Deepgreen & Greenplum DBA小白普及课之二(管理问题解答)

原文链接: http://click.aliyun.com/m/24831/
摘要: 不积跬步无以至千里,要想成为一名合格的数据库管理员,首先应该具备扎实的基础知识及问题处理能力。本文参考Pivotal官方FAQ,对在管理Deepgreen & Greenplum时经常会遇到的问题提出解决思路/答案。

074f69580b19f3e9185c564025209dfa3cfad3e7

不积跬步无以至千里,要想成为一名合格的数据库管理员,首先应该具备扎实的基础知识及问题处理能力。本文参考Pivotal官方FAQ,对在管理Deepgreen & Greenplum时经常会遇到的问题提出解决思路/答案。希望对大家有所帮助,如果有朋友有更多的问题分享,请留言,我将一并整理。

下面单刀直入,开始问题浏览及解决思路梳理:
1.执行gpstart命令失败了,我该怎么办?
查看gpstart命令在Master执行失败后返回的错误原因;
检查gpstart的启动日志,这里可能存着更详细的信息,日志存储在:~gpadmin/gpAdminLogs/gpstart_yyyymmdd.log;
检查pg startup产生的日志文件$MASTER_DATA_DIRECTORY/pg_log/startup.log,看能否发现蛛丝马迹;
如果Segment启动失败,在以上几个日志中,我们可以定位出启动失败的Segment编号,紧接着我们可以切换到对应的Segment 主机下面,找到以上两个日志去查看Segment失败的具体原因。
2.为什么我们需要gpstart -m和gpstop -m命令?
这两个命令允许我们只启动或关闭Master,不启动Segment数据节点。这两个命令主要用来配合管理员做一些数据库高级配置操作,一般用户最好不要使用。
3.如何查看数据库在线时间?
在psql界面执行如下语句:
postgres=# select now() - pg_postmaster_start_time() ;
       ?column?      
-----------------------
1 day 13:51:04.865115
(1 row)

4.怎样才能删除Mirror节点?
Deepgreen和Greenplum不提供Mirror节点删除工具,所以添加Mirror之前请慎重考虑。如果非要去除Mirror节点,可以重新初始化集群,再把之前的数据恢复回来。
5.gpcheckcat是用来干嘛的?如何执行这个命令?
gpcheckcat工具用来检查Master和Segments之间的catalog差异,存在$GPHOME/bin/lib目录下,如果没有设置到环境变量,需要手工切换到该目录下执行。
语法如下:
Usage: gpcheckcat [dbname]

        -?
        -B parallel: number of worker threads
        -g dir     : generate SQL to rectify catalog corruption, put it in dir
        -h host    : DB host name
        -p port    : DB port number
        -P passwd  : DB password
        -o         : check OID consistency
        -U uname   : DB User Name
        -v         : verbose
执行举例(报告结果在最后):
dgadmin@flash:~/deepgreendb/bin/lib$ ./gpcheckcat postgres

Connected as user 'dgadmin' to database 'postgres', port '15432', gpdb version '4.3'
-------------------------------------------------------------------
Performing test 'duplicate'
Total runtime for this test: 0:00:24.49
Performing test 'missing_extraneous'
Total runtime for this test: 0:00:25.51
Performing test 'inconsistent'
Total runtime for this test: 0:00:40.60
Performing test 'foreign_key'
Total runtime for this test: 0:00:01.74
Performing test 'acl'
Total runtime for this test: 0:00:00.04
Performing test 'persistent'
Total runtime for this test: 0:00:00.38
Performing test 'pgclass'
Total runtime for this test: 0:00:00.01
Performing test 'namespace'
Total runtime for this test: 0:00:00.05
Performing test 'distribution_policy'
Total runtime for this test: 0:00:00.00
Performing test 'dependency'
Total runtime for this test: 0:00:02.18
Performing test 'owner'
Total runtime for this test: 0:00:00.04
Performing test 'part_integrity'
Total runtime for this test: 0:00:00.03
Performing test 'part_constraint'
Total runtime for this test: 0:00:00.04
Performing test 'duplicate_persistent'
Total runtime for this test: 0:00:00.43

SUMMARY REPORT
===================================================================
Total runtime for 14 test(s): 0:01:35.59
Found no catalog issue

6.怎样删除Standby?
想要移除当前配置的Standby节点,只需要在Master主机上执行命令:gpinitstandby -r   。
7.如何执行Master和Standby之间的重新同步?
如果已经配置了Standby节点,并且想要同步主备之间的数据,可以执行以下命令:
gpinitstandby -n

8.如何恢复一个无效的Segment节点?
使用gprecoverseg工具,它能识别哪个Segment需要被恢复并执行恢复。
9.如何增加Mirror节点?
如果集群初始化没有配置Mirror节点,可以通过gpaddmirrors工具增加Mirror节点。
具体命令执行细节请参考:gpaddmirrors --help
10.如何查看Master,primary和mirror之间的映射关系?
通过执行下面语句,看整个集群映射关系:
postgres=# select * from gp_segment_configuration order by dbid;
dbid | content | role | preferred_role | mode | status | port  | hostname | address | replication_port | san_mounts
------+---------+------+----------------+------+--------+-------+----------+---------+------------------+------------
    1 |      -1 | p    | p              | s    | u      | 15432 | flash    | flash   |                  |
    2 |       0 | p    | p              | s    | u      | 25432 | flash    | flash   |            28432 |
    3 |       1 | p    | p              | s    | u      | 25433 | flash    | flash   |            28433 |
    4 |       0 | m    | m              | s    | u      | 26432 | flash    | flash   |            27432 |
    5 |       1 | m    | m              | s    | u      | 26433 | flash    | flash   |            27433 |
(5 rows)

11.如何以管理模式启动集群?
限制模式:
执行gpstart -R可以启动限制模式,此时只有超级用户才可以连接到数据库。
系统模式:
执行gpstart -m可以启动系统模式,此时我们可以单独连接到某一个Master或者Segment实例,例如只连接到Master实例
dgadmin@flash:~$ PGOPTIONS='-c gp_session_role=utility' psql -d postgres
psql (8.2.15)
Type "help" for help.

postgres=#

12.如何运行I/O、netperf检查工具gpcheckperf?
针对每个网络接口卡的网络I/O测试:
gpcheckperf -f seg_host_file_nic-1 -r N -d /data/gpcheckperf > seg_host_file_nic_1.out
gpcheckperf -f seg_host_file_nic-2 -r N -d /data/gpcheckperf > seg_host_file_nic_2.out
针对磁盘IO的测试:
gpcheckperf -f seg_host_file_nic-1 -r ds -D -d /data/gpdb_p1 -d  /data/gpdb_p2 -d /data/gpdb_m1 -d  /data/gpdb_m2

13.如何更新postgresql.conf文件并使生效?
除了常规的修改postgresql.conf文件并重载/重启使参数生效外,还可以使用gpconfig工具进行设置。具体命令参见:gpconfig --help
14.pg_hba.conf文件是干嘛用的?
Master主机上的pg_hba.conf文件用来控制客户端访问及授权。具体如何配置请参见官方数据库管理手册。
15.如何增加数据库新用户?
原文链接: http://click.aliyun.com/m/24831/

猜你喜欢

转载自1247520008.iteye.com/blog/2382561