In an MRS cluster, Location can be set to an OBS file system path during Spark table creation and Spark can connect to OBS through Hive Metastore.
cd Client installation directory
kinit Component operation user
spark-sql --master yarn
For example, to create a table named test whose Location is obs://obs-test/test/Database name/Table name, run the following command:
create external table testspark(name string) location "obs://obs-test/test/Database name/Table name";
Figure 1 spark.sql.warehouse.location.first configuration

Figure 2 spark.sql.warehouse.location.first configuration

If you do not download and install the client again, you can perform the following steps to update the Spark client configuration file (for example, the client directory is /opt/client): cd /opt/client vi Spark/spark/conf/hive-site.xml Change the value of hive.metastore.warehouse.dir to the corresponding OBS path, for example, obs://hivetest/user/hive/warehouse/. vi Spark/spark/conf/spark-defaults.conf
source bigdata_env
kinit Service user (skip this step for normal clusters)
spark-sql
create table d(a int);
desc formatted d;
As shown in the following figure, the location of table d is in the specified OBS path.

spark-beeline
create table e(a int);
desc formatted e;
As shown in the following figure, the location of table e is in the specified OBS path.


If Kerberos authentication is enabled for the cluster (the cluster is in security mode) and you need to store real-time data to OBS after the interconnection, perform the following operations to grant the Read and Write permissions on the corresponding OBS path to the specific user:
The following figure shows the configurations needed for adding the Read and Write permissions on obs://OBS parallel file system name/cdldata to user group obs_cdl.
