由此处看出是未知字符,确定了位置为interface,进入配置文件进行修改
整个配置文件实验配置入下
实验环境:
server1:ens33 192.168.10.19 ens34 192.168.10.140
server2:192.168.10.20
server1配置
[root@localhost ~]# vim /etc/keepalived/keepalived.conf
!Configuration File for keepalived
global_defs {
router_id 1
}
#vrrp_script_nginx {
#script "/etc/keepalived/ck_ng.sh"
#interval 2
#weight -5
#fall 3
}
vrrp_instance VI_1 {
state MASTER
interface ens34
mcast_src_ip 192.168.10.19
virtual_router_id 55
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
192.168.10.140
}
#track_script {
#chk_nginx
#}
}
server2 修改IP地址,router_id,优先级即可
配置Nginx
[root@web1 ~]#yum -y install nginx #下载Nginx
[root@web1 ~]# vim /usr/share/nginx/html/index.html #修改展示主页
[root@web1 ~]#systemctl start nginx #开启Nginx服务
[root@web1 ~]#systemctl enable nginx #设置开机自启
启动keepaived
systemctl start keepalived
systemctl enable keealived