Linux technical support - [email protected]


pacemaker corosync nginx cluster

# Pacemaker installation

[root@host1]# yum -y install corosync pcs pacemaker nginx 

[root@host2]# yum -y install corosync pcs pacemaker nginx 


# Enable autostart

[root@host1]# systemctl enable pcsd; systemctl enable corosync; \
systemctl enable pacemaker

[root@host2]# systemctl enable pcsd; systemctl enable corosync; \
systemctl enable pacemaker


# Start pacemaker

[root@host1]# systemctl start pcsd

[root@host2]# systemctl start pcsd


# Add nginx as cluster resource:

[root@host1]# cd /usr/lib/ocf/resource.d/heartbeat

[root@host1]# wget https://raw.githubusercontent.com/ClusterLabs/\
resource-agents/master/heartbeat/nginx

[root@host1]# chmod 755 nginx

[root@host2]# cd /usr/lib/ocf/resource.d/heartbeat

[root@host2]# wget https://raw.githubusercontent.com/ClusterLabs/\
resource-agents/master/heartbeat/nginx

[root@host2]# chmod 755 nginx


# Set password

[root@host1]# passwd hacluster

[root@host2]# passwd hacluster


# Authentificate nodes

[root@host1]# pcs cluster auth test01 test02


# Setup and start cluster

[root@host1]# pcs cluster setup --name cluster_web test01 test02

[root@host1]# systemctl start pacemaker; systemctl start corosync

[root@host2]# systemctl start pacemaker; systemctl start corosync

[root@host1]# pcs cluster start --all
 

# Disable STONITH 

[root@host1]# pcs property set stonith-enabled=false

[root@host1]# pcs property set no-quorum-policy=ignore


# Add cluster ip address

[root@host1]# pcs resource create virtual_ip ocf:heartbeat:IPaddr2 \
ip=10.1.1.10 cidr_netmask=32 op monitor interval=30s


# Create web server resource

[root@host1]# pcs resource create webserver ocf:heartbeat:nginx \
configfile=/etc/nginx/nginx.conf op monitor timeout="5s" interval="5s"


# Add rules

[root@host1]# pcs constraint colocation add webserver virtual_ip INFINITY

[root@host1]# pcs constraint order virtual_ip then webserver

[root@host1]# pcs constraint location webserver prefers test01=50

[root@host1]# pcs cluster stop --all; pcs cluster start --all

if something goes wrong – checkout troubleshooting page

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>