CREATE SERVER
Function
CREATE SERVER creates an external server.
An external server stores HDFS cluster information, OBS server information, or other homogeneous cluster information.
Precautions
By default, only the system administrator can create a foreign server. Otherwise, creating a server requires USAGE permission on the foreign-data wrapper being used. The syntax is as follows:
GRANT USAGE ON FOREIGN DATA WRAPPER fdw_name TO username
fdw_name is the name of FOREIGN DATA WRAPPER, and username is the user name of creating SERVER.
Syntax
1 2 3 | CREATE SERVER server_name
FOREIGN DATA WRAPPER fdw_name
OPTIONS ( { option_name ' value ' } [, ...] ) ;
|
Parameter Description
- server_name
Specifies the name of the foreign server to be created.
Value range: The length must be less than or equal to 63.
- FOREIGN DATA WRAPPER fdw_name
Specifies the name of the foreign data wrapper.
Value range: fdw_name indicates the data wrapper created by the system in the initial phase of the database. Currently, fdw_name can be hdfs_fdw or dfs_fdw for the HDFS cluster, and can be gc_fdw for other homogeneous clusters.
- OPTIONS ( { option_name ' value ' } [, ...] )
Specifies the parameters for the server. The detailed parameter description is as follows:
- address
Specifies the IP address and port number of a NameNode (metadata node) in the HDFS cluster, or the IP address and port number of a CN in other homogeneous clusters.
HDFS NameNodes are deployed in primary/secondary mode for HA. Add the addresses of the primary and secondary NameNodes to ADDRESS. When accessing HDFS, GaussDB(DWS) dynamically checks for the primary NameNode.
- address option must exist.
- address option only supports IPv4 addresses in dot-decimal notation, and an address string cannot contain spaces. Multiple IP address and port pairs are separated by commas (,). The IP addresses and ports are separated by colons (:). In an HDFS cluster, you are advised to set two groups of IP:Port to represent the addresses of the primary and standby NameNodes, respectively.
- hdfscfgpath
This parameter is available only when type is HDFS.
You can set the hdfscfgpath parameter to specify the HDFS configuration file path. GaussDB(DWS) accesses the HDFS cluster based on the connection configuration mode and security mode specified in the HDFS configuration file stored in that path.
If the HDFS cluster is connected in non-secure mode, data transmission encryption is not supported. If address has been specified, the HDFS configuration file does not need to be specified. If it has not been specified, the configuration file needs to be specified by hdfscfgpath.
- type
Specifies whether dfs_fdw is connected to OBS or HDFS.
Valid value:
- OBS indicates that OBS is connected.
- HDFS indicates that HDFS is connected.
- address
Examples
Create the hdfs_server server, and hdfs_fdw is the built-in foreign-data wrapper.
1 2 3 4 5 6 7 8 9 | -- Create the hdfs_server server:
CREATE SERVER hdfs_server FOREIGN DATA WRAPPER HDFS_FDW OPTIONS
(address '10.10.0.100:25000,10.10.0.101:25000',
hdfscfgpath '/opt/hadoop_client/HDFS/hadoop/etc/hadoop',
type 'HDFS'
) ;
-- Delete the hdfs_server server:
DROP SERVER hdfs_server;
|
You are advised to create another server in the homogeneous cluster, where gc_fdw is the foreign data wrapper in the database.
1 2 3 4 5 6 7 8 9 10 | -- Create a server:
CREATE SERVER server_remote FOREIGN DATA WRAPPER GC_FDW OPTIONS
(address '10.10.0.100:25000,10.10.0.101:25000',
dbname 'test',
username 'test',
password 'xxxxxxxx'
);
-- Delete the server:
DROP SERVER server_remote;
|
Helpful Links
Last Article: CREATE SEQUENCE
Next Article: CREATE SYNONYM
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.