自学内容网 自学内容网

GaussDB运维管理工具(一)

gs_guc工具

功能和用法

gs_guc工具可以用来查看或修改GaussDB配置文件中的参数。

  • 数据库配置文件:gaussdb.confpostgresql.conf
  • 客户端认证配置文件:gs_hba.confpg_hba.conf
  • 集群管理组件配置文件:cm_server.confcm_agent.conf

gs_guc命令格式为:

# Checking GUC parameters:
    gs_guc check [-Z NODE-TYPE] [-N NODE-NAME] {-I INSTANCE-NAME | -D DATADIR} {-c "parameter", -c "parameter", ...}
    gs_guc check [-Z NODE-TYPE] [-N NODE-NAME] {-I INSTANCE-NAME | -D DATADIR} {-c parameter, -c parameter, ...}
    
# Configuring GUC parameters:
    gs_guc {set | reload} [-Z NODE-TYPE] [-N NODE-NAME] {-I INSTANCE-NAME | -D DATADIR} [--lcname=LCNAME] [--ignore-node=NODES] {-c "parameter = value" -c "parameter = value" ...}
    gs_guc {set | reload} [-Z NODE-TYPE] [-N NODE-NAME] {-I INSTANCE-NAME | -D DATADIR} [--lcname=LCNAME] [--ignore-node=NODES] {-c " parameter = value " -c " parameter = value " ...}
    gs_guc {set | reload} [-Z NODE-TYPE] [-N NODE-NAME] {-I INSTANCE-NAME | -D DATADIR} [--lcname=LCNAME] [--ignore-node=NODES] {-c "parameter = 'value'" -c "parameter = 'value'" ...}
    gs_guc {set | reload} [-Z NODE-TYPE] [-N NODE-NAME] {-I INSTANCE-NAME | -D DATADIR} [--lcname=LCNAME] [--ignore-node=NODES] {-c " parameter = 'value' " -c " parameter = 'value' " ...}
    gs_guc {set | reload} [-Z NODE-TYPE] [-N NODE-NAME] {-I INSTANCE-NAME | -D DATADIR} [--lcname=LCNAME] [--ignore-node=NODES] {-c "parameter" -c "parameter" ...}

# Configuring Authentication Policy:
    gs_guc {set | reload} [-Z NODE-TYPE] [-N NODE-NAME] {-I INSTANCE-NAME | -D DATADIR} [--ignore-node=NODES] -h "HOSTTYPE DATABASE USERNAME IPADDR IPMASK AUTHMEHOD authentication-options" 
    gs_guc {set | reload} [-Z NODE-TYPE] [-N NODE-NAME] {-I INSTANCE-NAME | -D DATADIR} [--ignore-node=NODES] -h "HOSTTYPE DATABASE USERNAME IPADDR-WITH-IPMASK AUTHMEHOD authentication-options" 
    gs_guc {set | reload} [-Z NODE-TYPE] [-N NODE-NAME] {-I INSTANCE-NAME | -D DATADIR} [--ignore-node=NODES] -h "HOSTTYPE DATABASE USERNAME HOSTNAME AUTHMEHOD authentication-options"     

其中:

  • -Z:指定节点类型,可以是datanode、cmserver、cmagent、gnsserver、coordinator。
  • -N:指定节点名,可以是单独的一个节点、也可以通过all指定所有节点。
  • -I:指定数据库实例名,可以是单独的一个实例、也可以通过all指定所有实例。
  • -D:指定实例的数据目录。-D-I 只用写一个就行。
  • -c:指定要查看或修改的参数名(和参数值)。
  • -h:指定要配置的客户端认证策略。

gs_guc检查参数

使用gs_guc check命令来查看GaussDB所有的DN节点配置参数:

su - omm && source ~/gauss_env_file
gs_guc check -Z datanode -N all -I all -c "enable_default_ustore_table"
gs_guc check -Z datanode -N all -I all -c "max_process_memory"
gs_guc check -Z datanode -N all -I all -c "shared_buffers"
gs_guc check -Z datanode -N all -I all -c "maintenance_work_mem"

