使用Docker搭建LVS的DR模型

LVS模型搭建

docker 搭建 参见 linux上搭建docker服务

1. 使用docker创建LVS环境

按照步骤一步一步来,基本都会成功的

1.1 使用docker创建服务器

负载均衡服务器-lvs-server

Dockerfile

FROM centos:7
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]
ADD conf/ipvsadm /etc/sysconfig/
RUN yum -y install net-tools
RUN yum -y install ipvsadm
RUN yum install -y gcc make vim ipvsadm iproute2
EXPOSE 80
CMD ["/usr/sbin/init"]

conf/ipvsadm文件内容

# Unload modules on restart and stop
#   Value: yes|no,  default: yes
# This option has to be 'yes' to get to a sane state for a ipvs
# restart or stop. Only set to 'no' if there are problems unloading ipvs
# modules.
IPVS_MODULES_UNLOAD="yes"

# Save current ipvs rules on stop.
#   Value: yes|no,  default: no
# Saves all ipvs rules to /etc/sysconfig/ipvsadm if ipvsadm gets stopped
# (e.g. on system shutdown).
IPVS_SAVE_ON_STOP="no"

# Save current ipvs rules on restart.
#   Value: yes|no,  default: no
# Saves all ipvs rules to /etc/sysconfig/ipvsadm if ipvsadm gets
# restarted.
IPVS_SAVE_ON_RESTART="no"

# Numeric status output
#   Value: yes|no,  default: yes
# Print IP addresses and port numbers in numeric format in the status output.
IPVS_STATUS_NUMERIC="yes"

镜像构建命令

$ docker build --rm -t local/c7-ipvs .

启动命令

$ docker run -d -it --privileged -p 80:8
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值