@(技術-Linux)[Linux, Keepalived]tcp
①配置Keepalived的Mastercode
! Configuration File for keepalived global_defs { router_id LVS_DEVEL } vrrp_script chk_http_port { script "</dev/tcp/127.0.0.1/80" interval 1 weight -2 } vrrp_instance VI_1 { state MASTER interface enp0s31f6 virtual_router_id 51 priority 150 advert_int 1 mcast_src_ip 192.168.31.202 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.31.120 } track_script { chk_http_port } }
②配置Keepalived的Backuprouter
! Configuration File for keepalived global_defs { router_id LVS_DEVEL } vrrp_script chk_http_port { script "</dev/tcp/127.0.0.1/80" interval 1 weight -2 } vrrp_instance VI_1 { state BACKUP interface enp0s31f6 virtual_router_id 51 priority 100 advert_int 1 mcast_src_ip 192.168.31.201 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 192.168.31.120 } track_script { chk_http_port } }
③Keepalived啓動ip
/usr/local/keepalived/sbin/keepalived -D -f /usr/local/keepalived/etc/keepalived/keepalived.conf
④查看運行狀況it
ip addr