PCS Corosync Pacemaker Cluster Mariadb using NFS
PCS Corosync Pacemaker Cluster Mariadb using NFS
I have use 2 node cluster with nfsserver (NODE1,NODE2 and nfsserver ) OS RHEL7.6 Minimal Install
IP 192.168.122.50 node1.example.com node1
IP 192.168.122.51 node2.example.com node2
IP 192.168.122.49 nfsserver.example.com nfsserver
[root@node1 ~]# vi /etc/hosts ( edit in NODE1,NODE2 and nfsserver )
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.122.49 nfsserver.example.com nfsserver
192.168.122.50 node1.example.com node1
192.168.122.51 node2.example.com node2
##### Stop Firewall in NODE1,NODE2 and nfsserver #######
[root@node1 ~]# iptables -F
[root@node1 ~]# iptables -F -t nat
[root@node1 ~]# systemctl stop firewalld
[root@node1 ~]# systemctl disable firewalld
[root@node1 ~]# systemctl stop NetworkManager
[root@node1 ~]# systemctl disable NetworkManager
[root@node1 ~]# vi /etc/sysconfig/selinux (Change SELINUX )
SELINUX=enforcing to disabled
[root@node1 ~]# init 6
########### NFS Server install require nfs packegs #####################
[root@nfsserver ~]# cat /etc/yum.repos.d/yum.repo
[server]
name=server
baseurl=file:///mnt/
gpgcheck=0
enabled=1
[root@nfsserver ~]# mount /dev/sr0 /mnt/
[root@nfsserver ~]# yum install nfs* vim telnet net-tools mariadb* -y
[root@nfsserver ~]# mkdir /nfsmariadb
[root@nfsserver ~]# vim /etc/export ( edit below line )
/nfsmariadb 192.168.122.50(rw,sync,no_subtree_check,no_root_squash) 192.168.122.51(rw,sync,no_subtree_check,no_root_squash)
[root@nfsserver ~]# chmod -R 777 /nfsmariadb
[root@nfsserver ~]# chown -R mysql:mysql /nfsmariadb
[root@nfsserver ~]# systemctl restart nfs-server
[root@nfsserver ~]# systemctl enable nfs-server
Step-1 ( install require packegs in NODE1,NODE2 )
[root@node1 ~]# cat /etc/yum.repos.d/yum.repo
[server]
name=server
baseurl=file:///mnt/
gpgcheck=0
enabled=1
[centos-7-base]
name=CentOS
baseurl=http://mirror.centos.org/centos/7.6.1810/os/x86_64/
gpgcheck=0
enabled=1
[root@node1 ~]# mount /dev/sr0 /mnt/
[root@node1 ~]# yum install pacemaker pcs vim telnet net-tools mariadb* -y
[root@node1 ~]# mount 192.168.122.49:/nfsmariadb /var/lib/mysql
[root@node1 ~]# systemctl restart mariadb
[root@node1 ~]# systemctl stop mariadb
[root@node1 ~]# vim /etc/my.cnf ( add this line )
bind-address=192.168.122.52
Step-2 (In order to use pcs to configure the cluster and communicate among the nodes, you must set a password on each node for the user ID hacluster, which is the pcs administration account. It is recommended that the password for user hacluster be the same on each node. )
[root@node1 ~]# passwd hacluster
Changing password for user hacluster.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
Step-3 ( restart services in both node )
[root@node1 ~]# systemctl start pcsd.service
[root@node1 ~]# systemctl enable pcsd.service
Step-4 (Check the Authentcation by any node)
[root@node1 ~]# pcs cluster auth node1.example.com node2.example.com
Username: hacluster
Password:
node2.example.com: Authorized
node1.example.com: Authorized
Step-5 (Create Cluster )
[root@node1 ~]# pcs cluster setup --start --name mariadb node1.example.com node2.example.com
Destroying cluster on nodes: node1.example.com, node2.example.com...
node2.example.com: Stopping Cluster (pacemaker)...
node1.example.com: Stopping Cluster (pacemaker)...
node2.example.com: Successfully destroyed cluster
node1.example.com: Successfully destroyed cluster
Sending 'pacemaker_remote authkey' to 'node1.example.com', 'node2.example.com'
node1.example.com: successful distribution of the file 'pacemaker_remote authkey'
node2.example.com: successful distribution of the file 'pacemaker_remote authkey'
Sending cluster config files to the nodes...
node1.example.com: Succeeded
node2.example.com: Succeeded
Starting cluster on nodes: node1.example.com, node2.example.com...
node1.example.com: Starting Cluster (corosync)...
node2.example.com: Starting Cluster (corosync)...
node2.example.com: Starting Cluster (pacemaker)...
node1.example.com: Starting Cluster (pacemaker)...
Synchronizing pcsd certificates on nodes node1.example.com, node2.example.com...
node2.example.com: Success
node1.example.com: Success
Restarting pcsd on the nodes in order to reload the certificates...
node2.example.com: Success
node1.example.com: Success
Step-6 ( Enable the cluster services to run on each node in the cluster when the node is booted. )
[root@node1 ~]# pcs cluster enable --all
node1.example.com: Cluster Enabled
node2.example.com: Cluster Enabled
Step-7 ( Check your Cluster Status )
[root@node1 ~]# pcs cluster status
Cluster Status:
Stack: corosync
Current DC: node2.example.com (version 1.1.19-8.el7-c3c624ea3d) - partition with quorum
Last updated: Thu Feb 14 17:28:52 2019
Last change: Thu Feb 14 17:09:24 2019 by hacluster via crmd on node2.example.com
2 nodes configured
0 resources configured
PCSD Status:
node1.example.com: Online
node2.example.com: Online
Step-7 ( Create resource )
[root@node1 ~]# pcs property set no-quorum-policy=ignore
[root@node1 ~]# pcs resource defaults migration-threshold=2
[root@node1 ~]# pcs property set stonith-enabled=false
[root@node1 ~]# pcs resource create MariaDB_VIP ocf:heartbeat:IPaddr2 ip=192.168.122.52 cidr_netmask=24 op monitor interval=30s
[root@node1 ~]# pcs resource create MariaDB_New service:mariadb op start timeout=59s op stop timeout=60s op monitor interval=20s timeout=30s
[root@node1 ~]# pcs constraint colocation add MariaDB_VIP with MariaDB_New INFINITY
[root@node1 ~]# pcs constraint order MariaDB_VIP then MariaDB_New
Step-8
Create Group and add resource
[root@node1 ~]# pcs resource group add mysql MariaDB_VIP MariaDB_New
[root@node1 ~]# pcs status
(Testing the Resource Configuration)
1. The following command puts node node1.example.com in standby mode.
[root@node1 ~]# pcs cluster standby node1.example.com
2. To remove node1 from standby mode, enter the following command.
[root@node1 ~]# pcs cluster unstandby node1.example.com
I have use 2 node cluster with nfsserver (NODE1,NODE2 and nfsserver ) OS RHEL7.6 Minimal Install
IP 192.168.122.50 node1.example.com node1
IP 192.168.122.51 node2.example.com node2
IP 192.168.122.49 nfsserver.example.com nfsserver
[root@node1 ~]# vi /etc/hosts ( edit in NODE1,NODE2 and nfsserver )
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.122.49 nfsserver.example.com nfsserver
192.168.122.50 node1.example.com node1
192.168.122.51 node2.example.com node2
##### Stop Firewall in NODE1,NODE2 and nfsserver #######
[root@node1 ~]# iptables -F
[root@node1 ~]# iptables -F -t nat
[root@node1 ~]# systemctl stop firewalld
[root@node1 ~]# systemctl disable firewalld
[root@node1 ~]# systemctl stop NetworkManager
[root@node1 ~]# systemctl disable NetworkManager
[root@node1 ~]# vi /etc/sysconfig/selinux (Change SELINUX )
SELINUX=enforcing to disabled
[root@node1 ~]# init 6
########### NFS Server install require nfs packegs #####################
[root@nfsserver ~]# cat /etc/yum.repos.d/yum.repo
[server]
name=server
baseurl=file:///mnt/
gpgcheck=0
enabled=1
[root@nfsserver ~]# mount /dev/sr0 /mnt/
[root@nfsserver ~]# yum install nfs* vim telnet net-tools mariadb* -y
[root@nfsserver ~]# mkdir /nfsmariadb
[root@nfsserver ~]# vim /etc/export ( edit below line )
/nfsmariadb 192.168.122.50(rw,sync,no_subtree_check,no_root_squash) 192.168.122.51(rw,sync,no_subtree_check,no_root_squash)
[root@nfsserver ~]# chmod -R 777 /nfsmariadb
[root@nfsserver ~]# chown -R mysql:mysql /nfsmariadb
[root@nfsserver ~]# systemctl restart nfs-server
[root@nfsserver ~]# systemctl enable nfs-server
Step-1 ( install require packegs in NODE1,NODE2 )
[root@node1 ~]# cat /etc/yum.repos.d/yum.repo
[server]
name=server
baseurl=file:///mnt/
gpgcheck=0
enabled=1
[centos-7-base]
name=CentOS
baseurl=http://mirror.centos.org/centos/7.6.1810/os/x86_64/
gpgcheck=0
enabled=1
[root@node1 ~]# mount /dev/sr0 /mnt/
[root@node1 ~]# yum install pacemaker pcs vim telnet net-tools mariadb* -y
[root@node1 ~]# mount 192.168.122.49:/nfsmariadb /var/lib/mysql
[root@node1 ~]# systemctl restart mariadb
[root@node1 ~]# systemctl stop mariadb
[root@node1 ~]# vim /etc/my.cnf ( add this line )
bind-address=192.168.122.52
Step-2 (In order to use pcs to configure the cluster and communicate among the nodes, you must set a password on each node for the user ID hacluster, which is the pcs administration account. It is recommended that the password for user hacluster be the same on each node. )
[root@node1 ~]# passwd hacluster
Changing password for user hacluster.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
Step-3 ( restart services in both node )
[root@node1 ~]# systemctl start pcsd.service
[root@node1 ~]# systemctl enable pcsd.service
Step-4 (Check the Authentcation by any node)
[root@node1 ~]# pcs cluster auth node1.example.com node2.example.com
Username: hacluster
Password:
node2.example.com: Authorized
node1.example.com: Authorized
Step-5 (Create Cluster )
[root@node1 ~]# pcs cluster setup --start --name mariadb node1.example.com node2.example.com
Destroying cluster on nodes: node1.example.com, node2.example.com...
node2.example.com: Stopping Cluster (pacemaker)...
node1.example.com: Stopping Cluster (pacemaker)...
node2.example.com: Successfully destroyed cluster
node1.example.com: Successfully destroyed cluster
Sending 'pacemaker_remote authkey' to 'node1.example.com', 'node2.example.com'
node1.example.com: successful distribution of the file 'pacemaker_remote authkey'
node2.example.com: successful distribution of the file 'pacemaker_remote authkey'
Sending cluster config files to the nodes...
node1.example.com: Succeeded
node2.example.com: Succeeded
Starting cluster on nodes: node1.example.com, node2.example.com...
node1.example.com: Starting Cluster (corosync)...
node2.example.com: Starting Cluster (corosync)...
node2.example.com: Starting Cluster (pacemaker)...
node1.example.com: Starting Cluster (pacemaker)...
Synchronizing pcsd certificates on nodes node1.example.com, node2.example.com...
node2.example.com: Success
node1.example.com: Success
Restarting pcsd on the nodes in order to reload the certificates...
node2.example.com: Success
node1.example.com: Success
Step-6 ( Enable the cluster services to run on each node in the cluster when the node is booted. )
[root@node1 ~]# pcs cluster enable --all
node1.example.com: Cluster Enabled
node2.example.com: Cluster Enabled
Step-7 ( Check your Cluster Status )
[root@node1 ~]# pcs cluster status
Cluster Status:
Stack: corosync
Current DC: node2.example.com (version 1.1.19-8.el7-c3c624ea3d) - partition with quorum
Last updated: Thu Feb 14 17:28:52 2019
Last change: Thu Feb 14 17:09:24 2019 by hacluster via crmd on node2.example.com
2 nodes configured
0 resources configured
PCSD Status:
node1.example.com: Online
node2.example.com: Online
Step-7 ( Create resource )
[root@node1 ~]# pcs property set no-quorum-policy=ignore
[root@node1 ~]# pcs resource defaults migration-threshold=2
[root@node1 ~]# pcs property set stonith-enabled=false
[root@node1 ~]# pcs resource create MariaDB_VIP ocf:heartbeat:IPaddr2 ip=192.168.122.52 cidr_netmask=24 op monitor interval=30s
[root@node1 ~]# pcs resource create MariaDB_New service:mariadb op start timeout=59s op stop timeout=60s op monitor interval=20s timeout=30s
[root@node1 ~]# pcs constraint colocation add MariaDB_VIP with MariaDB_New INFINITY
[root@node1 ~]# pcs constraint order MariaDB_VIP then MariaDB_New
Step-8
Create Group and add resource
[root@node1 ~]# pcs resource group add mysql MariaDB_VIP MariaDB_New
[root@node1 ~]# pcs status
(Testing the Resource Configuration)
1. The following command puts node node1.example.com in standby mode.
[root@node1 ~]# pcs cluster standby node1.example.com
2. To remove node1 from standby mode, enter the following command.
[root@node1 ~]# pcs cluster unstandby node1.example.com
Comments
Post a Comment