栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

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

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

一、基础环境安装
如果你不想太麻烦,可以采用一台机器实现分布式,也是可以的按第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

b) 创建docker swarm集群环境

输入ifconfig查看centos的网络情况,如果是云环境那么他有公网IP和私网IP,公网IP是私网IP的一个映射,我们只需要获取私网IP就可以的,我的华为云私网IP是192开头的,如下图

可以知道我的IP是192.168.0.163。
创建集群主节点:
docker swarm init --advertise-addr 192.168.0.163

验证集群节点

至此,单个节点的docker swarm 分布式节点已经完成,下节介绍多节点docker swarm部署

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/751256.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号