gs_guc变更参数

使用gs_guc set命令来修改GaussDB配置文件中的参数(需要重启数据库才会生效):

# 修改数据库最大可用内存
gs_guc set -Z coordinator -Z datanode -N all -I all -c "max_process_memory=14GB"

# 修改数据库共享内存
gs_guc set -Z coordinator -Z datanode -N all -I all -c "shared_buffers=5120MB"

# 修改维护操作可使用的最大内存
gs_guc set -Z coordinator -Z datanode -N all -I all -c "maintenance_work_mem=64MB"

# 禁用UStore存储引擎
gs_guc set -Z datanode -N all -I all -c "enable_default_ustore_table=off"

# 修改数据库最大连接数
gs_guc set -Z datanode -N all -I all -c "max_connections=1024"

# 设置客户端认证策略
gs_guc set -Z datanode -N all -I all -h "host replication repluser 192.168.95.191/32 sha256"

# 清理已配置的客户端认证策略
gs_guc set -Z datanode -N all -I all -h "host replication repluser 192.168.95.191/32"

使用gs_guc reload命令重载HBA配置文件中的客户端认证策略(无需重启数据库就会生效):

gs_guc reload -Z datanode -N all -I all -h "host all all 0.0.0.0/0 trust"

gs_guc仅支持设置$GAUSSHOME/bin/cluster_guc.conf文件中的参数。

[omm@dbhost ~]$ cat $GAUSSHOME/bin/cluster_guc.conf | grep -v '^#' | grep -v '^$' | wc -l
884

gs_guc的日志

查看gs_guc产生的日志:

[omm@dbhost ~]$ more $GAUSSLOG/bin/gs_guc/gs_guc-2024-09-13_103954-current.log
...
[2024-09-13 16:27:10]
NOTICE: Enable to create ustore table by default
expected instance path: [/data/cluster/data/dn/dn_6001/postgresql.conf]
gs_guc set: enable_default_ustore_table=off: [/data/cluster/data/dn/dn_6001/postgresql.conf]

Total instances: 1. Failed instances: 0.
Success to perform gs_guc!

Command count is 1, Command success count is 1, Command failure count is 0.

Total instances: 1. Failed instances: 0.
ALL: Success to perform gs_guc!


[2024-09-13 16:28:17]
expected instance path: [/data/cluster/data/dn/dn_6001/postgresql.conf]
gs_guc set: max_process_memory=12GB: [/data/cluster/data/dn/dn_6001/postgresql.conf]

Total instances: 1. Failed instances: 0.
Success to perform gs_guc!

Command count is 1, Command success count is 1, Command failure count is 0.

Total instances: 1. Failed instances: 0.
ALL: Success to perform gs_guc!

[2024-09-13 16:28:35]
expected instance path: [/data/cluster/data/dn/dn_6001/postgresql.conf]
gs_guc set: shared_buffers=5120MB: [/data/cluster/data/dn/dn_6001/postgresql.conf]

Total instances: 1. Failed instances: 0.
Success to perform gs_guc!
  • 推荐使用gs_guc来设置参数,而不是手动修改配置文件。因为手动修改配置文件没有自动校验,如果出错可能会导致数据库重启失败。
  • gs_guc不支持参数值中包含#和反引号`的设置。这类参数可以通过手动编辑配置文件来修改。

gs_om工具

gs_om工具支持以下常用数据库维护功能:

  • 启停数据库、查询数据库状态、切换主备实例;
  • 修改IP、生成静态配置文件、SSL证书替换;
  • 日常巡检并上报告警等。

⭐️ 集中式不支持单独调用。使用root执行的功能需调用数据库工具临时存放的包路径下的gs_om执行。

数据库实例状态管理:

gs_om -t status --detail       # 实例状态查询

gs_om -t stop                  # 停止实例
gs_om -t start                 # 启动实例
gs_om -t start --time-out=300  # 启动实例并设置超时时间为300秒

gs_om -t restart               # 重启实例

:集中式部署禁止用gs_om启停,经测试可能会导致DN节点启动失败。

