Linux technical support - [email protected]


pacemaker corosync nginx cluster

# Pacemaker installation

[[email protected]]# yum -y install corosync pcs pacemaker nginx 

[[email protected]]# yum -y install corosync pcs pacemaker nginx 


# Enable autostart

[[email protected]]# systemctl enable pcsd; systemctl enable corosync; \
systemctl enable pacemaker

[[email protected]]# systemctl enable pcsd; systemctl enable corosync; \
systemctl enable pacemaker


# Start pacemaker

[[email protected]]# systemctl start pcsd

[[email protected]2]# systemctl start pcsd


# Add nginx as cluster resource:

[[email protected]]# cd /usr/lib/ocf/resource.d/heartbeat

[[email protected]]# wget https://raw.githubusercontent.com/ClusterLabs/\
resource-agents/master/heartbeat/nginx

[[email protected]]# chmod 755 nginx

[[email protected]]# cd /usr/lib/ocf/resource.d/heartbeat

[[email protected]]# wget https://raw.githubusercontent.com/ClusterLabs/\
resource-agents/master/heartbeat/nginx

[[email protected]]# chmod 755 nginx


# Set password

[[email protected]]# passwd hacluster

[[email protected]]# passwd hacluster


# Authentificate nodes

[[email protected]]# pcs cluster auth test01 test02


# Setup and start cluster

[[email protected]]# pcs cluster setup --name cluster_web test01 test02

[[email protected]]# systemctl start pacemaker; systemctl start corosync

[[email protected]]# systemctl start pacemaker; systemctl start corosync

[[email protected]]# pcs cluster start --all
 

# Disable STONITH 

[[email protected]]# pcs property set stonith-enabled=false

[[email protected]]# pcs property set no-quorum-policy=ignore


# Add cluster ip address

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


# Create web server resource

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


# Add rules

[[email protected]]# pcs constraint colocation add webserver virtual_ip INFINITY

[[email protected]]# pcs constraint order virtual_ip then webserver

[[email protected]]# pcs constraint location webserver prefers test01=50

[[email protected]]# 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>