0
点赞
收藏
分享

微信扫一扫

基于docker swarm搭建分布式项目之(一)基础环境安装

小亦同学321 2022-03-11 阅读 67

一、基础环境安装
如果你不想太麻烦,可以采用一台机器实现分布式,也是可以的按第1小节伪分布式环境小节进行实操,如果你有多台机器或虚拟机可以按第2小节进行实操。
1伪分布式环境
可以购买1折的云服务器也可以采用vmare在本地虚拟出一台centos7服务器。本人购买的新用户1折的云服务器。
a)安装docker(离线)
下载docker安装包docker-18.06.3-ce.tgz。然后上传到/opt文件夹下。
在这里插入图片描述
执行解压命令,并拷贝到/usr/bin/文件夹下
tar xzvf docker-18.06.3-ce.tgz
cp -ar docker/* /usr/bin/
编辑docker.service文件并复制配置内容进去。
vi /usr/lib/systemd/system/docker.service

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target

加载配置并启动docker
systemctl daemon-reload
systemctl start docker.service
验证docker是否已安好
docker ps
在这里插入图片描述

举报

相关推荐

0 条评论