gs_om常用命令:

gs_om -t start [-h HOSTNAME] [--az=AZNAME] [--time-out=SECS] [-l LOGFILE]
gs_om -t stop [-h HOSTNAME] [--az=AZNAME] [-m MODE] [-l LOGFILE]
gs_om -t restart [--nodegroup-name=NODEGROUPNAME] [-l LOGFILE]
gs_om -t status [-h HOSTNAME] [-o OUTPUT] [--detail] [-l LOGFILE]
gs_om -t switch [-h HOSTNAME] [--az=AZNAME] [-D INSTANCEDIR] [--reset] [--time-out=SECS] [-l LOGFILE]
gs_om -t managecn -m MODE -X XMLFILE [-l LOGFILE]
gs_om -t change_mode -m [dcf|quorum] [-L] [-l LOGFILE] [--time-out=SECS]
gs_om -t changeip -X XMLFILE [--rollback] [-l LOGFILE] [--auto-stop]
gs_om -t generateconf -X XMLFILE [--distribute] [-l LOGFILE]
gs_om -t formatcu [-j NUM] [-l LOGFILE]
gs_om -t estimate -m upgrade [-l LOGFILE]
gs_om -t estimate -m install -X XMLFILE [-l LOGFILE]
gs_om -t estimate -m expand -X XMLFILE [-l LOGFILE]
gs_om -t estimate -m addCN [-l LOGFILE]
gs_om -t estimate -m replace -h HOSTNAME [-l LOGFILE]
gs_om -t estimate -m warm-standby -h HOSTNAME [-l LOGFILE]
gs_om -t virtualip -m MODE [-X XMLFILE | --virtual-ip=Ips] [-L] [-l LOGFILE]
gs_om -t cert [--cert-file=CERTFILE | --rollback] [-L] [-l LOGFILE] [-m COMPONENT]
gs_om -t tablespace [-h HOSTNAME] [-l LOGFILE]
gs_om -t kerberos -m [install|uninstall] -U USER [-l LOGFILE] [--krb-server ip|--krb-client] [--krb-standby ip]
gs_om -t ec -m [install|uninstall|add|delete|restart] [-U] [-N] [--type] {[--target|--all]|--key-files} [--force] [-l LOGFILE]
gs_om -t javaUDF -m [addjar|rmjar|ls] [-d REMOTERELATIVEPATH] [-s LOCALPATH] [-l LOGFILE]
gs_om -t express -m queryworkload [-h HOSTNAME] [--detail] [-l LOGFILE]
gs_om -t compare-cluster --remote-host=HOSTNAME --remote-env-file=MPPRCFILE [-l LOGFILE]
gs_om -t isolate_stop -h HOSTNAME [-l LOGFILE]
gs_om -t isolate_tostandby -h HOSTNAME [-l LOGFILE]
gs_om -t isolate_restore -h HOSTNAME [-l LOGFILE]
gs_om -t killsession [--close-hba|--restore-hba] [-l LOGFILE]
gs_om -t slow_node [-m MODE] [--interval=INTERVALS] [--check-count=COUNT] [--threshold=RATIO] [--wait-count=COUNT][-l LOGFILE]
gs_om -t hotpatch -c [load|unload|active|deactive|info|list|cleanLock|recover] -n NAME
gs_om -t perf_job -m [enable_all|disable_all|is_enable]
gs_om -t show_disk
gs_om -t show_cluster_disk
gs_om -t show_disk_and_log
gs_om -t show_alarm_log
gs_om -t get_all_primary_disk
gs_om -t dorado_switch -m [primary|standby]
gs_om -t dorado_failover --dorado_status=[normal|abnormal]
gs_om -t dorado_restore
gs_om -t dorado_disk_mount
gs_om -t dorado_query
gs_om -t dorado_refresh_dr_relations -m [replacement|reduce_replica|add_replica] --data_ips=hostnames
gs_om -t prepare_disaster_info -m [write|read] -U [USER] [--time-out=SECS] [--json=string]
gs_om -t streaming_disaster_recovery_start -m [primary|disaster_standby] [--time-out=SECS] [--json=string]
gs_om -t streaming_disaster_recovery_stop [--json=string]
gs_om -t streaming_disaster_recovery_failover [--delete-dr-info=0|1]
gs_om -t streaming_disaster_recovery_switchover -m [primary|disaster_standby] [--time-out=SECS]
gs_om -t streaming_disaster_recovery_query
gs_om -t break_dr_action -m [dorado_cluster|streaming_cluster] --break-action=start
gs_om -t streaming_disaster_recovery_keep --xlog-keep=INT
gs_om -t streaming_disaster_recovery_restore
gs_om -t streaming_disaster_recovery_simulation -m [primary|disaster_standby|disaster_simulation] --xlog-keep=INT --simulation-state=[start|end]
gs_om -t dr_change_hadr_user_info -U [USER]

