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 permissions on the foreign data wrapper being used. Use the following syntax to grant permissions:

1
GRANT USAGE ON FOREIGN DATA WRAPPER fdw_name TO username;

fdw_name is the name of the foreign data wrapper, and username is the username 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 built-in 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 built-in foreign data wrapper.

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 built-in foreign data wrapper.

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'
);

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 'xxxxxxxx'
);

Helpful Links

ALTER SERVER DROP SERVER