Pivotal Knowledge Base

Follow

How to remove segments from Greenplum

Environment

Pivotal Greenplum: 4.3.x

OS: RHEL 6.x

Purpose

This article discusses the options available when the number of segments needs to be reduced in Greenplum

Cause 

There is a need to reduce the number of segments in a Pivotal Greenplum

Procedure

There is no option to remove a segment in Pivotal Greenplum, so the only two ways to reduce the number of segments in a cluster are: 

A) Migrate data to a new cluster with fewer segments

Or

B) Re-initialize the Pivotal Greenplum Cluster

This is the process to be followed

**WARNING: This procedure will delete all data on the Greenplum cluster with no way to recover the data - Backup any data before starting this procedure**

  1. Backup all greenplum databases. Make sure to place backup outside of the segment directory (for example, use --gp-d option in gp_dump like gp_dump -x MYDATABASE --gp-d=/tmp -C)
  2. Backup greenplum configuration from $MASTER_DATA_DIRECTORY (cp $MASTER_DATA_DIRECTORY/*.conf /tmp )

  3. Run gpdeletesystem (example output below) 

    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-Checking for database dump files...
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-Getting segment information...
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-Greenplum Instance Deletion Parameters
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:---------------------------------------
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-Greenplum Master hostname = localhost
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-Greenplum Master data directory = /data1/master/gpseg-1
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-Greenplum Master port = 5432
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-Greenplum Force delete of dump files = ON
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-Batch size = 32
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:---------------------------------------
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:- Segment Instance List
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:---------------------------------------
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-Host:Datadir:Port
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-mdw:/data1/master/gpseg-1:5432
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw1:/data1/primary/gpseg0:40000
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw2:/data1/mirror/gpseg0:50000
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw1:/data1/primary/gpseg1:40001
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw2:/data1/mirror/gpseg1:50001
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw1:/data1/primary/gpseg2:40002
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw2:/data1/mirror/gpseg2:50002
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw1:/data1/primary/gpseg3:40003
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw2:/data1/mirror/gpseg3:50003
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw2:/data1/primary/gpseg4:40000
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw3:/data1/mirror/gpseg4:50000
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw2:/data1/primary/gpseg5:40001
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw3:/data1/mirror/gpseg5:50001
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw2:/data1/primary/gpseg6:40002
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw3:/data1/mirror/gpseg6:50002
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw2:/data1/primary/gpseg7:40003
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw3:/data1/mirror/gpseg7:50003
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw3:/data1/primary/gpseg8:40000
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw4:/data1/mirror/gpseg8:50000
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw3:/data1/primary/gpseg9:40001
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw4:/data1/mirror/gpseg9:50001
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw3:/data1/primary/gpseg10:40002
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw4:/data1/mirror/gpseg10:50002
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw3:/data1/primary/gpseg11:40003
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw4:/data1/mirror/gpseg11:50003
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw4:/data1/primary/gpseg12:40000
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw1:/data1/mirror/gpseg12:50000
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw4:/data1/primary/gpseg13:40001
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw1:/data1/mirror/gpseg13:50001
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw4:/data1/primary/gpseg14:40002
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw1:/data1/mirror/gpseg14:50002
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw4:/data1/primary/gpseg15:40003
    20170705:11:25:40:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-sdw1:/data1/mirror/gpseg15:50003
    20170705:11:25:47:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-FINAL WARNING, you are about to delete the Greenplum instance
    20170705:11:25:47:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-on master host localhost.
    20170705:11:25:47:029990 gpdeletesystem:mdw:gpadmin-[WARNING]:-There are database dump files, these will be DELETED if you continue!
    20170705:11:25:55:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-Stopping database...
    20170705:11:26:22:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-Deleting segments and removing data directories...
    20170705:11:26:22:029990 gpdeletesystem:mdw:gpadmin-[INFO]:-Waiting for worker threads to complete...
    20170705:11:26:30:029990 gpdeletesystem:mdw:gpadmin-[WARNING]:-Delete system completed but warnings were generated.
  4. By default, you should have config and hostfile in your home directory

    ls ~/gpconfigs
    gpinitsystem_config hostfile_gpinitsystem

    Modify the hostfile_gpinitsystem if you want to add or remove segment servers to the configuration
    Modify gpinitsystem_config if you want to change the number of segments per segment server. You can do it by changing DATA_DIRECTORY line. For example, 3 entires would mean 3 primary segments per segment server. The same goes for MIRROR_DATA_DIRECTORY line

  5. Run gpinisystem with prepared gpinitsystem_config hostfile_gpinitsystem

    gpinitsystem -c gpinitsystem_config -h hostfile_gpinitsystem -S 

  6. Follow this article to load backup into a new greenplum instance (Basically, you have to copy all backup files to master and load it through master instance to redistribute it evenly)

  7. Adjust configuration files (like posgresql.conf and pg_hba.conf) in a $MASTER_DATA_DIRECTORY

 

 

Comments

Powered by Zendesk