OS: AlmaLinux/RockyLinux minimal(VBox v6.1.38)
Virtual Box Network configure:
- Attached to
Bridged Adapter
- Advanced
promiscuous mode:
Allow All
一、安装
prepare tool:
- RHEL7
#yum install gcc make autoconf automake openssl-devel libnl3-devel \
iptables-devel ipset-devel net-snmp-devel libnfnetlink-devel file-devel \
glib2-devel pcre2-devel libnftnl-devel libmnl-devel systemd-devel kmod-devel
- RHEL8
powertools:
#dnf --enablerepo=powertools install ipset-devel libnfnetlink-devel file-devel libnftnl-devel kmod-devel pcre2-devel
none:
#dnf install gcc make autoconf automake openssl-devel libnl3-devel \
iptables-devel net-snmp-devel \
glib2-devel libmnl-devel systemd-devel git
LVS manager:
#dnf install ipvsadm
Reboot the machine so that kmod takes effect!
Otherwise, it will show:
Keepalived_healthcheckers[25270]: kmod_module_new_from_lookup failed - err 38
installation
state(vrrp_instance) - config:
- MASTER
Node 1 - BACKUP
Node 2
down and unzip
Released Version: 2.2.7
$git clone https://github.com/acassen/keepalived.git
for me:
$git clone https://gitee.com/xiaobin80/keepalived
installation
$cd keepalived
$./autogen.sh
configure:
$./configure --prefix=/usr
make:
$make
Root permission Required
#make install
setup
#mkdir -p /etc/keepalived
$sudo mv /etc/keepalived/keepalived.conf.sample /etc/keepalived/keepalived.conf
$sudo cp ./keepalived/etc/init.d/keepalived /etc/init.d/
$sudo chmod 755 /etc/init.d/keepalived
- test
$keepalived -v
Security Options
allow fire wall port:
#firewall-cmd --permanent --zone=public --add-port=80/tcp
#firewall-cmd --reload
selinux
#vi /etc/selinux/config
更改enforcing为disabled:
SELINUX=disabled
二、配置
Table 4.1. lv_algo Values for Virtual Server
Algorithm Name | lv_algo value |
---|---|
Round-Robin | rr |
Weighted Round-Robin | wrr |
Least-Connection | lc |
Weighted Least-Connection | wlc |
Locality-Based Least-Connection | lblc |
Locality-Based Least-Connection Scheduling with Replication | lblcr |
Destination Hash | dh |
Source Hash | sh |
Source Expected Delay | sed |
Never Queue | nq |
example
/etc/keepalived/keepalived.conf
global_defs {
max_auto_priority
}
vrrp_instance VI_1 {
state MASTER
interface enp0s3
virtual_router_id 49
priority 200
advert_int 1
authentication {
auth_type PASS
auth_pass passw123
}
virtual_ipaddress {
192.168.0.220/24
}
}
virtual_server 192.168.0.220 80 {
delay_loop 6
lb_algo wrr
lb_kind DR
persistence_timeout 9600
protocol TCP
real_server 192.168.0.127 80 {
weight 3
TCP_CHECK {
connect_timeout 10
retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 192.168.0.122 80 {
weight 1
TCP_CHECK {
connect_timeout 10
retry 3
delay_before_retry 3
connect_port 80
}
}
}
priority
- node 1
200
- node 2
150