Linux High Available:Corosync + Pacemaker
说明:
Corosync:实现HA的心跳信息传输;
Pacemaker:开源的高可用资源管理器(CRM)
环境说明:
节点一:192.168.126.133
节点二:192.168.126.134
文件【/etc/hosts】
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[root@mysql1 ~]# cat /etc/hosts #127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 #::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 # Local 127.0.0.1 localhost localhost.localdomain # Public 192.168.126.133 mysql1 192.168.126.134 mysql2 # Finished [root@mysql1 ~]# |
集群节点之间的【SSH互信】:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
[root@mysql1 ~]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:WnTaHoqqoMaL5vxoyrWSw8aW88aYuGj2ixQ5bvrqL2k root@mysql1 The key's randomart image is: +---[RSA 2048]----+ | | | | | . . | | . . + | | + S o | |. o + o . | |*+B. o . . | |@E+o.. | |^%#Oo | +----[SHA256]-----+ [root@mysql1 ~]# [root@mysql1 ~]# ssh-copy-id -i .ssh/id_rsa.pub mysql2 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: ".ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@mysql2's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'mysql2'" and check to make sure that only the key(s) you wanted were added. [root@mysql1 ~]# [root@mysql1 ~]# ssh mysql2 date Sun Aug 9 15:22:11 CST 2020 [root@mysql1 ~]# |
可以看到,这样就配置好了;
如上的配置两个节点都需要配置SSH互信。
时间服务:
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@mysql1 ~]# vmware-toolbox-cmd timesync status Disabled [root@mysql1 ~]# vmware-toolbox-cmd timesync enable Enabled [root@mysql1 ~]# vmware-toolbox-cmd timesync status Enabled [root@mysql1 ~]# [root@mysql1 ~]# hwclock -s [root@mysql1 ~]# [root@mysql1 ~]# date Sun Aug 9 15:29:36 CST 2020 [root@mysql1 ~]# |
软件包安装:
1. corosync
2. pacemaker
3. crmsh
4. pssh
————————
其中【corosync】可以从这里下载:
https://corosync.github.io/corosync/
https://clusterlabs.org/corosync.html
其中【pacemaker】可以从这里下载:
https://clusterlabs.org/pacemaker/
其中【crmsh】与【pssh】的下载介质可以从以下两个地址获取:
1. http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-7/x86_64/
2. http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/RedHat_RHEL-7/noarch/
【crmsh】
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
[root@mysql1 ~]# mkdir /software [root@mysql1 ~]# [root@mysql1 ~]# ls -ltr /software/ total 9796 -rw-r--r-- 1 root root 1095396 Aug 8 14:19 corosync-3.0.4.tar.gz -rw-r--r-- 1 root root 7938363 Aug 8 14:28 pacemaker-Pacemaker-1.1.23.zip -rw-r--r-- 1 root root 12464 Aug 8 19:30 drbd-formula-0.2.0-1.1.noarch.rpm -rw-r--r-- 1 root root 763680 Aug 8 19:47 crmsh-3.0.0-6.1.noarch.rpm -rw-r--r-- 1 root root 95468 Aug 8 19:49 crmsh-scripts-3.0.0-6.1.noarch.rpm -rw-r--r-- 1 root root 36748 Aug 8 19:49 python-parallax-1.0.1-29.1.noarch.rpm -rw-r--r-- 1 root root 43284 Aug 8 19:49 python-pssh-2.3.1-7.1.noarch.rpm -rw-r--r-- 1 root root 27336 Aug 8 19:53 pssh-2.3.1-7.1.noarch.rpm [root@mysql1 ~]# [root@mysql1 ~]# rpm -ivh /software/crmsh-scripts-3.0.0-6.1.noarch.rpm warning: /software/crmsh-scripts-3.0.0-6.1.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 17280ddf: NOKEY Preparing... ################################# [100%] Updating / installing... 1:crmsh-scripts-3.0.0-6.1 ################################# [100%] [root@mysql1 ~]# [root@mysql1 ~]# rpm -ivh /software/python-parallax-1.0.1-29.1.noarch.rpm warning: /software/python-parallax-1.0.1-29.1.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 17280ddf: NOKEY Preparing... ################################# [100%] Updating / installing... 1:python-parallax-1.0.1-29.1 ################################# [100%] [root@mysql1 ~]# [root@mysql1 ~]# rpm -ivh /software/crmsh-3.0.0-6.1.noarch.rpm warning: /software/crmsh-3.0.0-6.1.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 17280ddf: NOKEY Preparing... ################################# [100%] Updating / installing... 1:crmsh-3.0.0-6.1 warning: user hacluster does not exist - using root warning: group haclient does not exist - using root ################################# [100%] [root@mysql1 ~]# |
【pssh】
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@mysql1 ~]# rpm -ivh /software/python-pssh-2.3.1-7.1.noarch.rpm warning: /software/python-pssh-2.3.1-7.1.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 17280ddf: NOKEY Preparing... ################################# [100%] Updating / installing... 1:python-pssh-2.3.1-7.1 ################################# [100%] [root@mysql1 ~]# [root@mysql1 ~]# rpm -ivh /software/pssh-2.3.1-7.1.noarch.rpm warning: /software/pssh-2.3.1-7.1.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 17280ddf: NOKEY Preparing... ################################# [100%] Updating / installing... 1:pssh-2.3.1-7.1 ################################# [100%] [root@mysql1 ~]# |
【corosync】
配置好YUM后,通过YUM安装
【pacemaker】
配置好YUM后,通过YUM安装
配置YUM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
[root@mysql1 ~]# vi /etc/yum.repos.d/tsinghua.repo [root@mysql1 ~]# [root@mysql1 ~]# vi /etc/yum.repos.d/epel.repo [root@mysql1 ~]# [root@mysql1 ~]# sed -i 's/\$releasever/7/g' /etc/yum.repos.d/*.repo [root@mysql1 ~]# sed -i '/gpgcheck/s/1/0/g' /etc/yum.repos.d/*.repo [root@mysql1 ~]# [root@mysql1 ~]# scp /etc/yum.repos.d/* mysql2:/etc/yum.repos.d/ epel.repo 100% 954 446.1KB/s 00:00 redhat.repo 100% 358 209.0KB/s 00:00 tsinghua.repo 100% 1546 941.6KB/s 00:00 [root@mysql1 ~]# [root@mysql1 ~]# yum repolist Loaded plugins: product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. base | 3.6 kB 00:00 epel | 4.7 kB 00:00 extras | 2.9 kB 00:00 updates | 2.9 kB 00:00 (1/7): base/x86_64/group_gz | 153 kB 00:00 (2/7): epel/x86_64/group_gz | 95 kB 00:00 (3/7): epel/x86_64/updateinfo | 1.0 MB 00:00 (4/7): base/x86_64/primary_db | 6.1 MB 00:01 (5/7): extras/x86_64/primary_db | 206 kB 00:00 (6/7): updates/x86_64/primary_db | 3.8 MB 00:01 (7/7): epel/x86_64/primary_db | 6.9 MB 00:02 repo id repo name status base/x86_64 CentOS-7 - Base 10,070 epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,425 extras/x86_64 CentOS-7 - Extras 413 updates/x86_64 CentOS-7 - Updates 1,112 repolist: 25,020 [root@mysql1 ~]# [root@mysql1 ~]# cat /etc/yum.conf | grep keepcache keepcache=1 [root@mysql1 ~]# |
根据corosync与pacemaker的官方文档,可以通过yum安装这两个软件包:
https://wiki.clusterlabs.org/wiki/Main_Page

