Official website
http://www.keepalived.org/
[Introduction]
keepalived is a software similar to the layer3, 4 & 5 switching mechanism, which is what we usually call layer 3, layer 4 and layer 5 switching. The function of Keepalived is to detect the status of the web server. If a web server crashes or fails to work, Keepalived will detect and remove the faulty web server from the system. When the web server works normally, Keepalived will automatically delete the web server. After joining the server group, all these tasks are completed automatically without manual intervention. All that needs to be done manually is to repair the faulty web server.
[Function]
It is mainly used for the health status check of RealServer and the implementation of failover between LoadBalance host and BackUP host.
[Dependent library]
ubuntu
apt-get install gcc openssl libpopt-dev libssl-dev
centos
yum install popt-devel openssl-devel popt-devel
./configure --prefix=/application/search/usr/keepalived-1.2.12
make
make install
creates a temporary directory
mkdir -p /application/search/usr/keepalived-1.2.12
[configuration file]
#Global, optional email notification
global_defs {
router_id app_dev
} #Check
, optional
# killall -0 haproxy
# If the haproxy process exists, return null
# If the haproxy process does not exist, return haproxy: no process killed
vrrp_script chk_haproxy { # Requires keepalived-1.1.13
script "killall -0 haproxy"
interval 1 # check every 10 seconds
weight -20 # if failed, decrease 40 of the priority
fall 1 # require 2 failures for failures
rise 1 # require 1 sucesses for ok
}
#host config (server 1)
vrrp_instance VI_1 {
state MASTER #MASTER/BACKUP
interface eth1
virtual_router_id 51 #If multiple virtual_ipaddresses are configured in one configuration file, they cannot be the same, for example vrrp_instance ip_253
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.56.254
}
#Optional
track_script {
chk_haproxy
}
}
vrrp_instance ip_253 {
state BACKUP
interface eth1
virtual_router_id 52
priority 70
advert_int 1
authentication {
auth_type PASS
auth_pass open
}
virtual_ipaddress {
192.168.56.253
}
} #Standby
configuration (server 2)
vrrp_instance VI_1 {
state BACKUP
interface eth1
virtual_router_id 51
priority 50
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.56.99
192.168.56.100
}
}
View log
tail - 200f /var/log/messages | grep Keepalived_vrrp
appendix
[centos adds log output]
First close selinux, refer to http://phl.iteye.com/blog/1981141
Set
/etc/rsyslog.conf
to add
local4.* /data0/search/keepalived/log/keepalived.log
Restart
service rsyslog stop
service rsyslog start
Test log output
logger -p local4.info 'test log print by piaohailin'
View log
tail - 200f /data0/search/keepalived/log/keepalived.log
start./sbin/keepalived
-f /root/keepalived-1.2.12/etc/keepalived/keepalived.conf -D -S 4
-D is to let keepalived log in detail
-d is to print the configuration information read by keepalived in the log
-S 4 is to send the log to syslog when it arrives, and the log is set to LOCAL4
[Reference]
Excellent tutorial: operation and maintenance world, very comprehensive
http://bbs.ywlm .net/thread-845-1-1.html
Installation error debugging reference
http://www.ttlsa.com/html/299.html
Shared library solution reference
http://blog.sina.com.cn/s/blog_54f82cc201011ve4.html
keepalived installation
http://wenku.baidu. com/view/15b996cf08a1284ac8504373.html
keepalived check
http://blog.sina.com.cn/s/blog_5374d6e30100sdne.html
[Error debugging]
configure: error: Popt libraries is required
centos: yum install popt-devel
ubuntu: apt-get install libpopt-dev
set library environment variable
LDFLAGS linker flags, eg -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
CPPFLAGS (Objective) C/C++ preprocessor flags, eg -I<include dir> if
you have headers in a nonstandard directory <include dir>
export LDFLAGS="-L/root/openssl-0.9.8x/lib"
export CPPFLAGS="-I/root/openssl-0.9.8x/include"
export LD_LIBRARY_PATH=/root/openssl-0.9.8x/lib:$LD_LIBRARY_PATH
包扫描
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/root/openssl-0.9.8x/lib/pkgconfig
http://www.keepalived.org/
[Introduction]
keepalived is a software similar to the layer3, 4 & 5 switching mechanism, which is what we usually call layer 3, layer 4 and layer 5 switching. The function of Keepalived is to detect the status of the web server. If a web server crashes or fails to work, Keepalived will detect and remove the faulty web server from the system. When the web server works normally, Keepalived will automatically delete the web server. After joining the server group, all these tasks are completed automatically without manual intervention. All that needs to be done manually is to repair the faulty web server.
[Function]
It is mainly used for the health status check of RealServer and the implementation of failover between LoadBalance host and BackUP host.
[Dependent library]
ubuntu
apt-get install gcc openssl libpopt-dev libssl-dev
centos
yum install popt-devel openssl-devel popt-devel
./configure --prefix=/application/search/usr/keepalived-1.2.12
make
make install
creates a temporary directory
mkdir -p /application/search/usr/keepalived-1.2.12
[configuration file]
#Global, optional email notification
global_defs {
router_id app_dev
} #Check
, optional
# killall -0 haproxy
# If the haproxy process exists, return null
# If the haproxy process does not exist, return haproxy: no process killed
vrrp_script chk_haproxy { # Requires keepalived-1.1.13
script "killall -0 haproxy"
interval 1 # check every 10 seconds
weight -20 # if failed, decrease 40 of the priority
fall 1 # require 2 failures for failures
rise 1 # require 1 sucesses for ok
}
#host config (server 1)
vrrp_instance VI_1 {
state MASTER #MASTER/BACKUP
interface eth1
virtual_router_id 51 #If multiple virtual_ipaddresses are configured in one configuration file, they cannot be the same, for example vrrp_instance ip_253
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.56.254
}
#Optional
track_script {
chk_haproxy
}
}
vrrp_instance ip_253 {
state BACKUP
interface eth1
virtual_router_id 52
priority 70
advert_int 1
authentication {
auth_type PASS
auth_pass open
}
virtual_ipaddress {
192.168.56.253
}
} #Standby
configuration (server 2)
vrrp_instance VI_1 {
state BACKUP
interface eth1
virtual_router_id 51
priority 50
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.56.99
192.168.56.100
}
}
View log
tail - 200f /var/log/messages | grep Keepalived_vrrp
appendix
[centos adds log output]
First close selinux, refer to http://phl.iteye.com/blog/1981141
Set
/etc/rsyslog.conf
to add
local4.* /data0/search/keepalived/log/keepalived.log
Restart
service rsyslog stop
service rsyslog start
Test log output
logger -p local4.info 'test log print by piaohailin'
View log
tail - 200f /data0/search/keepalived/log/keepalived.log
start./sbin/keepalived
-f /root/keepalived-1.2.12/etc/keepalived/keepalived.conf -D -S 4
-D is to let keepalived log in detail
-d is to print the configuration information read by keepalived in the log
-S 4 is to send the log to syslog when it arrives, and the log is set to LOCAL4
[Reference]
Excellent tutorial: operation and maintenance world, very comprehensive
http://bbs.ywlm .net/thread-845-1-1.html
Installation error debugging reference
http://www.ttlsa.com/html/299.html
Shared library solution reference
http://blog.sina.com.cn/s/blog_54f82cc201011ve4.html
keepalived installation
http://wenku.baidu. com/view/15b996cf08a1284ac8504373.html
keepalived check
http://blog.sina.com.cn/s/blog_5374d6e30100sdne.html
[Error debugging]
configure: error: Popt libraries is required
centos: yum install popt-devel
ubuntu: apt-get install libpopt-dev
set library environment variable
LDFLAGS linker flags, eg -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
CPPFLAGS (Objective) C/C++ preprocessor flags, eg -I<include dir> if
you have headers in a nonstandard directory <include dir>
export LDFLAGS="-L/root/openssl-0.9.8x/lib"
export CPPFLAGS="-I/root/openssl-0.9.8x/include"
export LD_LIBRARY_PATH=/root/openssl-0.9.8x/lib:$LD_LIBRARY_PATH
包扫描
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/root/openssl-0.9.8x/lib/pkgconfig