CREATE RESOURCE
This statement is used to create a resource. Only the root or admin user can create resources. Currently supports Spark, ODBC, S3 external resources. In the future, other external resources may be added to Doris for use, such as Spark/GPU for query, HDFS/S3 for external storage, MapReduce for ETL, etc.
grammar:
CREATE [EXTERNAL] RESOURCE "resource_name" PROPERTIES ("key"="value", ...);
illustrate:
Create a Spark resource named spark0 in yarn cluster mode.
CREATE EXTERNAL RESOURCE "spark0" PROPERTIES ( "type" = "spark", "spark.master" = "yarn", "spark.submit.deployMode" = "cluster", "spark.jars" = "xxx.jar,yyy.jar", "spark.files" = "/tmp/aaa,/tmp/bbb", "spark.executor.memory" = "1g", "spark.yarn.queue" = "queue0", "spark.hadoop.yarn.resourcemanager.address" = "127.0.0.1:9999", "spark.hadoop.fs.defaultFS" = "hdfs://127.0.0.1:10000", "working_dir" = "hdfs://127.0.0.1:10000/tmp/doris", "broker" = "broker0", "broker.username" = "user0", "broker.password" = "password0" );
Spark related parameters are as follows:
Working_dir and broker need to be specified when Spark is used for ETL. described as follows:
ALTER SYSTEM ADD BROKER command.Create an ODBC resource
CREATE EXTERNAL RESOURCE `oracle_odbc` PROPERTIES ( "type" = "odbc_catalog", "host" = "192.168.0.1", "port" = "8086", "user" = "test", "password" = "test", "database" = "test", "odbc_type" = "oracle", "driver" = "Oracle 19 ODBC driver" );
The relevant parameters of ODBC are as follows:
Create S3 resource
CREATE RESOURCE "remote_s3" PROPERTIES ( "type" = "s3", "s3.endpoint" = "bj.s3.com", "s3.region" = "bj", "s3.access_key" = "bbb", "s3.secret_key" = "aaaa", -- the followings are optional "s3.connection.maximum" = "50", "s3.connection.request.timeout" = "3000", "s3.connection.timeout" = "1000" );
If S3 resource is used for cold hot separation, we should add more required fields.
CREATE RESOURCE "remote_s3" PROPERTIES ( "type" = "s3", "s3.endpoint" = "bj.s3.com", "s3.region" = "bj", "s3.access_key" = "bbb", "s3.secret_key" = "aaaa", -- required by cooldown "s3.root.path" = "/path/to/root", "s3.bucket" = "test-bucket" );
S3 related parameters are as follows:
s3.endpoint: s3 endpoints3.region:s3 regions3.root.path: s3 root directorys3.access_key: s3 access keys3.secret_key: s3 secret keys3.bucket:s3 buckets3.connection.maximum: the maximum number of s3 connections, the default is 50s3.connection.request.timeout: s3 request timeout, in milliseconds, the default is 3000s3.connection.timeout: s3 connection timeout, in milliseconds, the default is 1000Create JDBC resource
CREATE RESOURCE mysql_resource PROPERTIES ( "type"="jdbc", "user"="root", "password"="123456", "jdbc_url" = "jdbc:mysql://127.0.0.1:3316/doris_test?useSSL=false", "driver_url" = "https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/jdbc_driver/mysql-connector-java-8.0.25.jar", "driver_class" = "com.mysql.cj.jdbc.Driver" );
JDBC related parameters are as follows:
Create HDFS resource
CREATE RESOURCE hdfs_resource PROPERTIES ( "type"="hdfs", "username"="user", "password"="passwd", "dfs.nameservices" = "my_ha", "dfs.ha.namenodes.my_ha" = "my_namenode1, my_namenode2", "dfs.namenode.rpc-address.my_ha.my_namenode1" = "nn1_host:rpc_port", "dfs.namenode.rpc-address.my_ha.my_namenode2" = "nn2_host:rpc_port", "dfs.client.failover.proxy.provider.my_ha" = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" );
HDFS related parameters are as follows:
Create HMS resource
HMS resource is used to create hms catalog
CREATE RESOURCE hms_resource PROPERTIES ( 'type'='hms', 'hive.metastore.uris' = 'thrift://127.0.0.1:7004', 'dfs.nameservices'='HANN', 'dfs.ha.namenodes.HANN'='nn1,nn2', 'dfs.namenode.rpc-address.HANN.nn1'='nn1_host:rpc_port', 'dfs.namenode.rpc-address.HANN.nn2'='nn2_host:rpc_port', 'dfs.client.failover.proxy.provider.HANN'='org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider' );
HMS related parameters are as follows:
Create ES resource
CREATE RESOURCE es_resource PROPERTIES ( "type"="es", "hosts"="http://127.0.0.1:29200", "nodes_discovery"="false", "enable_keyword_sniff"="true" );
ES related parameters are as follows:
CREATE, RESOURCE