通过YUM安装软件包:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
[root@mysql1 ~]# yum list | grep -E "corosync|pacemaker|createrepo" corosync.x86_64 2.4.5-4.el7 base corosync-qdevice.x86_64 2.4.5-4.el7 base corosync-qnetd.x86_64 2.4.5-4.el7 base corosynclib.i686 2.4.5-4.el7 base corosynclib.x86_64 2.4.5-4.el7 base corosynclib-devel.i686 2.4.5-4.el7 base corosynclib-devel.x86_64 2.4.5-4.el7 base createrepo.noarch 0.9.9-28.el7 base createrepo_c.x86_64 0.10.0-20.el7 extras createrepo_c-devel.x86_64 0.10.0-20.el7 extras createrepo_c-libs.x86_64 0.10.0-20.el7 extras drbd-pacemaker.x86_64 9.13.1-1.el7 epel pacemaker.x86_64 1.1.21-4.el7 base pacemaker-cli.x86_64 1.1.21-4.el7 base pacemaker-cluster-libs.i686 1.1.21-4.el7 base pacemaker-cluster-libs.x86_64 1.1.21-4.el7 base pacemaker-cts.x86_64 1.1.21-4.el7 base pacemaker-doc.x86_64 1.1.21-4.el7 base pacemaker-libs.i686 1.1.21-4.el7 base pacemaker-libs.x86_64 1.1.21-4.el7 base pacemaker-libs-devel.i686 1.1.21-4.el7 base pacemaker-libs-devel.x86_64 1.1.21-4.el7 base pacemaker-nagios-plugins-metadata.x86_64 1.1.21-4.el7 base pacemaker-remote.x86_64 1.1.21-4.el7 base python2-createrepo_c.x86_64 0.10.0-20.el7 extras [root@mysql1 ~]# [root@mysql1 ~]# yum install -y corosync pacemaker createrepo 过多的输出,... --> Processing Dependency: python-tdb(x86-64) >= 1.3.18 for package: pyldb-1.5.4-1.el7.x86_64 ---> Package pytalloc.x86_64 0:2.1.16-1.el7 will be installed --> Running transaction check ---> Package python-tdb.x86_64 0:1.3.18-1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: corosync x86_64 2.4.5-4.el7 base 221 k createrepo noarch 0.9.9-28.el7 base 94 k pacemaker x86_64 1.1.21-4.el7 base 478 k Installing for dependencies: bc x86_64 1.06.95-13.el7 base 115 k cifs-utils x86_64 6.2-10.el7 base 85 k corosynclib x86_64 2.4.5-4.el7 base 136 k cups-libs x86_64 1:1.6.3-43.el7 base 358 k deltarpm x86_64 3.6-3.el7 base 82 k gssproxy x86_64 0.7.0-28.el7 base 110 k keyutils x86_64 1.5.8-3.el7 base 54 k libbasicobjects x86_64 0.1.1-32.el7 base 26 k libcgroup x86_64 0.41-21.el7 base 66 k libcollection x86_64 0.7.0-32.el7 base 42 k libevent x86_64 2.0.21-4.el7 base 214 k libini_config x86_64 1.3.1-32.el7 base 64 k libldb x86_64 1.5.4-1.el7 base 149 k libnfsidmap x86_64 0.25-19.el7 base 50 k libpath_utils x86_64 0.2.1-32.el7 base 28 k libqb x86_64 1.0.1-9.el7 base 96 k libref_array x86_64 0.1.5-32.el7 base 27 k libtalloc x86_64 2.1.16-1.el7 base 33 k libtdb x86_64 1.3.18-1.el7 base 49 k libtevent x86_64 0.9.39-1.el7 base 41 k libtirpc x86_64 0.2.4-0.16.el7 base 89 k libverto-libevent x86_64 0.2.5-4.el7 base 8.9 k libwbclient x86_64 4.10.4-11.el7_8 updates 113 k net-snmp-libs x86_64 1:5.7.2-48.el7_8.1 updates 751 k net-tools x86_64 2.0-0.25.20131004git.el7 base 306 k nfs-utils x86_64 1:1.3.0-0.66.el7_8 updates 412 k pacemaker-cli x86_64 1.1.21-4.el7 base 362 k pacemaker-cluster-libs x86_64 1.1.21-4.el7 base 163 k pacemaker-libs x86_64 1.1.21-4.el7 base 637 k perl-TimeDate noarch 1:2.30-2.el7 base 52 k psmisc x86_64 22.20-16.el7 base 141 k pyldb x86_64 1.5.4-1.el7 base 49 k pytalloc x86_64 2.1.16-1.el7 base 18 k python-deltarpm x86_64 3.6-3.el7 base 31 k python-tdb x86_64 1.3.18-1.el7 base 20 k quota x86_64 1:4.01-19.el7 base 179 k quota-nls noarch 1:4.01-19.el7 base 90 k resource-agents x86_64 4.1.1-46.el7_8.2 updates 455 k rpcbind x86_64 0.2.0-49.el7 base 60 k samba-client-libs x86_64 4.10.4-11.el7_8 updates 5.0 M samba-common noarch 4.10.4-11.el7_8 updates 212 k samba-common-libs x86_64 4.10.4-11.el7_8 updates 176 k samba-libs x86_64 4.10.4-11.el7_8 updates 271 k tcp_wrappers x86_64 7.6-77.el7 base 78 k Transaction Summary ================================================================================ Install 3 Packages (+44 Dependent packages) Total download size: 12 M Installed size: 38 M Downloading packages: (1/47): bc-1.06.95-13.el7.x86_64.rpm | 115 kB 00:05 (2/47): corosync-2.4.5-4.el7.x86_64.rpm | 221 kB 00:00 (3/47): corosynclib-2.4.5-4.el7.x86_64.rpm | 136 kB 00:00 (4/47): createrepo-0.9.9-28.el7.noarch.rpm | 94 kB 00:00 (5/47): cups-libs-1.6.3-43.el7.x86_64.rpm | 358 kB 00:00 (6/47): deltarpm-3.6-3.el7.x86_64.rpm | 82 kB 00:00 (7/47): gssproxy-0.7.0-28.el7.x86_64.rpm | 110 kB 00:00 (8/47): keyutils-1.5.8-3.el7.x86_64.rpm | 54 kB 00:00 (9/47): libbasicobjects-0.1.1-32.el7.x86_64.rpm | 26 kB 00:00 (10/47): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00 (11/47): libcollection-0.7.0-32.el7.x86_64.rpm | 42 kB 00:00 (12/47): libevent-2.0.21-4.el7.x86_64.rpm | 214 kB 00:00 (13/47): libini_config-1.3.1-32.el7.x86_64.rpm | 64 kB 00:00 (14/47): libldb-1.5.4-1.el7.x86_64.rpm | 149 kB 00:00 (15/47): libnfsidmap-0.25-19.el7.x86_64.rpm | 50 kB 00:00 (16/47): libpath_utils-0.2.1-32.el7.x86_64.rpm | 28 kB 00:00 (17/47): libqb-1.0.1-9.el7.x86_64.rpm | 96 kB 00:00 (18/47): libref_array-0.1.5-32.el7.x86_64.rpm | 27 kB 00:00 (19/47): libtalloc-2.1.16-1.el7.x86_64.rpm | 33 kB 00:00 (20/47): libtdb-1.3.18-1.el7.x86_64.rpm | 49 kB 00:00 (21/47): libtevent-0.9.39-1.el7.x86_64.rpm | 41 kB 00:00 (22/47): libtirpc-0.2.4-0.16.el7.x86_64.rpm | 89 kB 00:00 (23/47): libverto-libevent-0.2.5-4.el7.x86_64.rpm | 8.9 kB 00:00 (24/47): net-tools-2.0-0.25.20131004git.el7.x86_64.rpm | 306 kB 00:00 (25/47): libwbclient-4.10.4-11.el7_8.x86_64.rpm | 113 kB 00:00 (26/47): net-snmp-libs-5.7.2-48.el7_8.1.x86_64.rpm | 751 kB 00:00 (27/47): nfs-utils-1.3.0-0.66.el7_8.x86_64.rpm | 412 kB 00:00 (28/47): pacemaker-1.1.21-4.el7.x86_64.rpm | 478 kB 00:00 (29/47): pacemaker-cli-1.1.21-4.el7.x86_64.rpm | 362 kB 00:00 (30/47): pacemaker-cluster-libs-1.1.21-4.el7.x86_64.rpm | 163 kB 00:00 (31/47): pacemaker-libs-1.1.21-4.el7.x86_64.rpm | 637 kB 00:00 (32/47): perl-TimeDate-2.30-2.el7.noarch.rpm | 52 kB 00:00 (33/47): psmisc-22.20-16.el7.x86_64.rpm | 141 kB 00:00 (34/47): pyldb-1.5.4-1.el7.x86_64.rpm | 49 kB 00:00 (35/47): pytalloc-2.1.16-1.el7.x86_64.rpm | 18 kB 00:00 (36/47): python-deltarpm-3.6-3.el7.x86_64.rpm | 31 kB 00:00 (37/47): python-tdb-1.3.18-1.el7.x86_64.rpm | 20 kB 00:00 (38/47): quota-4.01-19.el7.x86_64.rpm | 179 kB 00:00 (39/47): quota-nls-4.01-19.el7.noarch.rpm | 90 kB 00:00 (40/47): rpcbind-0.2.0-49.el7.x86_64.rpm | 60 kB 00:00 (41/47): resource-agents-4.1.1-46.el7_8.2.x86_64.rpm | 455 kB 00:00 (42/47): samba-common-4.10.4-11.el7_8.noarch.rpm | 212 kB 00:00 (43/47): samba-common-libs-4.10.4-11.el7_8.x86_64.rpm | 176 kB 00:00 (44/47): samba-libs-4.10.4-11.el7_8.x86_64.rpm | 271 kB 00:00 (45/47): samba-client-libs-4.10.4-11.el7_8.x86_64.rpm | 5.0 MB 00:01 (46/47): tcp_wrappers-7.6-77.el7.x86_64.rpm | 78 kB 00:00 cifs-utils-6.2-10.el7.x86_64.r FAILED https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/cifs-utils-6.2-10.el7.x86_64.rpm: [Errno 14] curl#7 - "Failed to connect to 2402:f000:1:408:8100::1: Network is unreachable" Trying other mirror. (47/47): cifs-utils-6.2-10.el7.x86_64.rpm | 85 kB 00:00 -------------------------------------------------------------------------------- Total 802 kB/s | 12 MB 00:15 Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum. Installing : libtalloc-2.1.16-1.el7.x86_64 1/47 Installing : libqb-1.0.1-9.el7.x86_64 2/47 Installing : libtdb-1.3.18-1.el7.x86_64 3/47 Installing : libtevent-0.9.39-1.el7.x86_64 4/47 Installing : libldb-1.5.4-1.el7.x86_64 5/47 Installing : 1:cups-libs-1.6.3-43.el7.x86_64 6/47 Installing : libevent-2.0.21-4.el7.x86_64 7/47 Installing : keyutils-1.5.8-3.el7.x86_64 8/47 Installing : samba-common-4.10.4-11.el7_8.noarch 9/47 Installing : libref_array-0.1.5-32.el7.x86_64 10/47 Installing : deltarpm-3.6-3.el7.x86_64 11/47 Installing : libcollection-0.7.0-32.el7.x86_64 12/47 Installing : libbasicobjects-0.1.1-32.el7.x86_64 13/47 Installing : libtirpc-0.2.4-0.16.el7.x86_64 14/47 Installing : rpcbind-0.2.0-49.el7.x86_64 15/47 Installing : python-deltarpm-3.6-3.el7.x86_64 16/47 Installing : libverto-libevent-0.2.5-4.el7.x86_64 17/47 Installing : python-tdb-1.3.18-1.el7.x86_64 18/47 Installing : pyldb-1.5.4-1.el7.x86_64 19/47 Installing : pytalloc-2.1.16-1.el7.x86_64 20/47 Installing : libwbclient-4.10.4-11.el7_8.x86_64 21/47 Installing : samba-libs-4.10.4-11.el7_8.x86_64 22/47 Installing : samba-common-libs-4.10.4-11.el7_8.x86_64 23/47 Installing : samba-client-libs-4.10.4-11.el7_8.x86_64 24/47 Installing : cifs-utils-6.2-10.el7.x86_64 25/47 Installing : libcgroup-0.41-21.el7.x86_64 26/47 Installing : 1:quota-nls-4.01-19.el7.noarch 27/47 Installing : tcp_wrappers-7.6-77.el7.x86_64 28/47 Installing : 1:quota-4.01-19.el7.x86_64 29/47 Installing : 1:perl-TimeDate-2.30-2.el7.noarch 30/47 Installing : libnfsidmap-0.25-19.el7.x86_64 31/47 Installing : libpath_utils-0.2.1-32.el7.x86_64 32/47 Installing : libini_config-1.3.1-32.el7.x86_64 33/47 Installing : gssproxy-0.7.0-28.el7.x86_64 34/47 Installing : 1:nfs-utils-1.3.0-0.66.el7_8.x86_64 35/47 Installing : 1:net-snmp-libs-5.7.2-48.el7_8.1.x86_64 36/47 Installing : corosynclib-2.4.5-4.el7.x86_64 37/47 Installing : corosync-2.4.5-4.el7.x86_64 38/47 Installing : pacemaker-libs-1.1.21-4.el7.x86_64 39/47 Installing : pacemaker-cli-1.1.21-4.el7.x86_64 40/47 Installing : pacemaker-cluster-libs-1.1.21-4.el7.x86_64 41/47 Installing : psmisc-22.20-16.el7.x86_64 42/47 Installing : net-tools-2.0-0.25.20131004git.el7.x86_64 43/47 Installing : bc-1.06.95-13.el7.x86_64 44/47 Installing : resource-agents-4.1.1-46.el7_8.2.x86_64 45/47 Installing : pacemaker-1.1.21-4.el7.x86_64 46/47 Installing : createrepo-0.9.9-28.el7.noarch 47/47 Verifying : libtirpc-0.2.4-0.16.el7.x86_64 1/47 Verifying : pacemaker-libs-1.1.21-4.el7.x86_64 2/47 Verifying : samba-client-libs-4.10.4-11.el7_8.x86_64 3/47 Verifying : libldb-1.5.4-1.el7.x86_64 4/47 Verifying : libtevent-0.9.39-1.el7.x86_64 5/47 Verifying : 1:cups-libs-1.6.3-43.el7.x86_64 6/47 Verifying : pacemaker-1.1.21-4.el7.x86_64 7/47 Verifying : libtdb-1.3.18-1.el7.x86_64 8/47 Verifying : resource-agents-4.1.1-46.el7_8.2.x86_64 9/47 Verifying : gssproxy-0.7.0-28.el7.x86_64 10/47 Verifying : libbasicobjects-0.1.1-32.el7.x86_64 11/47 Verifying : pyldb-1.5.4-1.el7.x86_64 12/47 Verifying : bc-1.06.95-13.el7.x86_64 13/47 Verifying : libwbclient-4.10.4-11.el7_8.x86_64 14/47 Verifying : net-tools-2.0-0.25.20131004git.el7.x86_64 15/47 Verifying : python-tdb-1.3.18-1.el7.x86_64 16/47 Verifying : rpcbind-0.2.0-49.el7.x86_64 17/47 Verifying : pytalloc-2.1.16-1.el7.x86_64 18/47 Verifying : libini_config-1.3.1-32.el7.x86_64 19/47 Verifying : psmisc-22.20-16.el7.x86_64 20/47 Verifying : 1:net-snmp-libs-5.7.2-48.el7_8.1.x86_64 21/47 Verifying : pacemaker-cli-1.1.21-4.el7.x86_64 22/47 Verifying : libpath_utils-0.2.1-32.el7.x86_64 23/47 Verifying : libqb-1.0.1-9.el7.x86_64 24/47 Verifying : corosynclib-2.4.5-4.el7.x86_64 25/47 Verifying : libtalloc-2.1.16-1.el7.x86_64 26/47 Verifying : cifs-utils-6.2-10.el7.x86_64 27/47 Verifying : createrepo-0.9.9-28.el7.noarch 28/47 Verifying : libcollection-0.7.0-32.el7.x86_64 29/47 Verifying : pacemaker-cluster-libs-1.1.21-4.el7.x86_64 30/47 Verifying : deltarpm-3.6-3.el7.x86_64 31/47 Verifying : libref_array-0.1.5-32.el7.x86_64 32/47 Verifying : samba-common-4.10.4-11.el7_8.noarch 33/47 Verifying : samba-libs-4.10.4-11.el7_8.x86_64 34/47 Verifying : libverto-libevent-0.2.5-4.el7.x86_64 35/47 Verifying : 1:quota-4.01-19.el7.x86_64 36/47 Verifying : python-deltarpm-3.6-3.el7.x86_64 37/47 Verifying : libnfsidmap-0.25-19.el7.x86_64 38/47 Verifying : 1:perl-TimeDate-2.30-2.el7.noarch 39/47 Verifying : keyutils-1.5.8-3.el7.x86_64 40/47 Verifying : corosync-2.4.5-4.el7.x86_64 41/47 Verifying : tcp_wrappers-7.6-77.el7.x86_64 42/47 Verifying : libevent-2.0.21-4.el7.x86_64 43/47 Verifying : samba-common-libs-4.10.4-11.el7_8.x86_64 44/47 Verifying : 1:nfs-utils-1.3.0-0.66.el7_8.x86_64 45/47 Verifying : 1:quota-nls-4.01-19.el7.noarch 46/47 Verifying : libcgroup-0.41-21.el7.x86_64 47/47 Installed: corosync.x86_64 0:2.4.5-4.el7 createrepo.noarch 0:0.9.9-28.el7 pacemaker.x86_64 0:1.1.21-4.el7 Dependency Installed: bc.x86_64 0:1.06.95-13.el7 cifs-utils.x86_64 0:6.2-10.el7 corosynclib.x86_64 0:2.4.5-4.el7 cups-libs.x86_64 1:1.6.3-43.el7 deltarpm.x86_64 0:3.6-3.el7 gssproxy.x86_64 0:0.7.0-28.el7 keyutils.x86_64 0:1.5.8-3.el7 libbasicobjects.x86_64 0:0.1.1-32.el7 libcgroup.x86_64 0:0.41-21.el7 libcollection.x86_64 0:0.7.0-32.el7 libevent.x86_64 0:2.0.21-4.el7 libini_config.x86_64 0:1.3.1-32.el7 libldb.x86_64 0:1.5.4-1.el7 libnfsidmap.x86_64 0:0.25-19.el7 libpath_utils.x86_64 0:0.2.1-32.el7 libqb.x86_64 0:1.0.1-9.el7 libref_array.x86_64 0:0.1.5-32.el7 libtalloc.x86_64 0:2.1.16-1.el7 libtdb.x86_64 0:1.3.18-1.el7 libtevent.x86_64 0:0.9.39-1.el7 libtirpc.x86_64 0:0.2.4-0.16.el7 libverto-libevent.x86_64 0:0.2.5-4.el7 libwbclient.x86_64 0:4.10.4-11.el7_8 net-snmp-libs.x86_64 1:5.7.2-48.el7_8.1 net-tools.x86_64 0:2.0-0.25.20131004git.el7 nfs-utils.x86_64 1:1.3.0-0.66.el7_8 pacemaker-cli.x86_64 0:1.1.21-4.el7 pacemaker-cluster-libs.x86_64 0:1.1.21-4.el7 pacemaker-libs.x86_64 0:1.1.21-4.el7 perl-TimeDate.noarch 1:2.30-2.el7 psmisc.x86_64 0:22.20-16.el7 pyldb.x86_64 0:1.5.4-1.el7 pytalloc.x86_64 0:2.1.16-1.el7 python-deltarpm.x86_64 0:3.6-3.el7 python-tdb.x86_64 0:1.3.18-1.el7 quota.x86_64 1:4.01-19.el7 quota-nls.noarch 1:4.01-19.el7 resource-agents.x86_64 0:4.1.1-46.el7_8.2 rpcbind.x86_64 0:0.2.0-49.el7 samba-client-libs.x86_64 0:4.10.4-11.el7_8 samba-common.noarch 0:4.10.4-11.el7_8 samba-common-libs.x86_64 0:4.10.4-11.el7_8 samba-libs.x86_64 0:4.10.4-11.el7_8 tcp_wrappers.x86_64 0:7.6-77.el7 Complete! [root@mysql1 ~]# |
这样,就安装好了。
配置:corosync
配置文件目录:/etc/corosync
配置文件:corosync.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
[root@mysql1 ~]# cd /etc/corosync/ [root@mysql1 corosync]# [root@mysql1 corosync]# ls -ltr total 12 -rw-r--r-- 1 root root 3278 Apr 2 21:28 corosync.xml.example -rw-r--r-- 1 root root 767 Apr 2 21:28 corosync.conf.example.udpu -rw-r--r-- 1 root root 2881 Apr 2 21:28 corosync.conf.example drwxr-xr-x 2 root root 6 Apr 2 21:28 uidgid.d [root@mysql1 corosync]# [root@mysql1 corosync]# cp corosync.conf.example corosync.conf [root@mysql1 corosync]# [root@mysql1 corosync]# ls -ltr total 16 -rw-r--r-- 1 root root 3278 Apr 2 21:28 corosync.xml.example -rw-r--r-- 1 root root 767 Apr 2 21:28 corosync.conf.example.udpu -rw-r--r-- 1 root root 2881 Apr 2 21:28 corosync.conf.example drwxr-xr-x 2 root root 6 Apr 2 21:28 uidgid.d -rw-r--r-- 1 root root 2881 Aug 9 16:15 corosync.conf [root@mysql1 corosync]# [root@mysql1 corosync]# cat corosync.conf # Please read the corosync.conf.5 manual page totem { version: 2 # crypto_cipher and crypto_hash: Used for mutual node authentication. # If you choose to enable this, then do remember to create a shared # secret with "corosync-keygen". # enabling crypto_cipher, requires also enabling of crypto_hash. crypto_cipher: none crypto_hash: none # interface: define at least one interface to communicate # over. If you define more than one interface stanza, you must # also set rrp_mode. interface { # Rings must be consecutively numbered, starting at 0. ringnumber: 0 # This is normally the *network* address of the # interface to bind to. This ensures that you can use # identical instances of this configuration file # across all your cluster nodes, without having to # modify this option. #bindnetaddr: 192.168.1.0 bindnetaddr: 192.168.126.0 # However, if you have multiple physical network # interfaces configured for the same subnet, then the # network address alone is not sufficient to identify # the interface Corosync should bind to. In that case, # configure the *host* address of the interface # instead: # bindnetaddr: 192.168.1.1 # When selecting a multicast address, consider RFC # 2365 (which, among other things, specifies that # 239.255.x.x addresses are left to the discretion of # the network administrator). Do not reuse multicast # addresses across multiple Corosync clusters sharing # the same network. mcastaddr: 239.255.1.1 # Corosync uses the port you specify here for UDP # messaging, and also the immediately preceding # port. Thus if you set this to 5405, Corosync sends # messages over UDP ports 5405 and 5404. mcastport: 5405 # Time-to-live for cluster communication packets. The # number of hops (routers) that this ring will allow # itself to pass. Note that multicast routing must be # specifically enabled on most network routers. ttl: 1 } } logging { # Log the source file and line where messages are being # generated. When in doubt, leave off. Potentially useful for # debugging. fileline: off # Log to standard error. When in doubt, set to no. Useful when # running in the foreground (when invoking "corosync -f") to_stderr: no # Log to a log file. When set to "no", the "logfile" option # must not be set. to_logfile: yes logfile: /var/log/cluster/corosync.log # Log to the system log daemon. When in doubt, set to yes. to_syslog: yes # Log debug messages (very verbose). When in doubt, leave off. debug: off # Log messages with time stamps. When in doubt, set to on # (unless you are only logging to syslog, where double # timestamps can be annoying). timestamp: on logger_subsys { subsys: QUORUM debug: off } } quorum { # Enable and configure quorum subsystem (default: off) # see also corosync.conf.5 and votequorum.5 #provider: corosync_votequorum } service { var: 0 name: pacemaker } [root@mysql1 corosync]# |
创建corosync authkey:
1 2 3 4 5 6 7 8 9 |
[root@mysql1 corosync]# mv /dev/{random,random.bak} [root@mysql1 corosync]# ln -s /dev/urandom /dev/random [root@mysql1 corosync]# [root@mysql1 corosync]# corosync-keygen Corosync Cluster Engine Authentication key generator. Gathering 1024 bits for key from /dev/random. Press keys on your keyboard to generate entropy. Writing corosync key to /etc/corosync/authkey. [root@mysql1 corosync]# |
将生成的authkey与corosync的配置文件传到另一节点:
1 2 3 4 |
[root@mysql1 corosync]# scp {corosync.conf,authkey} mysql2:/etc/corosync/ corosync.conf 100% 2949 1.2MB/s 00:00 authkey 100% 128 93.1KB/s 00:00 [root@mysql1 corosync]# |
安装集群管理工具:pcs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
[root@mysql1 corosync]# yum install pcs Loaded plugins: product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. Resolving Dependencies --> Running transaction check ---> Package pcs.x86_64 0:0.9.168-4.el7.centos will be installed --> Processing Dependency: ruby >= 2.0.0 for package: pcs-0.9.168-4.el7.centos.x86_64 --> Processing Dependency: python-clufter >= 0.59.0 for package: pcs-0.9.168-4.el7.centos.x86_64 --> Processing Dependency: rubygem-json for package: pcs-0.9.168-4.el7.centos.x86_64 --> Processing Dependency: overpass-fonts for package: pcs-0.9.168-4.el7.centos.x86_64 --> Processing Dependency: liberation-sans-fonts for package: pcs-0.9.168-4.el7.centos.x86_64 --> Processing Dependency: /usr/bin/ruby for package: pcs-0.9.168-4.el7.centos.x86_64 --> Processing Dependency: libruby.so.2.0()(64bit) for package: pcs-0.9.168-4.el7.centos.x86_64 --> Running transaction check ---> Package liberation-sans-fonts.noarch 1:1.07.2-16.el7 will be installed --> Processing Dependency: liberation-fonts-common = 1:1.07.2-16.el7 for package: 1:liberation-sans-fonts-1.07.2-16.el7.noarch ---> Package overpass-fonts.noarch 0:2.1-1.el7 will be installed --> Processing Dependency: fontpackages-filesystem for package: overpass-fonts-2.1-1.el7.noarch ---> Package python-clufter.noarch 0:0.77.1-1.el7 will be installed --> Processing Dependency: clufter-bin = 0.77.1-1.el7 for package: python-clufter-0.77.1-1.el7.noarch ---> Package ruby.x86_64 0:2.0.0.648-36.el7 will be installed --> Processing Dependency: rubygem(bigdecimal) >= 1.2.0 for package: ruby-2.0.0.648-36.el7.x86_64 --> Processing Dependency: ruby(rubygems) >= 2.0.14.1 for package: ruby-2.0.0.648-36.el7.x86_64 ---> Package ruby-libs.x86_64 0:2.0.0.648-36.el7 will be installed ---> Package rubygem-json.x86_64 0:1.7.7-36.el7 will be installed --> Running transaction check ---> Package clufter-bin.x86_64 0:0.77.1-1.el7 will be installed --> Processing Dependency: clufter-common = 0.77.1-1.el7 for package: clufter-bin-0.77.1-1.el7.x86_64 ---> Package fontpackages-filesystem.noarch 0:1.44-8.el7 will be installed ---> Package liberation-fonts-common.noarch 1:1.07.2-16.el7 will be installed ---> Package rubygem-bigdecimal.x86_64 0:1.2.0-36.el7 will be installed ---> Package rubygems.noarch 0:2.0.14.1-36.el7 will be installed --> Processing Dependency: rubygem(rdoc) >= 4.0.0 for package: rubygems-2.0.14.1-36.el7.noarch --> Processing Dependency: rubygem(psych) >= 2.0.0 for package: rubygems-2.0.14.1-36.el7.noarch --> Processing Dependency: rubygem(io-console) >= 0.4.2 for package: rubygems-2.0.14.1-36.el7.noarch --> Running transaction check ---> Package clufter-common.noarch 0:0.77.1-1.el7 will be installed ---> Package rubygem-io-console.x86_64 0:0.4.2-36.el7 will be installed ---> Package rubygem-psych.x86_64 0:2.0.0-36.el7 will be installed --> Processing Dependency: libyaml-0.so.2()(64bit) for package: rubygem-psych-2.0.0-36.el7.x86_64 ---> Package rubygem-rdoc.noarch 0:4.0.0-36.el7 will be installed --> Processing Dependency: ruby(irb) = 2.0.0.648 for package: rubygem-rdoc-4.0.0-36.el7.noarch --> Running transaction check ---> Package libyaml.x86_64 0:0.1.4-11.el7_0 will be installed ---> Package ruby-irb.noarch 0:2.0.0.648-36.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: pcs x86_64 0.9.168-4.el7.centos base 4.1 M Installing for dependencies: clufter-bin x86_64 0.77.1-1.el7 base 25 k clufter-common noarch 0.77.1-1.el7 base 72 k fontpackages-filesystem noarch 1.44-8.el7 base 9.9 k liberation-fonts-common noarch 1:1.07.2-16.el7 base 27 k liberation-sans-fonts noarch 1:1.07.2-16.el7 base 279 k libyaml x86_64 0.1.4-11.el7_0 base 55 k overpass-fonts noarch 2.1-1.el7 base 700 k python-clufter noarch 0.77.1-1.el7 base 323 k ruby x86_64 2.0.0.648-36.el7 base 73 k ruby-irb noarch 2.0.0.648-36.el7 base 94 k ruby-libs x86_64 2.0.0.648-36.el7 base 2.8 M rubygem-bigdecimal x86_64 1.2.0-36.el7 base 85 k rubygem-io-console x86_64 0.4.2-36.el7 base 56 k rubygem-json x86_64 1.7.7-36.el7 base 81 k rubygem-psych x86_64 2.0.0-36.el7 base 84 k rubygem-rdoc noarch 4.0.0-36.el7 base 324 k rubygems noarch 2.0.14.1-36.el7 base 215 k Transaction Summary ================================================================================ Install 1 Package (+17 Dependent packages) Total download size: 9.4 M Installed size: 27 M Is this ok [y/d/N]: y 过多的输出,... fontpackages-filesystem.noarch 0:1.44-8.el7 liberation-fonts-common.noarch 1:1.07.2-16.el7 liberation-sans-fonts.noarch 1:1.07.2-16.el7 libyaml.x86_64 0:0.1.4-11.el7_0 overpass-fonts.noarch 0:2.1-1.el7 python-clufter.noarch 0:0.77.1-1.el7 ruby.x86_64 0:2.0.0.648-36.el7 ruby-irb.noarch 0:2.0.0.648-36.el7 ruby-libs.x86_64 0:2.0.0.648-36.el7 rubygem-bigdecimal.x86_64 0:1.2.0-36.el7 rubygem-io-console.x86_64 0:0.4.2-36.el7 rubygem-json.x86_64 0:1.7.7-36.el7 rubygem-psych.x86_64 0:2.0.0-36.el7 rubygem-rdoc.noarch 0:4.0.0-36.el7 rubygems.noarch 0:2.0.14.1-36.el7 Complete! [root@mysql1 corosync]# |
启动PCS服务:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[root@mysql1 corosync]# systemctl start pcsd [root@mysql1 corosync]# [root@mysql1 corosync]# systemctl status pcsd ● pcsd.service - PCS GUI and remote configuration interface Loaded: loaded (/usr/lib/systemd/system/pcsd.service; disabled; vendor preset: disabled) Active: active (running) since Sun 2020-08-09 16:59:08 CST; 7s ago Docs: man:pcsd(8) man:pcs(8) Main PID: 24777 (pcsd) CGroup: /system.slice/pcsd.service └─24777 /usr/bin/ruby /usr/lib/pcsd/pcsd Aug 09 16:59:07 mysql1 systemd[1]: Starting PCS GUI and remote configuratio..... Aug 09 16:59:08 mysql1 systemd[1]: Started PCS GUI and remote configuration...e. Hint: Some lines were ellipsized, use -l to show in full. [root@mysql1 corosync]# |
确认用户【hacluster】的状态:
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@mysql1 corosync]# id hacluster uid=189(hacluster) gid=189(haclient) groups=189(haclient) [root@mysql1 corosync]# [root@mysql1 corosync]# cat /etc/passwd | grep hacluster hacluster:x:189:189:cluster user:/home/hacluster:/sbin/nologin [root@mysql1 corosync]# 设置用户【hacluster】的密码: [root@mysql1 corosync]# echo "Abcd1@34" | passwd --stdin hacluster Changing password for user hacluster. passwd: all authentication tokens updated successfully. [root@mysql1 corosync]# |
PCS验证:
节点一:
1 2 3 4 5 6 |
[root@mysql1 corosync]# pcs cluster auth mysql2 mysql1 Username: hacluster Password: mysql1: Authorized mysql2: Authorized [root@mysql1 corosync]# |
节点二:
1 2 3 4 |
[root@mysql2 ~]# pcs cluster auth mysql1 mysql2 mysql1: Already authorized mysql2: Already authorized [root@mysql2 ~]# |
建立集群:
在其中一个节点上操作,这里,我在节点一操作:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
[root@mysql1 corosync]# pcs cluster setup --name clusterme mysql1 mysql2 --force Destroying cluster on nodes: mysql1, mysql2... mysql1: Stopping Cluster (pacemaker)... mysql2: Stopping Cluster (pacemaker)... mysql2: Successfully destroyed cluster mysql1: Successfully destroyed cluster Sending 'pacemaker_remote authkey' to 'mysql1', 'mysql2' mysql1: successful distribution of the file 'pacemaker_remote authkey' mysql2: successful distribution of the file 'pacemaker_remote authkey' Sending cluster config files to the nodes... mysql1: Succeeded mysql2: Succeeded Synchronizing pcsd certificates on nodes mysql1, mysql2... mysql1: Success mysql2: Success Restarting pcsd on the nodes in order to reload the certificates... mysql1: Success mysql2: Success [root@mysql1 corosync]# |
上面命令执行完成后,配置文件会发生变化:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
[root@mysql1 corosync]# pwd /etc/corosync [root@mysql1 corosync]# [root@mysql1 corosync]# cat corosync.conf totem { version: 2 cluster_name: clusterme secauth: off transport: udpu } nodelist { node { ring0_addr: mysql1 nodeid: 1 } node { ring0_addr: mysql2 nodeid: 2 } } quorum { provider: corosync_votequorum two_node: 1 } logging { to_logfile: yes logfile: /var/log/cluster/corosync.log to_syslog: yes } [root@mysql1 corosync]# |
启动集群,并查看集群状态:
节点一:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
[root@mysql1 corosync]# pcs cluster status Error: cluster is not currently running on this node [root@mysql1 corosync]# [root@mysql1 corosync]# pcs cluster start Starting Cluster (corosync)... Starting Cluster (pacemaker)... [root@mysql1 corosync]# [root@mysql1 corosync]# pcs cluster status Cluster Status: Stack: unknown Current DC: NONE Last updated: Sun Aug 9 17:15:25 2020 Last change: Sun Aug 9 17:15:19 2020 by hacluster via crmd on mysql1 2 nodes configured 0 resources configured PCSD Status: mysql2: Online mysql1: Online [root@mysql1 corosync]# [root@mysql1 ~]# corosync-cfgtool -s Printing ring status. Local node ID 1 RING ID 0 id = 192.168.126.133 status = ring 0 active with no faults [root@mysql1 ~]# [root@mysql1 ~]# corosync-cmapctl | grep members runtime.totem.pg.mrp.srp.members.1.config_version (u64) = 0 runtime.totem.pg.mrp.srp.members.1.ip (str) = r(0) ip(192.168.126.133) runtime.totem.pg.mrp.srp.members.1.join_count (u32) = 1 runtime.totem.pg.mrp.srp.members.1.status (str) = joined runtime.totem.pg.mrp.srp.members.2.config_version (u64) = 0 runtime.totem.pg.mrp.srp.members.2.ip (str) = r(0) ip(192.168.126.134) runtime.totem.pg.mrp.srp.members.2.join_count (u32) = 1 runtime.totem.pg.mrp.srp.members.2.status (str) = joined [root@mysql1 ~]# [root@mysql1 ~]# crm_verify -L -V error: unpack_resources: Resource start-up disabled since no STONITH resources have been defined error: unpack_resources: Either configure some or disable STONITH with the stonith-enabled option error: unpack_resources: NOTE: Clusters with shared data need STONITH to ensure data integrity Errors found during check: config not valid [root@mysql1 ~]# [root@mysql1 ~]# pcs property set stonith-enabled=false [root@mysql1 ~]# [root@mysql1 ~]# crm_verify -L -V [root@mysql1 ~]# |
节点二:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
[root@mysql2 ~]# pcs cluster status Error: cluster is not currently running on this node [root@mysql2 ~]# [root@mysql2 ~]# pcs cluster start Starting Cluster (corosync)... Starting Cluster (pacemaker)... [root@mysql2 ~]# [root@mysql2 ~]# pcs cluster status Cluster Status: Stack: corosync Current DC: mysql1 (version 1.1.21-4.el7-f14e36fd43) - partition with quorum Last updated: Sun Aug 9 17:16:02 2020 Last change: Sun Aug 9 17:15:40 2020 by hacluster via crmd on mysql1 2 nodes configured 0 resources configured PCSD Status: mysql2: Online mysql1: Online [root@mysql2 ~]# [root@mysql2 ~]# corosync-cfgtool -s Printing ring status. Local node ID 2 RING ID 0 id = 192.168.126.134 status = ring 0 active with no faults [root@mysql2 ~]# [root@mysql2 ~]# corosync-cmapctl | grep members runtime.totem.pg.mrp.srp.members.1.config_version (u64) = 0 runtime.totem.pg.mrp.srp.members.1.ip (str) = r(0) ip(192.168.126.133) runtime.totem.pg.mrp.srp.members.1.join_count (u32) = 1 runtime.totem.pg.mrp.srp.members.1.status (str) = joined runtime.totem.pg.mrp.srp.members.2.config_version (u64) = 0 runtime.totem.pg.mrp.srp.members.2.ip (str) = r(0) ip(192.168.126.134) runtime.totem.pg.mrp.srp.members.2.join_count (u32) = 1 runtime.totem.pg.mrp.srp.members.2.status (str) = joined [root@mysql2 ~]# [root@mysql2 ~]# crm_verify -L -V error: unpack_resources: Resource start-up disabled since no STONITH resources have been defined error: unpack_resources: Either configure some or disable STONITH with the stonith-enabled option error: unpack_resources: NOTE: Clusters with shared data need STONITH to ensure data integrity Errors found during check: config not valid [root@mysql2 ~]# [root@mysql2 ~]# pcs property set stonith-enabled=false [root@mysql2 ~]# [root@mysql2 ~]# crm_verify -L -V [root@mysql2 ~]# |
也可以用【crm status】看集群状态:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@mysql1 corosync]# crm status Stack: corosync Current DC: mysql1 (version 1.1.21-4.el7-f14e36fd43) - partition with quorum Last updated: Sun Aug 9 18:22:12 2020 Last change: Sun Aug 9 17:20:18 2020 by root via cibadmin on mysql2 2 nodes configured 0 resources configured Online: [ mysql1 mysql2 ] No resources [root@mysql1 corosync]# |
基本的corosync与pacemaker,配好了,更多的内容在以后的文档中记录。