原文链接:www.gbase.cn/community/p…
更多精彩内容尽在南大通用GBase技术社区,南大通用致力于成为用户最信赖的数据库产品供应商。
在线替换1个节点集群IP
coordinator节点刷快照:
python
import gcware
gcware.flush_statemachine()
最终类似于以下情形: /opt/IP/gcware/data/gcware
-rw-r--r-- 1 gbase gbase 48 1月 13 15:57 GCWARE_META.A
-rw-r--r-- 1 gbase gbase 39 1月 13 15:57 GCWARE_META.B
-rw-r--r-- 1 gbase gbase 320 1月 13 16:22 REDOLOG.89215
-rw-r--r-- 1 gbase gbase 320 1月 13 16:22 REDOLOG.89217
-rw-r--r-- 1 gbase gbase 2172 1月 13 16:23 REDOLOG.89219
drwxr-xr-x 3 gbase gbase 69 1月 13 16:22 SNAPSHOT.45.89216
drwxr-xr-x 3 gbase gbase 69 1月 13 16:22 SNAPSHOT.45.89218
工具使用时注意修改权限: chown -R gbase:gbase gcReplaceIp
[gbase@data1 rePlaceIp_py2]$ cat replaceip.options
installPrefix= /opt
coordinateHost = 192.168.56.175
dataHost = 192.168.56.175
gcwareHost = 192.168.56.175
dbaUser = gbase
dbaGroup = gbase
dbaPwd = 'gbase'
rootPwd = 'root123'
version = V953
#rootPwdFile = rootPwd.json
hostReplaceIpFile = hostReplaceIp.json
[gbase@data1 rePlaceIp_py2]$ cat hostReplaceIp.json
{
"HOSTREPLACEIP":[
{
"OLDIP":"192.168.56.175",
"NEWIP":"192.168.56.176"
}
]
}
在线切换集群为只读状态
[gbase@data1 ~]$ gcadmin switchmode readonly
========== switch cluster mode...
switch pre mode: [NORMAL]
switch mode to [READONLY]
switch after mode: [READONLY]
开始替换IP
[gbase@data1 rePlaceIp_py2]$ python gcReplaceIp.py --silent=replaceip.options
Welcome to use GBase products
hostList: ['192.168.56.175']
cluster version : 9.5.3.27.17
cluster ip version: ipv4
cluster target ip version: ipv4
('hostReplaceIpDict', {'HostReplaceIp': {'192.168.56.175': '192.168.56.176'}})
('hostNodeIdDict:', {'192.168.56.175': 2939726016})
stoping all gcware nodes...
TStopNodeOnV953:192.168.56.175 prefix:/opt
stoping all gcluster nodes...
TStopNodeOnV953:192.168.56.175 prefix:/opt
Refreshing snapshot,please wait...
start all gcware
Connection gcware successfully,get all nodes status end.
check gcware status
threadSnapShotBefore!!!
flush_statemachine!!!
threadSnapShotBack,host:['192.168.56.175']
threadSnapShotBack!!!
stop all gcware!!!
clear gcware sessions successfully.
Refresh snapshot successfully.
modify gcware file on 192.168.56.175 successfully.
run hostlist ['192.168.56.175']
replace cluster node ip successfull, please check and process network all node
Replace cluster node ip Successfully.
然后主机修改ip 此时服务都停了已经,手工拉起即可
最后 gcadmin
- 离线方式(不建议使用)
这里只写差异,其他步骤与上同
主要就是快照比redolog版本号大 , 多刷几次 ,直到一个比另一个大 ,如下 : 89667>89666
[gbase@data1 gcware]$ ll
总用量 16
-rw-r--r-- 1 gbase gbase 48 1月 13 17:41 GCWARE_META.A
-rw-r--r-- 1 gbase gbase 39 1月 13 17:41 GCWARE_META.B
-rw-r--r-- 1 gbase gbase 320 1月 13 17:56 REDOLOG.89664
-rw-r--r-- 1 gbase gbase 480 1月 13 17:56 REDOLOG.89666
drwxr-xr-x 3 gbase gbase 69 1月 13 17:56 SNAPSHOT.51.89665
drwxr-xr-x 3 gbase gbase 69 1月 13 17:56 SNAPSHOT.51.89667
停服 (这是主要区别) :
gcluster_services all stop
gcware_services all stop
此时执行替换(带offline参数),有时会成功(成功时速度会比价快),有时会报错 ,【和集群版本有关系】 。
如这里报错,停服后redolog变大已经变成89669了,因此该方式不建议使用。
[gbase@data1 rePlaceIp_py2]$ python gcReplaceIp.py --silent=replaceip.options --offline
Welcome to use GBase products
hostList: ['192.168.56.177']
cluster version : 9.5.3.27.17
cluster ip version: ipv4
cluster target ip version: ipv4
start get host nodeid under offline cluster...
local node type is composition
confPath: /opt/192.168.56.177/gcware/data/gcware
maxSnapShotVer: 89667, redoLogVersion: 89669
Error: gcReplaceIp.py(line 4690) -- Snapshot max version less than RedoLog Version, REDOLOG must flush first, please flush statemachine again.
原文链接:www.gbase.cn/community/p…
更多精彩内容尽在南大通用GBase技术社区,南大通用致力于成为用户最信赖的数据库产品供应商。