MySQL Router高可用搭建,你学会了吗?( 四 )

  1. 修改pcsd的TCP端口为指定的13314
sed -i '/#PCSD_PORT=2224/aPCSD_PORT=13314' /etc/sysconfig/pcsd重启pcsd服务,让新端口生效
[#23#root@gdb1 ~ 11:23:20]23 systemctl restart pcsd[#24#root@gdb1 ~ 11:23:39]24 systemctl status pcsd● pcsd.service - PCS GUI and remote configuration interfaceLoaded: loaded (/usr/lib/systemd/system/pcsd.service; enabled; vendor preset: disabled)Active: active (running) since 三 2023-02-22 11:23:39 CST; 5s agoDocs: man:pcsd(8)man:pcs(8) Main PID: 30041 (pcsd)Tasks: 4Memory: 27.3MCGroup: /system.slice/pcsd.service└─30041 /usr/bin/ruby /usr/lib/pcsd/pcsd2月 22 11:23:38 gdb1 systemd[1]: Starting PCS GUI and remote configuration interface...2月 22 11:23:39 gdb1 systemd[1]: Started PCS GUI and remote configuration interface.[#25#root@gdb1 ~ 11:23:45]25
  1. 设置集群认证信息,通过操作系统用户hacluster进行认证
 [#27#root@gdb1 ~ 11:31:43]27 cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf[#28#root@gdb1 ~ 11:32:15]28 pcs cluster auth gdb1:13314 gdb2:13314 gdb3:13314 -u hacluster -p 'abc123'gdb1: Authorizedgdb2: Authorizedgdb3: Authorized[#29#root@gdb1 ~ 11:33:18]29
  1. 创建集群,任意节点执行即可
 ## 名称为gdb_ha , udp协议为13315, 掩码为24 ,集群成员为主机gdb1, gdb2, gdb3[#31#root@gdb1 ~ 11:41:48]31 pcs cluster setup --force --name gdb_ha --transport=udp --addr0 24 --mcastport0 13315 gdb1 gdb2 gdb3Destroying cluster on nodes: gdb1, gdb2, gdb3...gdb1: Stopping Cluster (pacemaker)...gdb2: Stopping Cluster (pacemaker)...gdb3: Stopping Cluster (pacemaker)...gdb2: Successfully destroyed clustergdb1: Successfully destroyed clustergdb3: Successfully destroyed clusterSending 'pacemaker_remote authkey' to 'gdb1', 'gdb2', 'gdb3'gdb2: successful distribution of the file 'pacemaker_remote authkey'gdb3: successful distribution of the file 'pacemaker_remote authkey'gdb1: successful distribution of the file 'pacemaker_remote authkey'Sending cluster config files to the nodes...gdb1: Succeededgdb2: Succeededgdb3: SucceededSynchronizing pcsd certificates on nodes gdb1, gdb2, gdb3...gdb1: Successgdb2: Successgdb3: SuccessRestarting pcsd on the nodes in order to reload the certificates...gdb1: Successgdb2: Successgdb3: Success
  1. 确认完整的集群配置,在任意节点查看即可
 [#21#root@gdb2 ~ 11:33:18]21 more /etc/corosync/corosync.conftotem {version: 2cluster_name: gdb_hasecauth: offtransport: udprrp_mode: passiveinterface {ringnumber: 0bin.NETaddr: 24mcastaddr: 239.255.1.1mcastport: 13315}}nodelist {node {ring0_addr: gdb1nodeid: 1}node {ring0_addr: gdb2nodeid: 2}node {ring0_addr: gdb3nodeid: 3}}quorum {provider: corosync_votequorum}logging {to_logfile: yeslogfile: /var/log/cluster/corosync.logto_syslog: yes}[#22#root@gdb2 ~ 14:23:50]22
  1. 启动所有集群节点的pacemaker 相关服务,任意节点执行即可
[#35#root@gdb1 ~ 15:30:51]35 pcs cluster start --allgdb1: Starting Cluster (corosync)...gdb2: Starting Cluster (corosync)...gdb3: Starting Cluster (corosync)...gdb3: Starting Cluster (pacemaker)...gdb1: Starting Cluster (pacemaker)...gdb2: Starting Cluster (pacemaker)...关闭服务时,使用pcs cluster stop --all,或者用pcs cluster stop 《server》关闭某一台
  1. 在每个节点上设置pacemaker相关服务开机自启动
[#35#root@gdb1 ~ 15:30:51]35 systemctl enable pcsd corosync pacemaker[#36#root@gdb1 ~ 15:30:53]36 pcs cluster enable --all
  1. 没有STONITH 设备时,禁用STONITH 组件功能
禁用STONITH 组件功能后,分布式锁管理器DLM等资源以及依赖DLM的所有服务:例如cLVM2,GFS2,OCFS2等都将无法启动,不禁用时会有错误信息
pcs property set stonith-enabled=false完整的命令执行过程如下
[#32#root@gdb1 ~ 15:48:20]32 systemctl status pacemaker● pacemaker.service - Pacemaker High Availability Cluster ManagerLoaded: loaded (/usr/lib/systemd/system/pacemaker.service; disabled; vendor preset: disabled)Active: active (running) since 三 2023-02-22 15:35:48 CST; 1min 54s agoDocs: man:pacemakerdhttps://clusterlabs.org/pacemaker/doc/en-US/Pacemaker/1.1/html-single/Pacemaker_Explained/index.html Main PID: 25661 (pacemakerd)Tasks: 7Memory: 51.1MCGroup: /system.slice/pacemaker.service├─25661 /usr/sbin/pacemakerd -f├─25662 /usr/libexec/pacemaker/cib├─25663 /usr/libexec/pacemaker/stonithd├─25664 /usr/libexec/pacemaker/lrmd├─25665 /usr/libexec/pacemaker/attrd├─25666 /usr/libexec/pacemaker/pengine└─25667 /usr/libexec/pacemaker/crmd2月 22 15:35:52 gdb1 crmd[25667]:notice: Fencer successfully connected2月 22 15:36:11 gdb1 crmd[25667]:notice: State transition S_ELECTION -> S_INTEGRATION2月 22 15:36:12 gdb1 pengine[25666]:error: Resource start-up disabled since no STONITH resources have been defined2月 22 15:36:12 gdb1 pengine[25666]:error: Either configure some or disable STONITH with the stonith-enabled option2月 22 15:36:12 gdb1 pengine[25666]:error: NOTE: Clusters with shared data need STONITH to ensure data integrity2月 22 15:36:12 gdb1 pengine[25666]:notice: Delaying fencing operations until there are resources to manage2月 22 15:36:12 gdb1 pengine[25666]:notice: Calculated transition 0, saving inputs in /var/lib/pacemaker/pengine/pe-input-0.bz22月 22 15:36:12 gdb1 pengine[25666]:notice: Configuration ERRORs found during PE processing.Please run "crm_verify -L" to identify issues.2月 22 15:36:12 gdb1 crmd[25667]:notice: Transition 0 (Complete=0, Pending=0, Fired=0, Skipped=0, Incomplete=0, Source=/var/lib/pacemaker/pengine/pe-input-0.bz2): Complete2月 22 15:36:12 gdb1 crmd[25667]:notice: State transition S_TRANSITION_ENGINE -> S_IDLE[#33#root@gdb1 ~ 15:37:43]33 pcs property set stonith-enabled=false[#34#root@gdb1 ~ 15:48:20]34 systemctl status pacemaker● pacemaker.service - Pacemaker High Availability Cluster ManagerLoaded: loaded (/usr/lib/systemd/system/pacemaker.service; disabled; vendor preset: disabled)Active: active (running) since 三 2023-02-22 15:35:48 CST; 12min agoDocs: man:pacemakerdhttps://clusterlabs.org/pacemaker/doc/en-US/Pacemaker/1.1/html-single/Pacemaker_Explained/index.html Main PID: 25661 (pacemakerd)Tasks: 7Memory: 51.7MCGroup: /system.slice/pacemaker.service├─25661 /usr/sbin/pacemakerd -f├─25662 /usr/libexec/pacemaker/cib├─25663 /usr/libexec/pacemaker/stonithd├─25664 /usr/libexec/pacemaker/lrmd├─25665 /usr/libexec/pacemaker/attrd├─25666 /usr/libexec/pacemaker/pengine└─25667 /usr/libexec/pacemaker/crmd2月 22 15:36:12 gdb1 pengine[25666]:notice: Calculated transition 0, saving inputs in /var/lib/pacemaker/pengine/pe-input-0.bz22月 22 15:36:12 gdb1 pengine[25666]:notice: Configuration ERRORs found during PE processing.Please run "crm_verify -L" to identify issues.2月 22 15:36:12 gdb1 crmd[25667]:notice: Transition 0 (Complete=0, Pending=0, Fired=0, Skipped=0, Incomplete=0, Source=/var/lib/pacemaker/pengine/pe-input-0.bz2): Complete2月 22 15:36:12 gdb1 crmd[25667]:notice: State transition S_TRANSITION_ENGINE -> S_IDLE2月 22 15:48:20 gdb1 crmd[25667]:notice: State transition S_IDLE -> S_POLICY_ENGINE2月 22 15:48:21 gdb1 pengine[25666]:warning: Blind faith: not fencing unseen nodes2月 22 15:48:21 gdb1 pengine[25666]:notice: Delaying fencing operations until there are resources to manage2月 22 15:48:21 gdb1 pengine[25666]:notice: Calculated transition 1, saving inputs in /var/lib/pacemaker/pengine/pe-input-1.bz22月 22 15:48:21 gdb1 crmd[25667]:notice: Transition 1 (Complete=0, Pending=0, Fired=0, Skipped=0, Incomplete=0, Source=/var/lib/pacemaker/pengine/pe-input-1.bz2): Complete2月 22 15:48:21 gdb1 crmd[25667]:notice: State transition S_TRANSITION_ENGINE -> S_IDLE[#35#root@gdb1 ~ 15:48:31]35


推荐阅读