Greenplum Cluster Operations and Maintenance Guide
Starting the Cluster
gpstart -a # bring the entire cluster online
gpstop -r # restart after configuration changes that require reboot
gpstop -u # reload config files without stopping services
Master-only Maintenance Mode
gpstart -m # start master in utility mode
PGOPTIONS='-c gp_session_role=utility' psql postgres # connect for catalog work
gpstop -mr # return to normal production mode
Shutting Down Services
gpstop # graceful shutdown
gpstop -M fast # immediate shutdown
Fialover to the Standby Master
gpactivatestandby -d $MASTER_DATA_DIRECTORY
gpstate -f # verify standby promotion
mv /data/master/gpseg-1 /data/master/gpseg-1.bak # archive old master dir
Daily Health Checks
gpstate # overall cluster health
select * from gp_toolkit.gp_disk_free; # free space from SQL
gpssh -f host.list -e "df -h | grep data" # free space from OS
psql -c "select * from pg_stat_activity;" # active connections
psql -c "select pg_size_pretty(pg_database_size('test'));" # db size
psql -c "select pg_size_pretty(pg_relation_size('schema.test'));" -- table size
select relname from pg_class where relname like 'ods%';
select gp_segment_id, count(*) from test group by 1; -- data skew
select * from gp_segment_configuration order by 1; -- segment config
vacuum analyze tablename; -- reclaim & stats
Monitoring Queries and Locks
select * from pg_stat_activity where waiting = 't' order by current_query;
select * from pg_stat_activity where state <> 'idle' and query_start < now() - interval '1 hour' order by query_start;
Segment Recovery Workflow
# 1. Check failed segments
gpstate -e
# 2. Standard recovery
nohup gprecoverseg -a &
# 3. Rebalance primaries if roles flipped
nohup gprecoverseg -ra &
# 4. Full rebuild when delta is too large
nohup gprecoverseg -Fa &
Transaction Control
BEGIN; -- or START TRANSACTION
-- DML statements
COMMIT; -- or END
-- or
ROLLBACK;
SAVEPOINT sp1;
-- more work
ROLLBACK TO SAVEPOINT sp1;
RELEASE SAVEPOINT sp1;
Free-Space Map Tuning
Expired rows are tracked in the free-space map. Tune with:
max_fsm_pages
max_fsm_relations
When the map overflwos, use CREATE TABLE AS to rebuild the table instead of VACUUM FULL.
Statistics and Vacuum
VACUUM ANALYZE tb_cp_02;
Log Management
Server logs roll daily and live in each instance’s pg_log directory:
gpdb-YYYY-MM-DD_TIME.csv
Verbosity levels:
show log_min_messages; -- server side
show client_min_messages; -- client side
Search logs:
gplogfilter -n 3 # last 3 lines on master
gpssh -f seg_host_file -e 'gplogfilter -n 3 /data/primary/*/pg_log/gpdb*.csv'
Utility logs are written to ~/gpAdminLogs/script_name_YYYYMMDD.log.
System Catalogs
Standard PostgreSQL catalogs live in pg_catalog. Greenplum additions include:
- gp_configuration
- gp_distribution_policy
- gp_distributed_log
- gp_id
- gp_version_at_initdb
- gp_master_mirroring
- gp_pgdatabase
\dtS # list system tables
\dvS # list system views