How to change data directory and port of an existing Master
search cancel

How to change data directory and port of an existing Master

book

Article ID: 420007

calendar_today

Updated On:

Products

VMware Tanzu Greenplum

Issue/Introduction

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

Environment

GPDB 6.x

Resolution

IMPORTANT NOTE: This process involves initializing and activating the Master a couple of times. It does require some cluster downtime.

Follow the steps mentioned below to change the data directory and port of an existing Master:


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

Port

gpadmin=# select * from gp_segment_configuration;
 dbid | content | role | preferred_role | mode | status | port | hostname | address |        datadir
------+---------+------+----------------+------+--------+------+----------+---------+-----------------------
    1 |      -1 | p    | p              | n    | u      | 5432 | u82      | u82     | /data/master/gpsegS-1

gpadmin=# show port; port ------ 5432 $ echo $PGPORT 5432

2. Verify the directory and port used by the postmaster process:

[gpadmin@u82 ~]$ ps -ef |grep master
gpadmin    16989       1  0 22:42 ?        00:00:00 /usr/local/greenplum-db-6.28.0/bin/postgres -D /data/master/gpsegS-1 -p 5432 -E

3. If you have a standby Master configured currently, 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 /data/master/gpseg2  and the port to 5332:

gpinitstandby -s u83 -S /data/master/gpseg2 -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 /data/master/gpseg2 and 5332 respectively. Activate the newly created standby instance:

gpactivatestandby -d /data/master/gpseg2

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

ps -ef |grep master
gpadmin    16989       1  0 22:42 ?        00:00:00 /usr/local/greenplum-db-6.28.0/bin/postgres -D /data/master/gpseg2 -p 5332 -E

9. Now when 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.

gpadmin=# select * from gp_segment_configuration where content = -1;

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