You are on page 1of 42

Pacemaker

Power Systems
Pacemaker

• HA

– Linux-HA Japan
– Red Hat RHEL High Availability Add-On HA

• Pacemaker
– / / Pacemaker

© 2018 IBM Corporation 2


IBM Power Systems S824

VIOS

ent0 ent0
192.168.48.11 192.168.48.12

node1 node2
CentOS 7.5 CentOS 7.5

© 2018 IBM Corporation 3


pacemaker1
node1, node2
Floating IP 192.168.48.180
IP

© 2018 IBM Corporation 4


Pacemaker
1. CentOS yum
– Red Hat Add-on

2.

– yum
– pacemaker


– pcs :
• pacemaker corosync
– corosync :

• pacemaker

© 2018 IBM Corporation 5


Pacemaker
• Pacemaker
node1 $ yum install pacemaker pcs


node1 $ attrd_updater --version
Pacemaker 1.1.18-11.el7_5.3
Written by Andrew Beekhof
node1 $ corosync -v
Corosync Cluster Engine, version '2.4.3'
Copyright (c) 2006-2009 Red Hat, Inc.
2018 10 CentOS

© 2018 IBM Corporation 7


(1/2)
• /etc/hosts
node1 $ vi /etc/ hosts
node1 $ cat /etc/hosts
127.0.0.1 localhost
::1 localhost

192.168.48.11 node1
192.168.48.12 node2

• SSH
– SSH 1

node1 $ ssh-keygen -t dsa -f ~/.ssh/id_dsa -N "”


node1 $ cp ~/.ssh/id_dsa.pub ~/.ssh/authorized_keys
node1 $ scp -r ~/.ssh node2:

© 2018 IBM Corporation 9


(2/2)


node1 $ firewall-cmd --permanent --add-service=high-availability
success
node1 $ firewall-cmd --reload
success

© 2018 IBM Corporation 10


Pacemaker
• pcsd
node1 $ systemctl start pcsd.service
node1 $ systemctl enable pcsd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/pcsd.service to
/usr/lib/systemd/system/pcsd.service.

• “hacluster”
– Hacluster pacemaker

node1 $ passwd hacluster


Changing password for user hacluster.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

© 2018 IBM Corporation 11


• “hacluster” 1

node1 $ pcs cluster auth node1 node2


Username: hacluster
Password:
node1: Authorized
node2: Authorized

• corosync config 1

node1 $ pcs cluster setup --name pacemaker1 node1 node2

© 2018 IBM Corporation 12


• 1

node1 $ pcs cluster start --all
node2: Starting Cluster...
node1: Starting Cluster...
node1 $ pcs cluster enable --all
node1: Cluster Enabled
node2: Cluster Enabled

• STONITH
– STONITH 1

node1 $ pcs property set stonith-enabled=false


node1 $ crm_verify -L

© 2018 IBM Corporation 13


Active / Passive Apache HTTP
• Pacemaker Active / Passive Apache
HTTP
– Web “index.html”

• pcs
– “/var/lib/pacemaker/cib/cib.xml” pcs

192.168.48.11

node1
192.168.48.180

192.168.48.12

node2

© 2018 IBM Corporation 14


• LVM 1

node1 $ pvcreate /dev/mapper/mpathb1


Physical volume " /dev/mapper/mpathb1" successfully created

• “my_vg” 1

node1 $ vgcreate my_vg /dev/mapper/mpathb1


Volume group "my_vg" successfully created

• “my_lv” 1

node1 $ lvcreate –L5000 -n my_lv my_vg


Rounding up size to full physical extent 5000.00 MiB Logical volume "my_lv" created

• ext4 my_lv 1

node1 $ mkfs.ext4 /dev/my_vg/my_lv

© 2018 IBM Corporation 15


Apache

• Apache HTTP
node1 $ yum install httpd


node1 $ firewall-cmd --permanent --add-service=http
success
node1 $ firewall-cmd --reload
success

© 2018 IBM Corporation 16


HTML
• 1

node1 $ mount /dev/my_vg/my_lv /var/www/

• html
1

node1 $ mkdir /var/www/html


node1 $ mkdir /var/www/cgi-bin
node1 $ mkdir /var/www/error
node1 $ restorecon -R /var/www
node1 $ cat <<-END >/var/www/html/index.html
<html>
<body>My Test Site</body>
</html>
END
node1 $ umount /var/www

© 2018 IBM Corporation 17


Apache HTTP (1/2)

• Apache
node1 $ vi /etc/httpd/conf/httpd.conf
node1 $ cat /etc/httpd/conf/httpd.conf

~ ~

<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>

© 2018 IBM Corporation 18


