Postgres-XC 1.1 Documentation | ||||
---|---|---|---|---|
Prev | Up | Chapter 30. Adding a New Node | Next |
Following steps should be performed to add a new datanode to a running cluster:
Initialize the new datanode. The following example initializes a new datanode named data_node_3.
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data3 --nodename data_node_3
Make the necessary changes in postgresql.conf of the new datanode, in particular specify new datanode name
Connect to any of the existing coordinators and lock the cluster for backup, do not close this session.
The following example assumes a coordinator is running on port 5432. Make sure the function call returns true.
The detailed description of the function pgxc_lock_for_backup
can be found
in Table 9-68
./psql postgres -p 5432 select pgxc_lock_for_backup();
Connect to any of the existing datanodes and take backup of the database. Please note that only schema (i.e. no data) is to be dumped. The following example assumes that a datanode is running on port 15432.
./pg_dumpall -p 15432 -s --file=/some/valid/path/some_file_name.sql
Start the new datanode specifying --restoremode while starting the it. The following example starts the new datanode on port 35432.
./postgres --restoremode -D ../data3 -p 35432
You can use pg_ctl with -Z restoremode option.
./pg_ctl start -Z restoremode -D ../data3 -p 5455
Restore the backup (taken in step 4) by connecting to the new datanode directly.
./psql -d postgres -f /some/valid/path/some_file_name.sql -p 35432
Quit the new datanode.
Start the new datanode specifying --datanode while starting.
./postgres --datanode -D ../data3 -p 35432
Create the new datanode on all the coordinators and reload configuration. The following example creates data_node_3, with host localhost and port 35432.
CREATE NODE DATA_NODE_3 WITH (HOST = 'localhost', type = 'datanode', PORT = 35432); SELECT pgxc_pool_reload();
Quit the session of step 3, this will unlock the cluster.
Redistribute existing data by using ALTER TABLE REDISTRIBUTE. The new datanode is now ready.