Pivotal Knowledge Base

Follow

How to Change Data Directory and Port of an Existing Master

Environment

Pivotal Greenplum: 4.3.x

Purpose

Normally changing the MASTER_DATA_DIRECTORY or the master port requires changing some entries in the catalog tables. This article outlines how to make these changes using gpinitstandby instead of issuing direct updates to the catalog.

Procedure

Note: This process involves initializing and activating the master a couple time, so it does require some cluster downtime.

1. Check the current master settings in gp_segment_configuration and pg_filespace_entry. Verify this with your environment variables and postgresql.conf values:

Port:

gpadmin=# select dbid,content,hostname,port from gp_segment_configuration where content = -1;
dbid | content | hostname | port
------+---------+----------+------
1 | -1 | mdw | 5432
gpadmin=# show port;
port
------
5432
$ echo $PGPORT
5432

Master Data Directory:

gpadmin=# select * from pg_filespace_entry where fsedbid = 1;
fsefsoid | fsedbid | fselocation
----------+---------+-----------------------
3052 | 1 | /data1/master/gpseg-1

$ echo $MASTER_DATA_DIRECTORY
/data1/master/gpseg-1

2. Finally, verify the directory and port used by the postmaster process:

$ ps -ef | grep silent | grep -v grep
gpadmin 19363 1 0 Aug30 ? 00:00:07 /usr/local/greenplum-db-4.3.12.0/bin/postgres -D /data1/master/gpseg-1 -p 5432 -b 1 -z 16 --silent-mode=true -i -M master -C -1 -x 0 -E

3. If you currently have a standby master configured, then remove it first:

gpinitstandby -r

4. Create a new standby master instance with the new directory and port settings. In this example, we are changing the master data directory to /data2/master/gpseg-1 and the port to 5332:

gpinitstandby -s smdw -F pg_system:/data2/master/gpseg-1 -P 5332

5. Verify the standby master has been created in sync with the current active master:

gpstate -f

6. Shutdown the master instance only:

gpstop -m

7. SSH to smdw and check that the MASTER_DATA_DIRECTORY and PGPORT environment variables are set to /data2/master/gpseg-1 and 5332 respectively. Activate the newly created standby instance.

gpactivatestandby -d /data2/master/gpseg-1

8. Verify the new postmaster process is running when the changed settings:

$ ps -ef | grep silent | grep -v grep
/usr/local/greenplum-db-4.3.12.0/bin/postgres -D /data2/master/gpseg-1 -p 5332 -b 34 -z 16 --silent-mode=true -i -M master -C -1 -x 0 -y -E

9. Now that the master and standby master hosts have been swapped to a different host, if you want to restore these instances to their original hosts, follow the steps in the Greenplum Documentation.

10. Finally, verify gp_segment_configuration and pg_filespace_entry to see the changed entries:

gpadmin=# select * from pg_filespace_entry where fsedbid = 1;
fsefsoid | fsedbid | fselocation
----------+---------+-----------------------
3052 | 1 | /data2/master/gpseg-1
gpadmin=# select dbid,content,hostname,port from gp_segment_configuration where content = -1;
dbid | content | hostname | port
------+---------+----------+------
1 | -1 | mdw | 5332

gpadmin=# show port;
 port
------
5332

Comments

Powered by Zendesk