keepalived configuration file configuration information

yum install keepalived -y

#File
/etc/keepalived/keepalived.conf #keepalived service main configuration file
/etc/rc.d/init.d/keepalived #Service startup script
/etc/sysconfig/keepalived
/usr/bin/genhash
/usr/libexec/keepalived
/usr/sbin/keepalived
2. Deploy httpd (for example)
yum -y install httpd
systemctl start httpd

3. Test verification to see if the return corresponds
(host-1 operation)
echo "37" >> /var/ww/html/index.html
curl http://192.168.2.37

(host-2 operation)
echo "149" >> /var/ww/html/index.html
curl http://192.168.2.149

3.
Change the configuration of keepalived to the following, and delete the redundant part. For the specific meaning, see the detailed explanation of the keepalived configuration file

(host-1 operation)
1. Use host-1 as the main machine, modify and configure
vim /etc/keepalived/keepalived.conf

! Configuration File for keepalived

global_defs { #Global configuration
router_id lb01 #routing id number, cannot be repeated
}

vrrp_instance VI_1 { #Define an instance
state MASTER #The state parameter master/backup is just an explanation, specifically according to the priority
interface enp0s8 #The location of the network card placed by the virtual IP address
virtual_router_id 51 #The same cluster id is consistent
priority 100 #The priority determines whether it is the master or the backup The bigger the priority
advert_int 1 #Active-standby communication time interval
authentication { auth_type PASS auth_pass 1111 #Authentication number must be consistent in the cluster } virtual_ipaddress { 192.168.2.99 #The virtual ip used must not conflict with the ip in the network segment } } (host- 2 operation) 2. Use host-2 as the slave machine to modify the configuration








! Configuration File for keepalived

global_defs { router_id lb02 #change }

vrrp_instance VI_1 { state BACKUP #As a backup interface enp0s8 virtual_router_id 51 priority 90 #priority down advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.2.99 } } (both machines operate) 3. Start service systemctl start keepalived















Guess you like

Origin blog.csdn.net/qq_44912603/article/details/127427388