1、主备切换
登录备库(既要升级角色的数据库)
[omm@euler2 ~]$ gs_om -t status --detail
[ cluster state ]
cluster_state : normal
redistributing : no
current_az : az_all
[ datanode state ]
node node_ip port instance state
---------------------------------------------------------------------------------
1 euler1 172.16.220.151 26000 6001 /gauss/data/db1 p primary normal
2 euler2 172.16.220.152 26000 6002 /gauss/data/db1 s standby normal
3 euler3 172.16.220.153 26000 6003 /gauss/data/db1 c cascade normal
[omm@euler2 ~]$ gs_ctl switchover -d /gauss/data/db1
[2023-04-28 12:44:34.779][488531][][gs_ctl]: gs_ctl switchover ,datadir is /gauss/data/db1
[2023-04-28 12:44:34.779][488531][][gs_ctl]: switchover term (1)
[2023-04-28 12:44:34.784][488531][][gs_ctl]: waiting for server to switchover.........
[2023-04-28 12:44:40.828][488531][][gs_ctl]: done
[2023-04-28 12:44:40.828][488531][][gs_ctl]: switchover completed (/gauss/data/db1)
[omm@euler2 ~]$ gs_om -t status --detail
[ cluster state ]
cluster_state : normal
redistributing : no
current_az : az_all
[ datanode state ]
node node_ip port instance state
---------------------------------------------------------------------------------
1 euler1 172.16.220.151 26000 6001 /gauss/data/db1 p standby normal
2 euler2 172.16.220.152 26000 6002 /gauss/data/db1 s primary normal
3 euler3 172.16.220.153 26000 6003 /gauss/data/db1 c cascade normal
2、切换至级联备库
登录级联备库(要升级角色的数据库)
1、先由级联备库切换至备库
[omm@euler3 ~]$ gs_om -t status --detail
[ cluster state ]
cluster_state : normal
redistributing : no
current_az : az_all
[ datanode state ]
node node_ip port instance state
---------------------------------------------------------------------------------
1 euler1 172.16.220.151 26000 6001 /gauss/data/db1 p primary normal
2 euler2 172.16.220.152 26000 6002 /gauss/data/db1 s standby normal
3 euler3 172.16.220.153 26000 6003 /gauss/data/db1 c cascade normal
[omm@euler3 ~]$ gs_ctl switchover -d /gauss/data/db1
[2023-04-28 12:48:47.190][380541][][gs_ctl]: gs_ctl switchover ,datadir is /gauss/data/db1
[2023-04-28 12:48:47.190][380541][][gs_ctl]: switchover term (1)
[2023-04-28 12:48:47.194][380541][][gs_ctl]: waiting for server to switchover.......
[2023-04-28 12:48:51.219][380541][][gs_ctl]: done
[2023-04-28 12:48:51.219][380541][][gs_ctl]: switchover completed (/gauss/data/db1)
[omm@euler3 ~]$ gs_om -t status --detail
[ cluster state ]
cluster_state : normal
redistributing : no
current_az : az_all
[ datanode state ]
node node_ip port instance state
---------------------------------------------------------------------------------
1 euler1 172.16.220.151 26000 6001 /gauss/data/db1 p primary normal
2 euler2 172.16.220.152 26000 6002 /gauss/data/db1 s cascade normal
3 euler3 172.16.220.153 26000 6003 /gauss/data/db1 c standby normal
2、由备库切换至主库
[omm@euler3 ~]$ gs_ctl switchover -d /gauss/data/db1
[2023-04-28 12:49:15.763][382239][][gs_ctl]: gs_ctl switchover ,datadir is /gauss/data/db1
[2023-04-28 12:49:15.763][382239][][gs_ctl]: switchover term (1)
[2023-04-28 12:49:15.768][382239][][gs_ctl]: waiting for server to switchover................
[2023-04-28 12:49:28.835][382239][][gs_ctl]: done
[2023-04-28 12:49:28.835][382239][][gs_ctl]: switchover completed (/gauss/data/db1)
[omm@euler3 ~]$ gs_om -t status --detail
[ cluster state ]
cluster_state : normal
redistributing : no
current_az : az_all
[ datanode state ]
node node_ip port instance state
---------------------------------------------------------------------------------
1 euler1 172.16.220.151 26000 6001 /gauss/data/db1 p standby normal
2 euler2 172.16.220.152 26000 6002 /gauss/data/db1 s cascade normal
3 euler3 172.16.220.153 26000 6003 /gauss/data/db1 c primary normal
3、多主情况及遗留问题
多主情况
[omm@euler3 ~]$ gs_om -t status --detail
[ cluster state ]
cluster_state : unavailable
redistributing : no
current_az : az_all
[ datanode state ]
node node_ip port instance state
---------------------------------------------------------------------------------
1 euler1 172.16.220.151 26000 6001 /gauss/data/db1 p primary normal
2 euler2 172.16.220.152 26000 6002 /gauss/data/db1 s primary normal
3 euler3 172.16.220.153 26000 6003 /gauss/data/db1 c primary normal
1、关闭3节点
[omm@euler3 ~]$ gs_ctl stop -d /gauss/data/db1
[2023-04-28 12:59:58.418][402290][][gs_ctl]: gs_ctl stopped ,datadir is /gauss/data/db1
waiting for server to shut down.... done
server stopped
[omm@euler3 ~]$ gs_ctl start -d /gauss/data/db1
[2023-04-28 13:00:05.577][402471][][gs_ctl]: gs_ctl started,datadir is /gauss/data/db1
[2023-04-28 13:00:05.618][402471][][gs_ctl]: waiting for server to start...
.0 log: [alarm module]can not read gauss_warning_type env.
0 log: [alarm module]host name: euler3
2、关闭2节点
[2023-04-28 13:02:28.659][536665][][gs_ctl]: gs_ctl stopped ,datadir is /gauss/data/db1
waiting for server to shut down....... done
server stopped
3、调整2节点为standby
[omm@euler2 ~]$ gs_ctl start -d /gauss/data/db1 -m standby
[2023-04-28 13:02:44.303][536666][][gs_ctl]: gs_ctl started,datadir is /gauss/data/db1
[2023-04-28 13:02:44.328][536666][][gs_ctl]: waiting for server to start...
.0 log: [alarm module]can not read gauss_warning_type env.
0 log: [alarm module]host name: euler2
0 log: [alarm module]host ip: 172.16.220.152
0 log: [alarm module]cluster name: gscluster
0 log: [alarm module]invalid data in alarmitem file! read alarm english name failed! line: 57
...
bbox_dump_path is set to /gauss/corefile/
[2023-04-28 13:02:45.338][536666][][gs_ctl]: done
[2023-04-28 13:02:45.338][536666][][gs_ctl]: server started (/gauss/data/db1)
[omm@euler2 ~]$ gs_om -t status --detail
[ cluster state ]
cluster_state : degraded
redistributing : no
current_az : az_all
[ datanode state ]
node node_ip port instance state
---------------------------------------------------------------------------------
1 euler1 172.16.220.151 26000 6001 /gauss/data/db1 p primary normal
2 euler2 172.16.220.152 26000 6002 /gauss/data/db1 s standby need repair(wal)
3 euler3 172.16.220.153 26000 6003 /gauss/data/db1 c down manually stopped
4、修复状态
[omm@euler2 ~]$ gs_ctl build -d /gauss/data/db1
[2023-04-28 13:11:04.788][557128][][gs_ctl]: gs_ctl incremental build ,datadir is /gauss/data/db1
waiting for server to shut down.... done
server stopped
[2023-04-28 13:11:05.799][557128][][gs_ctl]: fopen build pid file "/gauss/data/db1/gs_build.pid" success
[2023-04-28 13:11:05.799][557128][][gs_ctl]: fprintf build pid file "/gauss/data/db1/gs_build.pid" success
[2023-04-28 13:11:05.799][557128][][gs_ctl]: fsync build pid file "/gauss/data/db1/gs_build.pid" success
[2023-04-28 13:11:05.803][557128][dn_6001_6002_6003][gs_ctl]: build try host(172.16.220.151) port(26001) success
[2023-04-28 13:11:05.804][557128][dn_6001_6002_6003][gs_rewind]: set gaussdb state file when incremental build:db stat
5、跟新配置信息
[omm@euler2 ~]$ gs_om -t refreshconf
generating dynamic configuration file for all nodes.
successfully generated dynamic configuration file.
[omm@euler2 ~]$ gs_om -t status --detail
[ cluster state ]
cluster_state : degraded
redistributing : no
current_az : az_all
[ datanode state ]
node node_ip port instance state
---------------------------------------------------------------------------------
1 euler1 172.16.220.151 26000 6001 /gauss/data/db1 p primary normal
2 euler2 172.16.220.152 26000 6002 /gauss/data/db1 s standby normal
3 euler3 172.16.220.153 26000 6003 /gauss/data/db1 c down manually stopped
6、启动3节点
[omm@euler3 ~]$ gs_ctl restart -d /gauss/data/db1
[2023-04-28 13:26:06.559][423700][][gs_ctl]: gs_ctl restarted ,datadir is /gauss/data/db1
[2023-04-28 13:26:06.559][423700][][gs_ctl]: is server running?
[2023-04-28 13:26:06.559][423700][][gs_ctl]: starting server anyway
[2023-04-28 13:26:06.560][423700][][gs_ctl]: waiting for server to start...
.0 log: [alarm module]can not read gauss_warning_type env.
0 log: [alarm module]host name: euler3
0 log: [alarm module]host ip: 172.16.220.153
[omm@euler3 ~]$ gs_om -t status --detail
[ cluster state ]
cluster_state : normal
redistributing : no
current_az : az_all
[ datanode state ]
node node_ip port instance state
---------------------------------------------------------------------------------
1 euler1 172.16.220.151 26000 6001 /gauss/data/db1 p primary normal
2 euler2 172.16.220.152 26000 6002 /gauss/data/db1 s standby normal
3 euler3 172.16.220.153 26000 6003 /gauss/data/db1 c standby normal
玩坏了,双主可以通过-m调整回来,双备怎么办,-m参数没有cascade呀
[omm@euler3 ~]$ gs_ctl build -d /gauss/data/db1 -b full -m cascade
[2023-04-28 13:31:28.555][426602][][gs_ctl]: gs_ctl full build ,datadir is /gauss/data/db1
waiting for server to shut down.... done
server stopped
[2023-04-28 13:31:29.571][426602][][gs_ctl]: current workdir is (/home/omm).
[2023-04-28 13:31:29.571][426602][][gs_ctl]: fopen build pid file "/gauss/data/db1/gs_build.pid" success
[omm@euler3 ~]$ gs_om -t status --detail
[ cluster state ]
cluster_state : normal
redistributing : no
current_az : az_all
[ datanode state ]
node node_ip port instance state
---------------------------------------------------------------------------------
1 euler1 172.16.220.151 26000 6001 /gauss/data/db1 p primary normal
2 euler2 172.16.220.152 26000 6002 /gauss/data/db1 s standby normal
3 euler3 172.16.220.153 26000 6003 /gauss/data/db1 c standby normal
全量重建也不行,我也不知道,我也不敢问,官方文档也没写
最后修改时间:2023-04-30 23:02:15
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【米乐app官网下载的版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。