Environmental information
Keepalived Master 192.168.1.106
Keepalived Backup 192.168.1.103
VIP 192.168.1.100
1, install keepalived, I use 1.1.17
TAR-ZVXF keepalived-1.1.17.tar.gz
CD keepalived-1.1.17
./configure
This step may encounter a lack of openssl,popt. If it's missing, you can install Yum.
#yum Install Openssl-devel
#yum Install Popt-devel
After compilation
Make
Make install
And then
/bin/cp/usr/local/etc/rc.d/init.d/keepalived/etc/init.d
/bin/cp/usr/local/etc/sysconfig/keepalived/etc/sysconfig/
/bin/cp/usr/local/etc/keepalived/keepalived.conf/etc/keepalived
/bin/cp/usr/local/sbin/keepalived/usr/sbin/
Modifying a configuration file
Draw the line where backup must not repeat
Backup needs to be aware
1,ROUTER_ID the only
2,state MASTER changed to backup. Capital
3,priority changed to 50. General recommended backup is 50 smaller than master. When Master hangs, it chooses the highest priority to act as master
4,VIRTUAL_ROUTER_ID 51. Be sure to agree with master. It's going to split up.
5. About the mail section, write down
Backup is configured as follows:
for Keepalivedglobal_defs { notification_email { [email protected] [email protected] [email Protected] } notification_email_from [email protected] 192.168.200.1 router_id lvs_devel_02}vrrp_instance vi_2 {State BACKUP interface eth1 Wuyi 1 authentication { auth_type PASS 1111 } virtual_ipaddress { 192.168.1.100/24 }}
/etc/init.d/keepalived start
Log default Path
/var/log/message
Look under the log found log has been flashing screen, the hint can ' t initialize Ipvs
This is because the Ipvs module is not loaded
Load it manually
Modprobe Ip_vs
Modprobe IP_VS_WRR
And then re-
/etc/init.d/keepalived start
Ps-ef | grep keep
Will find three processes
[Email protected] keepalived]# Ps-ef | grep keeproot 9276 8440 0 19:28 pts/1 00:00:00 vi keepalived.confroot 9490 1 1 19:40? 00:00:00 keepalived-d-d-s 0root 9492 9490 0 19:40? 00:00:00 keepalived-d-d-s 0root 9493 9490 0 19:40? 00:00:00 keepalived-d-d-s 0root 9496 8440 5 19:40 pts/1 00:00:00 grep keep
How to check if the VIP is in effect?
via the IP Add command
[[Email protected] keepalived]# IP add1:lo: <LOOPBACK,UP,LOWER_UP> MTU 16436qdisc noqueue State UNKNOWN Link/loopback 00:00:00:00:00:00 BRD 00:00:00:00:00:00inet127.0.0.1/8Scope host lo inet6::1/128Scope host Valid_lft forever Preferred_lft forever2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU qdisc pfifo_fast State UNKNOWN Qlen 1000Link/ether 00:0c:29: 4a:fb:1d BRD ff:ff:ff:ff:ff:ff inet192.168.1.106/24 BRD 192.168.1.255Scope global Eth0 inet192.168.1.100/24Scope Global secondary eth0 inet6 fe80::20c:29ff:fe4a:fb1d/64scope link Valid_lft forever Preferred_lft forever3:pan0: <BROADCAST,MULTICAST> MTU 1500Qdisc noop State down link/ether fe:c8:58:f7:2c:04 BRD FF:FF:FF:FF:FF:FF
Found that 192.168.1.100 is already tied to the NIC.
And then backup on the IP add again, the results are as follows
[[ Email protected] keepalived]# [[email protected] keepalived]# IP add1:lo: <LOOPBACK,UP,LOWER_UP> MTU 16436qdisc noqueue State UNKNOWN Link/loopback 00:00:00:00:00:00 BRD 00:00:00:00:00:00inet127.0.0.1/8Scope host lo inet6::1/128Scope host Valid_lft forever Preferred_lft forever2:eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU qdisc pfifo_fast State UNKNOWN Qlen 1000Link/ether 00:0c:29:25:98:10BRD ff:ff:ff:ff:ff:ff inet192.168.1.103/24 BRD 192.168.1.255Scope Global eth1 inet6 fe80::20c:29ff:fe25:9810/64scope link Valid_lft forever Preferred_lft forever5:pan0: <BROADCAST,MULTICAST> MTU 1500Qdisc noop State down link/ether e2:15:b8:9d:56: EB brd ff:ff:ff:ff:ff:ff[[email protected] keepalived]#
Notice that the VIP is not tied to the NIC, this is normal, if the backup VIP is also tied to the network card, it may be split brain
Then kill the keepalived on master and find that the VIP of the backup is bound to the NIC, which indicates the keepalived configuration is successful.
You can install Tomcat on both machines. Access the following files via 192.168.1.100
The next article combined with Nginx keepalived is how to use
Keepalived Balance Environment Construction