📖 gs_om默认的日志路径为:$GAUSSLOG/om/gs_om-*.log

gs_ctl工具

gs_ctl工具支持以下数据库维护功能:

  • 启停GaussDB节点;
  • 在不停库的前提下重新加载配置文件(gaussdb.conf、gs_hba.conf);
  • 主备切换、主备状态查询、DN重建以及重建状态查询等。

⭐️ 集中式单节点不支持主备间操作

查询DN节点主备角色:

gs_ctl status -D /gsdata/dn/dn_6001

gs_ctl常用命令:

gs_ctl init[db]               [-D DATADIR] [-s] [-o "OPTIONS"]
gs_ctl start   [-w] [-t SECS] [-D DATADIR] [-s] [-l FILENAME] [-o "OPTIONS"] [-M SERVERMODE]
gs_ctl restart [-w] [-t SECS] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]
               [-o "OPTIONS"]
gs_ctl build   [-D DATADIR] [-b MODE] [-r SECS] [-C CONNECTOR] [-q] [-M SERVERMODE]
gs_ctl stop    [-W] [-t SECS] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]
gs_ctl reload  [-D DATADIR] [-s]
gs_ctl status  [-D DATADIR]
gs_ctl finishredo [-D DATADIR] [-s]
gs_ctl getlocalmaxlsn [-D XLOGDIR]
gs_ctl decode [-D DATADIR] [--startpos LSN] [--endpos LSN] [--xlogfolder XLOGDIR]
gs_ctl failover   [-W] [-t SECS] [-D DATADIR] [-U USERNAME] [-P PASSWORD] [-T TERM] [-u DCF-LOGGER-ID]
gs_ctl switchover [-W] [-D DATADIR] [-m SWITCHOVER-MODE] [-U USERNAME] [-P PASSWORD] [-f]
gs_ctl query   [-D DATADIR] [-U USERNAME] [-P PASSWORD] [-L lsn]
gs_ctl notify   -M SERVERMODE [-D DATADIR] [-U USERNAME] [-P PASSWORD]
gs_ctl kill    SIGNALNAME PID
gs_ctl querybuild   [-D DATADIR]
gs_ctl copy   [-D DATADIR] [-Q COPYMODE]
gs_ctl hotpatch  [-D DATADIR] [-a ACTION] [-n NAME]
gs_ctl stack [-D DATADIR] [-I lwtid]
gs_ctl startwalrcv [-w] [-t SECS] [-D DATADIR]
gs_ctl switchreplication [-W] [-t SEC] [-A APPLY-MODE] [-D DATADIR]
gs_ctl member         [-O OPERATION] [-u DCF-NODE-ID] [-i DCF-NODE-IP] [-e DCF-NODE-PORT] [-D PRIMARY-DATADIR]
gs_ctl changerole     [-R DCF-ROLE] [-D DATADIR] [-t SEC]
gs_ctl setrunmode     [-x XMODE] [-v VOTE-NUM] [-D PRIMARY-DATADIR]

📖 gs_ctl默认的日志路径为:$GAUSSLOG/bin/gs_ctl/gs_ctl-*.log


原文地址:https://blog.csdn.net/Sebastien23/article/details/144648154

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!