阿里云ECS服务器,从零搭建 docker服务环境

一、如果有额外购买数据盘,先查看这一篇
【阿里云】如何挂载阿里云ESC购买的数据盘

二、
#查询SELinux的运行模式(关闭模式)
getenforce

SELinux三种模式简介
Enforcing:强制模式。代表SELinux在运行中,且已经开始限制domain/type之间的验证关系
Permissive:宽容模式。代表SELinux在运行中,不过不会限制domain/type之间的验证关系,即使验证不正确,进程仍可以对文件进行操作。不过如果验证不正确会发出警告
Disabled:关闭模式。SELinux并没有实际运行
————————————————

三、安装包

# 安装 阿里云的镜像源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

yum install epel-release -y

# 安装 zabbix 的镜像源
rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm

# 安装 zabbix 的命令补充插件
yum install bash-completion -y

yum install bash-completion-extras -y

yum -y update

四、搭建服务器

1-0、阿里云主机设置swap,防止OOM Killer
https://blog.csdn.net/weixin_42697074/article/details/104028459

1-1、更改 /ect/sysctl.conf 配置,并 sysctl -p 加载启用

如下:

fs.file-max = 1000000
vm.swappiness = 20
kernel.sysrq = 1
vm.overcommit_memory = 1
vm.max_map_count = 655360
kernel.pid_max = 1000000
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304
net.ipv4.tcp_max_syn_backlog = 102400
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_fin_timeout = 20
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.neigh.default.gc_stale_time = 120
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_announce = 2
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_keepalive_probes = 10
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 102400
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

1-2、安装 docker 
https://blog.csdn.net/weixin_42697074/article/details/102978629

1-3、修改 docker 默认工作目录(迁移 /var/lib/docker 目录)
https://blog.csdn.net/weixin_42697074/article/details/103142768

1-4、docker 镜像加速
https://blog.csdn.net/weixin_42697074/article/details/103782406

1-5、设置 swarm
https://blog.csdn.net/weixin_42697074/article/details/103472892

1-6、重启docker  systemctl restart docker 

1-7、配置基于docker容器的springCloud微服务的磁盘使用空间大小
https://blog.csdn.net/weixin_42697074/article/details/105688078


1-8、【docker系列】在Linux系统上安装 docker-compose
https://blog.csdn.net/weixin_42697074/article/details/105813391

你可能感兴趣的:(阿里云,docker)