This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ===== HA with CentOS and RedHat and like ===== ==== Environment ==== Install two servers with one IP virtual and shared storage: {{::diagramahadb2.png|}} * Server1: **ext1** with IP **192.168.122.113** * Server2: **ext2** with IP **192.168.122.53** * IP virtual: **192.168.122.70** * Shared storage on device **/dev/sda** mounted on **/home/db2** * HA user named hacluster with password manager Tested on CentOS 7.5. Some exceptions for testing on RHEL 7.3. ==== Install software ==== On both nodes: Configure **/etc/hosts**: <code> 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.122.113 ext1 192.168.122.53 ext2 192.168.122.70 ext </code> Install and enable pacemaker: <code> $ sudo yum install pcs fence-agents-all -y $ sudo systemctl disable firewalld $ sudo systemctl stop firewalld $ sudo passwd hacluster $ sudo systemctl start pcsd.service $ sudo systemctl enable pcsd.service $ sudo lvmconf --enable-halvm --services --startstopservices </code> If you prefer get working the firewall: <code> $ sudo firewall-cmd --permanent --add-service=high-availability $ sudo firewall-cmd --add-service=high-availability </code> If you are using RHEL you must enable HighAvailability. If you receive this message: <code> Unit lvm2-cluster-activation.service could not be found. Failed to execute operation: No such file or directory Failed to stop lvm2-cluster-activation.service: Unit lvm2-cluster-activation.service not loaded. </code> Use this steps: <code> $ sudo lvmconf --enable-halvm $ sudo systemctl disable lvm2-lvmetad $ sudo systemctl stop lvm2-lvmetad </code> On one node: Create one partition with fdisk and configure a physical group, a volume group and logical volume: <code> $ sudo pcs cluster auth ext1 ext2 $ sudo pcs cluster setup --start --name baccluster ext1 ext2 $ sudo pcs cluster enable --all $ sudo fdisk /dev/sda $ sudo pvcreate /dev/sda1 $ sudo vgcreate bacvg /dev/sda1 $ sudo lvcreate -L10G -n baclv bacvg $ sudo mkfs.ext4 /dev/mapper/bacvg-baclv </code> Edit **/etc/lvm/lvm.conf** and create or modify the line //volume_list = [ ]//, add all the vg that are outside the shared storage, in our case all except bacvg. For example: //volume_list = [ "centos" , "otro" ]// Execute on both nodes: <code> $ sudo dracut -H -f /boot/initramfs-$(uname -r).img $(uname -r) </code> On the other node: <code> $ sudo partprobe $ sudo pvscan $ sudo vgscan $ sudo lvscan </code> Validate that you can see the logical volume created on the other server. Reboot both nodes. On one node: <code> $ sudo pcs resource create bacip IPaddr2 ip=192.168.122.70 cidr_netmask=24 --group bacgroup $ sudo pcs resource create baclvm LVM volgrpname=bacvg exclusive=true --group bacgroup $ sudo pcs resource create bacfs Filesystem device="/dev/mapper/bacvg-baclv" directory="/home/db2/" fstype="ext4" --group bacgroup $ sudo pcs property set stonith-enabled=false $ sudo pcs property set no-quorum-policy=ignore </code> You can get cluster status with: <code> $ sudo pcs status </code> You can migrate resources between nodes <code> $ sudo pcs resource move bacgroup ext2 </code> If the resources migrates automatically to the node that you moved all resources, remove the location contraint with: <code> $ sudo pcs resource clear bacgroup </code> ==== Monitoring resources ==== The cluster can starts automatically resources if was stopped, this can be OK or not. If you want that the cluster doesn't monitor resources use this command to create it: <code> pcs resource create bachttpd systemd:httpd op monitor enabled=false --group bacgroup </code> If the resource was created update it: <code> pcs resource update bachttpd op monitor enabled=false </code> ==== References ==== * https://www.itzgeek.com/how-tos/linux/centos-how-tos/configure-high-avaliablity-cluster-on-centos-7-rhel-7.html * https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/high_availability_add-on_administration/index * http://clusterlabs.org/pacemaker/doc/en-US/Pacemaker/1.1/html/Clusters_from_Scratch/_move_resources_manually.html ==== Icon credits ==== * https://www.flaticon.com/authors/nhor-phai * https://www.flaticon.com/authors/smashicons * http://www.freepik.com * https://www.flaticon.com/authors/twitter