Apache HTTP (2/2)
• “/etc/logrotate.d/httpd”
– apache Apache systemd
systemctl
node1 $ vi /etc/logrotate.d/httpd
node1 $ cat /etc/logrotate.d/httpd
/var/log/httpd/*log {
missingok
notifempty
sharedscripts
delaycompress
postrotate
/usr/sbin/httpd -f /etc/httpd/conf/httpd.conf -c "PidFile /var/run/httpd.pid" -k graceful > /dev/null 2>/dev/null
|| true
endscript
}

© 2018 IBM Corporation 19



node1 $ lvmconf --enable-halvm --services --startstopservices

• /etc/lvm/lvm.conf
“volume_list”
node1 $ vi /etc/lvm/lvm.conf

volume_list = [ "ca" ]


“initramfs”
node1 $ dracut -H -f /boot/initramfs-$(uname -r).img $(uname -r)

© 2018 IBM Corporation 20



LVM my_lvm
Filesystem my_fs
apachegroup
IPaddr2 ClusterIP
apache WebSite

© 2018 IBM Corporation 21


(1/2) 1

• LVM “my_lvm”
node1 $ pcs resource create my_lvm LVM volgrpname=my_vg exclusive=true --group apachegroup
Assumed agent name 'ocf:heartbeat:LVM' (deduced from 'LVM')

• Filesystem “my_fs”
node1 $ pcs resource create my_fs Filesystem device="/dev/my_vg/my_lv" directory="/var/www"
fstype="ext4" --group apachegroup
Assumed agent name 'ocf:heartbeat:Filesystem' (deduced from 'Filesystem')

• Filesystem “my_fs”
node1 $ pcs resource create ClusterIP IPaddr2 ip=192.168.48.120 cidr_netmask=32 op monitor interval=30s
--group apachegroup

• apache “WebSite”
node1 $ pcs resource create WebSite apache configfile="/etc/httpd/conf/httpd.conf"
statusurl="http://127.0.0.1/server-status" --group apachegroup
© 2018 IBM Corporation 22
(2/2)
• 1
node1 $ pcs status

~ ~

2 nodes configured
4 resources configured

Online: [ node1 node2 ]

Full list of resources:

Resource Group: apachegroup


my_lvm (ocf::heartbeat:LVM): Started node1
4
my_fs (ocf::heartbeat:Filesystem): Started node1
ClusterIP (ocf::heartbeat:IPaddr2): Started node1
WebSite (ocf::heartbeat:apache): Started node1

~ ~

© 2018 IBM Corporation 23


Apache HTTP
• Floating IP Web
– node2 Web

© 2018 IBM Corporation 24


(1/2)
• 1
– “WebSite” “ClusterIP”
– “INFINITY” “ ”
node1 $ pcs constraint colocation add WebSite with ClusterIP INFINITY

• 1
– Floating IP Web
node1 $ pcs constraint order ClusterIP then WebSite
Adding ClusterIP WebSite (kind: Mandatory) (Options: first-action=start then-action=start)

1

node1 $ pcs constraint location WebSite prefers node1=50

© 2018 IBM Corporation 25


(2/2)
• 1
– Location, Ordering, Colocation

node1 $ pcs constraint


Location Constraints:
Resource: WebSite
Enabled on: node1 (score:50)
Enabled on: node1 (score:INFINITY) (role: Started)
Ordering Constraints:
start ClusterIP then start WebSite (kind:Mandatory)
Colocation Constraints:
WebSite with ClusterIP (score:INFINITY)
Ticket Constraints:

© 2018 IBM Corporation 26




© 2018 IBM Corporation 28



node1 $ pcs status
Cluster name: pacemaker1
Stack: corosync
Current DC: node2 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum
Last updated: Wed Oct 10 14:22:11 2018
Last change: Wed Oct 10 14:22:00 2018 by root via crm_resource on node1

2 nodes configured
4 resources configured

Online: [ node1 node2 ]

Full list of resources:

Resource Group: apachegroup


my_lvm (ocf::heartbeat:LVM): Started node1 node1
my_fs (ocf::heartbeat:Filesystem): Started node1
ClusterIP (ocf::heartbeat:IPaddr2): Started node1
WebSite (ocf::heartbeat:apache): Started node1

© 2018 IBM Corporation 29


( )

node1 $ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

~ ~

sdb 8:16 0 5G 0 disk


└─mpathb 253:6 0 5G 0 mpath
└─mpathb1 253:7 0 5G 0 part
└─my_vg-my_lv 253:8 0 4.9G 0 lvm /var/www
node1
node2 $ lsblk node2
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

~ ~

sdb 8:16 0 5G 0 disk


└─mpathb 253:6 0 5G 0 mpath
└─mpathb1 253:7 0 5G 0 part

© 2018 IBM Corporation 30


• “WebSite” node2
node1 $ pcs resource move WebSite node2


– LVM
– pacemaker “crm_mon”
node1 $ pcs status
Cluster name: pacemaker1

~ ~

my_lvm (ocf::heartbeat:LVM): Started node2


my_fs (ocf::heartbeat:Filesystem): Started node2
ClusterIP (ocf::heartbeat:IPaddr2): Starting node2
WebSite (ocf::heartbeat:apache): Stopped
© 2018 IBM Corporation 31
( )

node1 $ pcs status
Cluster name: pacemaker1

~ ~

Online: [ node1 node2 ]

Full list of resources:

Resource Group: apachegroup


my_lvm (ocf::heartbeat:LVM): Started node2 node2
my_fs (ocf::heartbeat:Filesystem): Started node2
ClusterIP (ocf::heartbeat:IPaddr2): Started node2
WebSite (ocf::heartbeat:apache): Started node2

Daemon Status:
corosync: active/enabled
pacemaker: active/enabled
pcsd: active/enabled

© 2018 IBM Corporation 32


( )
• “lsblk”
– node2 “/var/www”
node2 $ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 50G 0 disk
└─mpatha 253:0 0 50G 0 mpath
├─mpatha1 253:1 0 4M 0 part
├─mpatha2 253:2 0 1G 0 part /boot
└─mpatha3 253:3 0 49G 0 part
├─ca-root 253:4 0 45G 0 lvm /
└─ca-swap 253:5 0 4G 0 lvm [SWAP]
sdb 8:16 0 5G 0 disk
└─mpathb 253:6 0 5G 0 mpath
└─mpathb1 253:7 0 5G 0 part
└─my_vg-my_lv 253:8 0 4.9G 0 lvm /var/www

© 2018 IBM Corporation 33


( )
• node1
node1 $ pcs status
~ ~
Online: [ node1 node2 ]

Full list of resources:

Resource Group: apachegroup


my_lvm (ocf::heartbeat:LVM): Started node1
my_fs (ocf::heartbeat:Filesystem): Started node1
ClusterIP (ocf::heartbeat:IPaddr2): Started node1
WebSite (ocf::heartbeat:apache): Started node1
~ ~

© 2018 IBM Corporation 34


( )
• node1
node1 $ halt
Connection to 192.168.48.15 closed by remote host.
Connection to 192.168.48.15 closed.

© 2018 IBM Corporation 35


( )
node2 $ pcs status
Cluster name: pacemaker1
Stack: corosync
Current DC: node2 (version 1.1.18-11.el7_5.3-2b07d5c5a9) - partition with quorum
Last updated: Wed Oct 10 16:16:17 2018
Last change: Wed Oct 10 15:09:59 2018 by root via crm_resource on node1

2 nodes configured
4 resources configured

Online: [ node2 ]
node1 OFFLINE
OFFLINE: [ node1 ]

Full list of resources:

Resource Group: apachegroup


my_lvm (ocf::heartbeat:LVM): Started node2 2 node2
my_fs (ocf::heartbeat:Filesystem): Started node2
ClusterIP (ocf::heartbeat:IPaddr2): Started node2
WebSite (ocf::heartbeat:apache): Started node2

© 2018 IBM Corporation 36


( )
• HMC node1

• node1 node1
node2 $ pcs status

~ ~

Online: [ node1 node2 ]

Full list of resources:

Resource Group: apachegroup


my_lvm (ocf::heartbeat:LVM): Started node1
my_fs (ocf::heartbeat:Filesystem): Started node1
ClusterIP (ocf::heartbeat:IPaddr2): Started node1
WebSite (ocf::heartbeat:apache): Started node1

© 2018 IBM Corporation 37


corosync
• pacemaker corosync
• corosync

$ yum -y install automake autoconf libtool libtool-ltdl-devel libuuid-devel pkgconfig glib2-devel libxml2-devel
libxslt-devel bzip2-devel libqb-devel
$ git clone https://github.com/ppc64le/build-scripts/blob/master/corosync/corosync_rhel_7.4.sh
$ ./corosync_rhel_7.4.sh

corosync_rhel_7.4sh URL
Git
https://github.com/ppc64le/build-scripts/blob/master/corosync/corosync_rhel_7.4.sh

© 2018 IBM Corporation 39


Pacemaker
• pacemaker
• Github
• URL : https://github.com/ClusterLabs/pacemaker.git

$ git clone https://github.com/ClusterLabs/pacemaker.git


$ cd pacemaker
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install
$ ldconfig

© 2018 IBM Corporation 40


gem
• pcs rubygems
node1 $ wget https://rubygems.org/rubygems/rubygems-2.7.7.tgz
node1 $ tar -xzvf rubygems-2.7.7.tgz
node1 $ cd rubygems-2.7.7/
node1 $ ruby setup.rb

• ruby-devel (RedHat Optional )


node1 $ yum install ruby-devel

• pcs pcsd V0.9


– Rubygems V0.9
node1 $ git clone -b pcs-0.9 https://github.com/ClusterLabs/pcs.git
node1 $ cd pcs
node1 $ make install
node1 $ make install_pcsd

© 2018 IBM Corporation 41


• Cluster Lab https://clusterlabs.org/doc/
• Pacemaker Docment : https://clusterlabs.org/pacemaker/doc/en-
US/Pacemaker/2.0/html/Clusters_from_Scratch/index.html
• High Availability Add-On : https://access.redhat.com/documentation/ja-
jp/red_hat_enterprise_linux/7/html-single/high_availability_add-on_overview/index
• High Availability Add-on : https://access.redhat.com/documentation/ja-
jp/red_hat_enterprise_linux/7/html/high_availability_add-on_reference/index
• High Availability Add-On : https://access.redhat.com/documentation/ja-
jp/red_hat_enterprise_linux/7/html-single/high_availability_add-on_administration/index#s1-
webserversetup-HAAA

© 2018 IBM Corporation 42

You might also like