基本管理
本节将介绍MatrixDB的基本运维管理,包括启停、查看运行状态、修改集群配置等。这些命令都是通过master节点控制的,所以必须在master节点上执行。
1. 启动MatrixDB
gpstart -a
命令可以启动MatrixDB集群。
[mxadmin@mdw ~]$ gpstart -a
20210723:16:00:36:002624 gpstart:sdw2:mxadmin-[INFO]:-Starting gpstart with args: -a
20210723:16:00:36:002624 gpstart:sdw2:mxadmin-[INFO]:-Gathering information and validating the environment...
20210723:16:00:36:002624 gpstart:sdw2:mxadmin-[INFO]:-Greenplum Binary Version: 'postgres (MatrixDB) 4.1.0-community (Greenplum Database) 7.0.0+dev.16905.gc6dbf4f14d build commit:c6dbf4f14d4452a414198fd45d507819803fffb2'
......
20210723:16:00:38:002624 gpstart:sdw2:mxadmin-[INFO]:-Database successfully started
gpstart的详细使用方法请参考文档
2. 停止MatrixDB
gpstop -a
命令用来停止一个正在运行的集群。
[mxadmin@mdw ~]$ gpstop -a
20210723:16:08:41:002827 gpstop:sdw2:mxadmin-[INFO]:-Starting gpstop with args: -a
20210723:16:08:41:002827 gpstop:sdw2:mxadmin-[INFO]:-Gathering information and validating the environment...
......
20210723:16:08:43:002827 gpstop:sdw2:mxadmin-[INFO]:-Successfully shutdown 1 of 1 segment instances
20210723:16:08:43:002827 gpstop:sdw2:mxadmin-[INFO]:-Database successfully shutdown with no errors reported
用gpstop -a
停止集群的前提是当前没有活跃连接,否则将挂起直到其他连接退出。
如果要强行杀掉用户连接并关闭集群,请使用gpstop -a -M fast
。
2.1 重启
gpstop -ar
可以重启集群。
2.2 重新加载授权配置
当修改pg_hba.conf
授权配置之后,需要调用gpstop -u
来重新加载授权配置。
gpstop的详细使用方法请参考文档
3. 查看集群状态
gpstate
可以查看集群的运行状态,包括:
- master和segment的配置信息
- 镜像配置等
[mxadmin@mdw ~]$ gpstate
20210723:17:00:15:004109 gpstate:sdw2:mxadmin-[INFO]:-Starting gpstate with args:
......
20210723:17:00:15:004109 gpstate:sdw2:mxadmin-[INFO]:-Obtaining Segment details from master...
20210723:17:00:15:004109 gpstate:sdw2:mxadmin-[INFO]:-Gathering data from segments...
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:-Greenplum instance status summary
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:-----------------------------------------------------
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Master instance = Active
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Master standby = No master standby configured
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Total segment instance count from metadata = 1
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:-----------------------------------------------------
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Primary Segment Status
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:-----------------------------------------------------
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Total primary segments = 1
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Total primary segment valid (at master) = 1
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Total primary segment failures (at master) = 0
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Total number of postmaster.pid files missing = 0
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Total number of postmaster.pid files found = 1
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Total number of postmaster.pid PIDs missing = 0
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Total number of postmaster.pid PIDs found = 1
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Total number of /tmp lock files missing = 0
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Total number of /tmp lock files found = 1
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Total number postmaster processes missing = 0
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Total number postmaster processes found = 1
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:-----------------------------------------------------
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Mirror Segment Status
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:-----------------------------------------------------
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:- Mirrors not configured on this array
20210723:17:00:16:004109 gpstate:sdw2:mxadmin-[INFO]:-----------------------------------------------------
4. 修改集群配置
gpconfig
用于查看或修改配置文件postgresql.conf
中的配置参数。
4.1 查看配置
通过gpconfig -s
加配置名可以查看配置:
[mxadmin@mdw ~]$ gpconfig -s shared_buffers
Values on all segments are consistent
GUC : shared_buffers
Master value: 1078464kB
Segment value: 1078464kB
4.2 修改配置
通过gpconfig -c {配置名} -v {值}
来修改配置:
[mxadmin@mdw ~]$ gpconfig -c shared_buffers -v 128MB
20210723:17:13:35:004318 gpconfig:sdw2:mxadmin-[INFO]:-completed successfully with parameters '-c shared_buffers -v 128MB'
修改配置后要重启集群才能生效:
[mxadmin@mdw ~]$ gpstop -ar
重启后,查看配置:
[mxadmin@mdw ~]$ gpconfig -s shared_buffers
Values on all segments are consistent
GUC : shared_buffers
Master value: 128MB
Segment value: 128MB
gpconfig的详细使用方法请参考文档