阅读更多
Pacemaker 2019(1)Introduction and Installation on CentOS7
Try that on my CentOS7
https://clusterlabs.org/quickstart-redhat.html
Install that on my system via yum
> sudo yum install pacemaker pcs resource-agents
Create the Cluster
It is on top of Corosync 2, so make sure pcs daemon is running
> sudo systemctl start pcsd.service
> sudo systemctl enable pcsd.service
Set up user and password
> echo password123 | sudo passwd --stdin hacluster
Changing password for user hacluster.
passwd: all authentication tokens updated successfully.
> sudo pcs cluster auth centos-dev1 centos-dev2 -u hacluster -p password123 --force
centos-dev1: Authorized
centos-dev2: Authorized
Create first cluster as peacemaker1
> sudo pcs cluster setup --force --name pacemaker1 centos-dev1 centos-dev2
Destroying cluster on nodes: centos-dev1, centos-dev2...
centos-dev2: Stopping Cluster (pacemaker)...
centos-dev1: Stopping Cluster (pacemaker)...
centos-dev2: Successfully destroyed cluster
centos-dev1: Successfully destroyed cluster
Sending 'pacemaker_remote authkey' to 'centos-dev1', 'centos-dev2'
centos-dev1: successful distribution of the file 'pacemaker_remote authkey'
centos-dev2: successful distribution of the file 'pacemaker_remote authkey'
Sending cluster config files to the nodes...
centos-dev1: Succeeded
centos-dev2: Succeeded
Synchronizing pcsd certificates on nodes centos-dev1, centos-dev2...
centos-dev1: Success
centos-dev2: Success
Restarting pcsd on the nodes in order to reload the certificates...
centos-dev1: Success
centos-dev2: Success
Start the Cluster
> sudo pcs cluster start --all
centos-dev1: Starting Cluster (corosync)...
centos-dev2: Starting Cluster (corosync)...
centos-dev2: Starting Cluster (pacemaker)...
centos-dev1: Starting Cluster (pacemaker)...
Enable that on boot
> sudo pcs cluster enable --all
centos-dev1: Cluster Enabled
centos-dev2: Cluster Enabled
Install nginx and run the static page there
> sudo yum install nginx -y
> sudo systemctl enable nginx
> sudo systemctl start nginx
Go and modify the default nginx page
> sudo vi /usr/share/nginx/html/index.html
Webserver-1
> sudo vi /usr/share/nginx/html/index.html
Webserver-2
Check cluster status
> sudo pcs status
Cluster name: pacemaker1
WARNINGS:
No stonith devices and stonith-enabled is not false
Stack: corosync
Current DC: centos-dev1 (version 1.1.19-8.el7_6.4-c3c624ea3d) - partition with quorum
Last updated: Tue Sep 10 16:04:42 2019
Last change: Tue Sep 10 15:44:26 2019 by hacluster via crmd on centos-dev1
2 nodes configured
0 resources configured
Online: [ centos-dev1 centos-dev2 ]
No resources
Daemon Status:
corosync: active/enabled
pacemaker: active/enabled
pcsd: active/enabled
Disable STONITH
> sudo pcs property set stonith-enabled=false
Check status again
> sudo pcs status
Cluster name: pacemaker1
Stack: corosync
Current DC: centos-dev1 (version 1.1.19-8.el7_6.4-c3c624ea3d) - partition with quorum
Last updated: Tue Sep 10 16:06:54 2019
Last change: Tue Sep 10 16:06:42 2019 by root via cibadmin on centos-dev1
2 nodes configured
0 resources configured
Online: [ centos-dev1 centos-dev2 ]
No resources
Daemon Status:
corosync: active/enabled
pacemaker: active/enabled
pcsd: active/enabled
Ignore the Quorum Policy
> sudo pcs property set no-quorum-policy=ignore
Check the features
> sudo pcs property list
Cluster Properties:
cluster-infrastructure: corosync
cluster-name: pacemaker1
dc-version: 1.1.19-8.el7_6.4-c3c624ea3d
have-watchdog: false
no-quorum-policy: ignore
stonith-enabled: false
Add Resources floatingIP
> sudo pcs resource create v_ip ocf:heartbeat:IPaddr2 ip=192.168.56.110 cidr_netmask=32 op monitor interval=20s
Add Resource web server
> sudo pcs resource create webserver ocf:heartbeat:nginx configfile=/etc/nginx/nginx.conf op monitor timeout="5s" interval="5s"
Check resources
> sudo pcs status resources
v_ip (ocf::heartbeat:IPaddr2): Started centos-dev1
webserver (ocf::heartbeat:nginx): Started centos-dev2
Resources running on the same node
> sudo pcs constraint colocation add webserver v_ip INFINITY
> sudo pcs status resources
v_ip (ocf::heartbeat:IPaddr2): Started centos-dev1
webserver (ocf::heartbeat:nginx): Started centos-dev1
Set the running order of the resources
> sudo pcs constraint order v_ip then webserver
Adding v_ip webserver (kind: Mandatory) (Options: first-action=start then-action=start)
Check status again
> sudo pcs status resources
v_ip (ocf::heartbeat:IPaddr2): Started centos-dev1
webserver (ocf::heartbeat:nginx): Started centos-dev1
Visit the floating IP, you will see the web server
http://192.168.56.110/
Stop the cluster
> sudo pcs cluster stop centos-dev1
The service goes to server 2
> sudo pcs status resources
v_ip (ocf::heartbeat:IPaddr2): Started centos-dev2
webserver (ocf::heartbeat:nginx): Started centos-dev2
Pacemaker/Corosync. VS. HAProxy/Keepalived
Check resources
> sudo pcs resource standards
[sudo] password for carl:
lsb
ocf
service
systemd
> sudo pcs resource providers
heartbeat
openstack
pacemaker
> sudo pcs resource agents
aliyun-vpc-move-ip
apache
arp-ethers
arp-ethers
attribute
auditd
…snip…
All the files are here
> cd /usr/lib/ocf/resource.d/
Check the help file
> sudo pcs resource describe ocf:heartbeat:nginx
Customer Resource
https://blog.csdn.net/tantexian/article/details/50160159
https://unix.stackexchange.com/questions/303814/pacemaker-corosync-ha-simple-custom-resource-testing-status-flapping-s
https://dopensource.com/2017/04/27/creating-custom-ocf-resource-agents/
List the LSB services
> sudo pcs resource agents lsb
netconsole
network
List the OCF
> sudo pcs resource agents ocf
apache
attribute
aws-vpc-move-ip
awseip
References:
https://blog.51cto.com/freeloda/1274533
https://clusterlabs.org/
https://clusterlabs.org/quickstart.html
https://clusterlabs.org/quickstart-redhat.html
https://www.dreamvps.com/tutorials/set-nginx-high-availability-cluster-using-pacemaker-centos-7/
https://www.sharpcode.cn/linux/cluster-corosync-pacemaker/
https://stackoverflow.com/questions/45166494/pacemaker-adding-custom-resource