Updated on 2024-08-20 GMT+08:00

CREATE NODE

Description

Creates a cluster node.

Precautions

CREATE NODE is an API of the cluster management tool. You are advised not to use this API, because doing so affects the cluster. Only the administrator has the permission to use this API.

Syntax

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
CREATE NODE nodename WITH
  (
    [ TYPE = nodetype,]
    [ HOST = hostname,]
    [ PORT = portnum,]
    [ HOST1 = 'hostname',]
    [ PORT1 = portnum,]
    [ HOSTPRIMARY [ = boolean ],]
    [ PRIMARY [ = boolean ],]
    [ PREFERRED [ = boolean ],]
    [ SCTP_PORT = portnum,]
    [ CONTROL_PORT = portnum,]
    [ SCTP_PORT1 = portnum,]
    [ CONTROL_PORT1 = portnum ]
  );

Parameters

  • nodename

    Specifies the node name.

    Value range: a string. It must comply with the naming convention.

  • TYPE = nodetype

    Specifies the type of a node.

    Value range:

    • 'coordinator'
    • 'datanode'
  • HOST = hostname

    Specifies the host name or IP address of a node.

  • PORT = portnum

    Specifies the port number of the primary node to which a node is bound.

  • HOST1 = hostname

    Specifies the name or IP address of the standby node corresponding to a node.

  • PORT1 = portnum

    Specifies the port number of the standby node to which a node is bound.

  • HOSTPRIMARY
  • PRIMARY = boolean

    Specifies whether the node is a primary node or not. A primary node allows read/write operations. A non-primary node allows only read operations.

    Value range:

    • true
    • false (default value)
  • PREFERRED = boolean

    Specifies whether the node is a preferred node for read operations.

    Value range:

    • true
    • false (default value)
  • SCTP_PORT = portnum

    Specifies the port used by the TCP proxy communications library of the primary node to listen on the data transmission channel. TCP is used to listen on connections.

  • CONTROL_PORT = portnum

    Specifies the port used by the TCP proxy communications library of the primary node to listen on the control transmission channel. The TCP protocol is used to listen on connections.

  • SCTP_PORT1 = portnum

    Specifies the port used by the TCP proxy communications library of the standby node to listen on the data transmission channel. TCP is used to listen on connections.

  • CONTROL_PORT 1= portnum

    Specifies the port used by the TCP proxy communications library of the standby node to listen on the control transmission channel. The TCP protocol is used to listen on connections.

Examples

-- Create cluster nodes.
gaussdb=# CREATE NODE datanode1 WITH(
   TYPE = datanode,
   PREFERRED = false
);
gaussdb=# CREATE NODE datanode2 WITH(
   TYPE = datanode,
   PREFERRED = false
);

-- Query the initial cluster DN status.
gaussdb=# SELECT node_name, nodeis_preferred FROM pgxc_node WHERE node_type = 'D' ORDER BY 1;
 node_name | nodeis_preferred
-----------+------------------
 datanode1 | f
 datanode2 | f
(2 rows)

-- Set datanode1 as the preferred DN.
gaussdb=# ALTER NODE datanode1 WITH(preferred = true);
-- Query the cluster DN status after the change.
gaussdb=# SELECT node_name, nodeis_preferred FROM pgxc_node WHERE node_type = 'D' ORDER BY 1;
 node_name | nodeis_preferred
-----------+------------------
 datanode1 | t
 datanode2 | f
(2 rows)

-- Delete nodes from the cluster.
gaussdb=# DROP NODE datanode1;
gaussdb=# DROP NODE datanode2;

Helpful Links

ALTER NODE and DROP NODE