Ubuntu64 apache2+lvs+Keepalived
安装 apache2, vim, keepalived 和 ipvsadm
打开 vim /etc/keepalived/keepalived.conf
点击 i, 进入编辑状态, 输入:
! Configuration File for keepalived global_defs { router_id LVSMaster } vrrp_instance VI_1 { state MASTER interface ens33 # 对外服务的网卡 virtual_router_id 100 #VRRP组名,两个节点的设置必须一样,以指明各个节点属于同一VRRP>组 priority 100 #主节点的优先级(1-254之间),备用节点必须比主节点优先级低 advert_int 1 #设置主备之间同步检查的时间间隔单位秒 authentication { #设置验证信息,两个节点必须一致 auth_type PASS auth_pass abcd123 } virtual_ipaddress { #指定虚拟IP, 两个节点设置必须一样 192.168.144.200 } } virtual_server 192.168.144.200 80 { delay_loop 6 lb_algo rr lb_kind DR persistence_timeout 0 protocol TCP real_server 192.168.144.128 80 { weight 1 TCP_CHECK { connect_timeout 10 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } }
然后点击 esc, 退出编辑, 输入 :wq 保持.
启动 service keepalived start
编辑 apache2 默认页 index.html
启动局域网访问 LVS: 192.168.144.200