Switch back and forth between listening and replacing multiple servers
1. Installation
Tar zxvf keepalived-1.1.15.tar.gz
CD keepalived-1.1.15
./Configure -- prefix =/usr/local/keepalived
Make & make install
# This configuration is only for ease of use. You can skip this configuration.
--------------------------------------------------------------------------------
CP keepalived-1.1.15/etc/init. d/keepalived. RH. init/etc/init. d/keepalived
Chmod A + x/etc/init. d/keepalived
Keepalived-1.1.15/etc/init. d/keepalived. sysconfig/etc/sysconfig/keepalived
Chkconfig -- add keepalived
Chkconfig -- level 345 keepalived on
CP/usr/local/keepalived/sbin/keepalived/bin/
---------------------------------------------------------------------------------
Ii. Configuration
Mkdir/etc/keepalived
Vim/etc/keepalived. conf
Add the following content
# Global_defs {
# Icationication_email {
# [Email protected] # set alarm email addresses. You can set multiple email addresses, one per line. You must enable the sendmail service.
# [Email protected]
#}
# Icationication_email_from [email protected] # Set the mail sending Address
# Smtp_server localhost # Set the SMTP server address
# Smtp_connect_timeout 30 # Set the SMTP server timeout time
# Router_id lvs_devel # indicates an identifier for running the keepalived server. Information in the large mail subject is displayed when you send an email.
#}
Master server statement:
Vrrp_instance vi_1 {
State master # specify node A as the backup node of the master node.
Interface eth0 # network interface for binding virtual IP addresses
Mcast_src_ip 192.168.200.122 # local IP Address
Virtual_router_id 51 # vrrp group name. The two nodes must have the same settings to indicate that each node belongs to the same vrrp group.
Priority 100 # priority of the master node (between 1 and). The slave node must have a lower priority than the master node.
Advert_int 1 # interval for sending multicast information. The two nodes must have the same settings.
Authentication {# set verification information. The two nodes must be consistent.
Auth_type pass
Auth_pass 1111
}
Virtual_ipaddress {# specify the virtual IP address. The two node settings must be the same. You can write multiple
192.168.200.16
#192.168.200.17/24
#192.168.200.18/24
}
}
Slave server syntax
Vrrp_instance vi_1 {
State backup
Interface eth0
Mcast_src_ip 192.168.200.123
Virtual_router_id 51
Priority 90 # priority is lower than the master server
Advert_int 1
Authentication {
Auth_type pass
Auth_pass 1111
}
Virtual_ipaddress {
192.168.200.16
#192.168.200.17/24
#192.168.200.18/24
}
}
Iii. Start
Service keepalived start