概述
#####lb1
$ docker run --privileged -itd --name lb1 osixia/keepalived:2.0.20 bash
$ docker exec -it lb1 bash
$ vi /usr/local/etc/keepalived/keepalived.conf
global_defs {
default_interface eth0
}
vrrp_instance VI_1 {
interface eth0
state BACKUP
virtual_router_id 51
priority 150
nopreempt
unicast_peer {
172.17.0.6 #### lb2的IP, 可以用ifconfig看lb2的IP
}
virtual_ipaddress {
172.17.0.100 #### VIP,可任意
}
authentication {
auth_type PASS
auth_pass d0cker
}
notify "/container/service/keepalived/assets/notify.sh"
}
$ ps aux|grep keepalived ## 找到pid
$ kill -HUP `$PID`
#####lb2
$ docker run --privileged -itd --name lb2 osixia/keepalived:2.0.20 bash
$ docker exec -it lb2 bash
$ vi /usr/local/etc/keepalived/keepalived.conf
global_defs {
default_interface eth0
}
vrrp_instance VI_1 {
interface eth0
state BACKUP
virtual_router_id 51
priority 150
nopreempt
unicast_peer {
172.17.0.5 #### lb1的IP, 可以用ifconfig看lb1的IP
}
virtual_ipaddress {
172.17.0.100 #### VIP,可任意
}
authentication {
auth_type PASS
auth_pass d0cker
}
notify "/container/service/keepalived/assets/notify.sh"
}
$ ps aux|grep keepalived ## 找到pid
$ kill -HUP `$PID`
$ ip addr ##### 查看VIP是否在该机器上
最后
以上就是安静钢笔为你收集整理的Mac下使用Docker安装Keepalived的全部内容,希望文章能够帮你解决Mac下使用Docker安装Keepalived所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复