1. Install the kernel and OpenSSL components first. Note that you must create a soft connection after installing the kernel.
# Kernel-devel
Yum install kernel-devel
# OpenSSL-devel
Yum install OpenSSL-devel
# Create slink from kernels
Ln-SV/usr/src/kernels/2.6.18-194. el5-i686 // usr/src/Linux
2. Install keepalived-1.2.1 on each server
#Keepalived-1.2.1.tar.gz
Wget http://www.keepalived.org/software/keepalived-1.2.1.tar.gz
Tar-zxvf keepalived-1.2.1.tar.gz
CD keepalived-1.2.1
./Configure
# Check Configure. You must see that:
# Use ipvs framework: Yes
# PVS sync daemon support: Yes
# Use vrrp framework: Yes
Make
Make install
CP/usr/local/etc/sysconfig/keepalived
CP/usr/local/sbin/keepalived/usr/sbin/keepalived
CP/usr/local/etc/rc. d/init. d/keepalived/etc/init. d/keepalived
# Keepalived. conf
Mkdir/etc/keepalived
# Keepalived. conf default configure
CP/usr/local/etc/keepalived/samples/keepalived. conf. virtualhost/etc/keepalived. conf
3. edit/etc/keepalived. conf.
Note the configuration
Virtual_ipaddress: virtual IP address list
Virtual_server, virtual host
Real_server, real host
Lb_algo, Server Load balancerAlgorithm
State, host status, Master is master, backup is from
# Vim/etc/keepalived. conf
Global_defs {
Notification_email {
Xxx@yyy.cn
}
Notification_email_from {
Xxx@yyy.cn
}
Smtp_server 127.0.0.1
# Smtp_connect_timeout 30
Router_id lvs_devel
}
Vrrp_instance vi_1 {
State master #121 set master, 122 & 123 set backup.
Interface eth0
Virtual_router_id 51
Priority100
Advert_int 1
Authentication {
Auth_type Mongo
Auth_pass 1111
}
Virtual_ipaddress {
172.17.0.124
}
}
Virtual_server 172.17.0.124 30000 {
Delay_loop 6
Lb_algo WRR # WRR or wlc
Lb_kind Dr
Persistence_timeout 60
Protocol TCP
# Virtualhost www. Firewall. loc # The virtualhost string to use
# In the get query.
Real_server 172.17.0.121 30000 {
Weight 5
Tcp_check {
Connect_timeout 10
Nb_get_retry 3
Delay_before_retry 3
Connect_port 30000
}
}
Real_server 172.17.0.122 30000 {
Weight 4
Tcp_check {
Connect_timeout 10
Nb_get_retry 3
Delay_before_retry 3
Connect_port 30000
}
}
Real_server 172.17.0.123 30000 {
Weight 4
Tcp_check {
Connect_timeout 10
Nb_get_retry 3
Delay_before_retry 3
Connect_port 30000
}
}
}
4. Start the keepalived service:/sbin/service keepalived start
You can view the tail/var/log/message logs.
5. The running of ipvsadm on Dog Day is unstable and often fails. I will not write it.