keepalived
Introduction
Keepalived
is a service software that guarantees the high availability of the cluster in cluster management. Its function is similar to heartbeat to prevent single points of failure.
working principle
Keepalived is based on the VRRP protocol. VRRP stands for Virtual Router Redundancy Protocol , that is, virtual router redundancy protocol .
Keepalived mainly has three modules, namely core, check and vrrp .
-
The core module
is the core of keepalived, responsible for the startup and maintenance of the main process and the loading and analysis of global configuration files. -
check
is responsible for health checks, including various common check methods. -
The vrrp module
is to implement the VRRP protocol.
Environmental preparation centos6 two [firewall closed]
Master master 192.168.1.101
backup backup 192.168.1.103
Perform installation on master
yum -y install keepalived
The yum source occupancy situation appears yum
occupancy solution——rm -rf /var/run/yum.pid
Modify the configuration file
vim /etc/keepalived/keepalived.conf
In line 4, execute 8dd and leave
the service name in
line 8 and the default network card in
line 9 and the weight of the default network card in line 11.
Others remain intact
18 lines are modified to the unoccupied ip of the network segment [master and backup are the same]
22 lines to modify this machine ip and port
27 perform row dd, renderings as
29 row change local ip and port
31 and the check lines modified protocol
execution 8dd, and add the port number connect_port 3306
after deleting all rows useless 37
Save and exit, restart, view vip
ip a
Execute on backup
After installation, modify basically the same. Pay attention to a few points-the weight
of the service name of the 8 line and the
11 line of the VIP is less than 100. The ip of the 29 line is the local ip of the backup, and the others are unchanged
Save and exit, restart, stop master to view VIP
ip a