1. Basic understanding
1. The difference between Heartbeat and Keepalived
The vrrp protocol used by Keepalived, Virtual Router Redundancy Protocol (VRRP);
Heartbeat is a high-availability method for services based on host or network;
The purpose of keepalived is to simulate the dual-machine of the router.
The purpose of heartbeat is the dual-machine of the user service.
High availability of lvs is recommended to use keepavlived
high availability of business use heartbeat
heartbeat hasMain-standby mode, dual-main mode
2. Heartbeat main configuration file
ha.cf Parameter configuration file
authkey authentication file
haresource resources Configuration files, such as configuring ip resources and script programs
3. Expansion: configure two ips for one network card interface
[[emailprotected] ~]# cd /etc/sysconfig/network-scripts/
[[emailprotected] network-scripts]# vim ifcfg-ens33:0
DEVICE=ens33:0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.40.222
NETMASK=255.255.255.0
GATEWAY=192.168.40.1
2. Source installation
1. Setting up the environment
#hostnamectl set-hostname master (132) ——> 192.168.40.2 21 (heartbeat line)
#hostnamectl set-hostname slave (211) ——-> 192.168.40.220 (heartbeat line)
vip :192.168.40.222 (Follow-up operations will be listed temporarily)
[[email protected] ~]# vim /etc/hosts
192.168.40.132 master
192.168.40.211 slave
Turn off the firewall, selinux
2,
< p align="left">vim /usr/local/heartbeat/etc/ha.d/ha.cf
vim /usr/local/heartbeat/etc/ha.d/ authkeys
vim /usr/local/heartbeat/etc/ha.d/haresources
[[email protected] ~]# vim /usr/share/nginx/html/index.html (modify the homepage file to distinguish it)