docker 搭建 keepalived 实现 nginx 双机热备
1 | ❯ docker run --privileged -d --name node1 debian:11 top -b |
–-privileged
是指以特权模式启动容器,否则 keepalived 无法成功生成虚拟 IP
分别进入 node1、node2 容器节点(docker exec -it node1 /bin/bash
和 docker exec -it node2 /bin/bash
)
安装以下软件 apt update && apt install curl vim iproute2 inetutils-ping psmisc net-tools systemctl nginx keepalived -y