CREATE SERVER

Function

CREATE SERVER creates an external server.

An external server stores information of HDFS clusters, OBS servers, DLI connections, or other homogeneous clusters.

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:

1
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

Examples

Create the hdfs_server server, in which hdfs_fdw is the foreign-data wrapper:

1
2
3
4
5
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'
) ;

Create the obs_server server, in which dfs_fdw is the foreign-data wrapper:

Hard-coded or plaintext AK and SK are risky. For security purposes, encrypt your AK and SK and store them in the configuration file or environment variables.

1
2
3
4
5
6
CREATE SERVER obs_server FOREIGN DATA WRAPPER DFS_FDW OPTIONS ( 
  address 'obs.xxx.xxx.com', 
  access_key 'xxxxxxxxx', 
  secret_access_key 'yyyyyyyyyyyyy', 
  type 'obs'
);

Create the dli_server server, in which dfs_fdw is the foreign-data wrapper:

Hard-coded or plaintext AK and SK are risky. For security purposes, encrypt your AK and SK and store them in the configuration file or environment variables.

1
2
3
4
5
6
7
8
9
CREATE SERVER dli_server FOREIGN DATA WRAPPER DFS_FDW OPTIONS ( 
  address 'obs.xxx.xxx.com', 
  access_key 'xxxxxxxxx', 
  secret_access_key 'yyyyyyyyyyyyy', 
  type 'dli',
  dli_address 'dli.xxx.xxx.com',
  dli_access_key 'xxxxxxxxx',
  dli_secret_access_key 'yyyyyyyyyyyyy'
);

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
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 '{Password}'
);

Helpful Links

ALTER SERVER DROP SERVER