Available Packages Name : pcs Arch : x86_64 Version : 0.9.158 Release : 6.el7.centos Size : 4.8 M Repo : base/7/x86_64 Summary : Pacemaker Configuration System URL : https://github.com/ClusterLabs/pcs License : GPLv2 Description : pcs is a corosync and pacemaker configuration tool. It permits users to : easily view, modify and create pacemaker based clusters.
[root@VM-node1 ~]# ansible ha -m yum -a 'name=pcs state=latest'
这次准备的两个CentSOS7, 而且已经做好了密钥ssh登录, 主机名解析, 时间同步.
安装完成之后, 会看到: pcs有个守护进程 这个我们需要启动起来接着设置成为开机启动:
1 2 3 4 5 6 7 8 9 10 11 12
[root@VM-node1 ~]# ansible ha -m service -a 'name=pcsd state=started enabled=yes' # 查看一下 [root@VM-node1 ~]# systemctl status pcsd ● pcsd.service - PCS GUI and remote configuration interface Loaded: loaded (/usr/lib/systemd/system/pcsd.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2017-10-28 14:04:32 CST; 17s ago Main PID: 23944 (pcsd) CGroup: /system.slice/pcsd.service └─23944 /usr/bin/ruby /usr/lib/pcsd/pcsd > /dev/null &
Oct 28 14:04:30 VM-node1 systemd[1]: Starting PCS GUI and remote configuration interface... Oct 28 14:04:32 VM-node1 systemd[1]: Started PCS GUI and remote configuration interface.
Sending 'pacemaker_remote authkey' to 'VM-node1', 'VM-node2' VM-node1: successful distribution of the file 'pacemaker_remote authkey' VM-node2: successful distribution of the file 'pacemaker_remote authkey' Sending cluster config files to the nodes... VM-node1: Succeeded VM-node2: Succeeded
Synchronizing pcsd certificates on nodes VM-node1, VM-node2... VM-node1: Success VM-node2: Success Restarting pcsd on the nodes in order to reload the certificates... VM-node1: Success VM-node2: Success
[root@VM-node1 ~]# pcs status Cluster name: testcluster WARNING: no stonith devices and stonith-enabled is not false Stack: corosync Current DC: VM-node1 (version 1.1.16-12.el7_4.4-94ff4df) - partition with quorum Last updated: Sat Oct 28 14:41:58 2017 Last change: Sat Oct 28 14:40:29 2017 by hacluster via crmd on VM-node1
Membership information ---------------------- Nodeid Votes Name 1 1 VM-node1 (local) 2 1 VM-node2
corosync-cfgtool
1 2 3 4 5 6
[root@VM-node1 ~]# corosync-cfgtool -s VM-node1 Printing ring status. Local node ID 1 RING ID 0 id = 192.168.206.9 status = ring 0 active with no faults
[root@VM-node1 ~]# crm_verify -LV 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@VM-node1 ~]# crm crm(live)# ls cibstatus help site cd cluster quit end script verify exit ra maintenance bye ? ls node configure back report cib resource up status corosync options history crm(live)# resource crm(live)resource# cd .. crm(live)#
crm(live)# status Stack: corosync Current DC: VM-node1 (version 1.1.16-12.el7_4.4-94ff4df) - partition with quorum Last updated: Sat Oct 28 15:56:50 2017 Last change: Sat Oct 28 15:54:55 2017 by root via cibadmin on VM-node1
2 nodes configured 1 resource configured
Online: [ VM-node1 VM-node2 ]
Full list of resources:
webip (ocf::heartbeat:IPaddr): Started VM-node1
crm(live)# node crm(live)node# standby crm(live)node# cd crm(live)# status Stack: corosync Current DC: VM-node1 (version 1.1.16-12.el7_4.4-94ff4df) - partition with quorum Last updated: Sat Oct 28 15:57:52 2017 Last change: Sat Oct 28 15:57:46 2017 by root via crm_attribute on VM-node1
crm(live)# configure crm(live)configure# primitive webserver systemd:httpd crm(live)configure# verify WARNING: webserver: default timeout 20s for start is smaller than the advised 100 WARNING: webserver: default timeout 20s for stop is smaller than the advised 100 crm(live)configure# commit WARNING: webserver: default timeout 20s for start is smaller than the advised 100 WARNING: webserver: default timeout 20s for stop is smaller than the advised 100 crm(live)configure# cd crm(live)# status Stack: corosync Current DC: VM-node1 (version 1.1.16-12.el7_4.4-94ff4df) - partition with quorum Last updated: Sat Oct 28 16:35:17 2017 Last change: Sat Oct 28 16:35:09 2017 by root via cibadmin on VM-node1
2 nodes configured 2 resources configured
Online: [ VM-node1 VM-node2 ]
Full list of resources:
webip (ocf::heartbeat:IPaddr): Started VM-node2 webserver (systemd:httpd): Started VM-node1
crm(live)# configure crm(live)configure# group webservice webip webserver crm(live)configure# verify WARNING: webserver: default timeout 20s for start is smaller than the advised 100 WARNING: webserver: default timeout 20s for stop is smaller than the advised 100 crm(live)configure# commit crm(live)configure# cd crm(live)# status Stack: corosync Current DC: VM-node1 (version 1.1.16-12.el7_4.4-94ff4df) - partition with quorum Last updated: Sat Oct 28 16:37:39 2017 Last change: Sat Oct 28 16:37:33 2017 by root via cibadmin on VM-node1
2 nodes configured 2 resources configured
Online: [ VM-node1 VM-node2 ]
Full list of resources:
Resource Group: webservice webip (ocf::heartbeat:IPaddr): Started VM-node2 webserver (systemd:httpd): Started VM-node2
[root@VM-node1 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. Press keys on your keyboard to generate entropy (bits = 920). Press keys on your keyboard to generate entropy (bits = 1000). Writing corosync key to /etc/corosync/authkey.
[root@VM-node1 corosync]# tail /var/log/cluster/corosync.log Oct 28 20:57:36 [34337] VM-node1 corosync info [QB ] server name: votequorum Oct 28 20:57:36 [34337] VM-node1 corosync notice [SERV ] Service engine loaded: corosync cluster quorum service v0.1 [3] Oct 28 20:57:36 [34337] VM-node1 corosync info [QB ] server name: quorum Oct 28 20:57:36 [34337] VM-node1 corosync notice [TOTEM ] A new membership (192.168.206.9:16) was formed. Members joined: 3232288265 Oct 28 20:57:36 [34337] VM-node1 corosync notice [QUORUM] Members[1]: 3232288265 Oct 28 20:57:36 [34337] VM-node1 corosync notice [MAIN ] Completed service synchronization, ready to provide service. Oct 28 20:57:36 [34337] VM-node1 corosync notice [TOTEM ] A new membership (192.168.206.9:24) was formed. Members joined: 3232288266 Oct 28 20:57:36 [34337] VM-node1 corosync notice [QUORUM] This node is within the primary component and will provide service. Oct 28 20:57:36 [34337] VM-node1 corosync notice [QUORUM] Members[2]: 3232288265 3232288266 Oct 28 20:57:36 [34337] VM-node1 corosync notice [MAIN ] Completed service synchronization, ready to provide service.
[root@VM-node0 ~]# crm crm(live)# configure crm(live)configure# show node 3232288264: VM-node0 node 3232288265: VM-node1 node 3232288266: VM-node2 property cib-bootstrap-options: \ have-watchdog=false \ dc-version=1.1.16-12.el7_4.4-94ff4df \ cluster-infrastructure=corosync \ stonith-enabled=false crm(live)configure# cd crm(live)# configure crm(live)configure# primitive webip ocf:heartbeat:IPaddr2 params ip=192.168.206.11 op monitor interval=30s timeout=20s crm(live)configure# verify crm(live)configure# primitive webserver systemd:httpd op start timeout=30s op stop timeout=30s op monitor interval=30s timeout=20s crm(live)configure# verify WARNING: webserver: specified timeout 30s for start is smaller than the advised 100 WARNING: webserver: specified timeout 30s for stop is smaller than the advised 100 WARNING: webserver: specified timeout 20s for monitor is smaller than the advised 100 crm(live)configure# edit crm(live)configure# verify crm(live)configure# primitive webstore ocf:heartbeat:Filesystem params device="VM-node0:/data" fstype=nfs directory="/var/www/html" crm(live)configure# verify WARNING: webstore: default timeout 20s for start is smaller than the advised 60 WARNING: webstore: default timeout 20s for stop is smaller than the advised 60 crm(live)configure# edit crm(live)configure# verify crm(live)configure# order store_after_ip Mandatory: webip webstore crm(live)configure# order server_after_store Mandatory: webserver webstore crm(live)configure# verify crm(live)configure# commit crm(live)configure# exit bye [root@VM-node0 ~]# crm status Stack: corosync Current DC: VM-node2 (version 1.1.16-12.el7_4.4-94ff4df) - partition with quorum Last updated: Sun Oct 29 07:49:31 2017 Last change: Sun Oct 29 07:49:25 2017 by root via cibadmin on VM-node0
3 nodes configured 3 resources configured
Online: [ VM-node0 VM-node1 VM-node2 ]
Full list of resources:
webip (ocf::heartbeat:IPaddr2): Started VM-node0 webserver (systemd:httpd): Started VM-node0 webstore (ocf::heartbeat:Filesystem): Started VM-node0
OK, 呼出一口气….来测试一下吧.
1 2 3
C:\Users\lenovo\Desktop λ curl 192.168.206.11 <h1>Web Page on NFS</h1>