代码拉取完成,页面将自动刷新
#!/bin/bash
printf "==============》》开始搭建基础环境《《==============\n"
printf "1.开始关闭防火墙\n"
systemctl stop firewalld
systemctl disable firewalld
printf "防火墙已关闭\n"
printf "2.开始关闭 SeLinux\n"
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
printf "3.关闭swap交换区\n"
swapoff -a
yes | cp /etc/fstab /etc/fstab_bak
cat /etc/fstab_bak |grep -v swap > /etc/fstab
printf "4.开始安装yum并替换阿里云eoel源\n"
# 安装wget
yum install wget -y
# 备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# 获取阿里云yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 获取阿里云epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
# 清理缓存并创建新的缓存
yum clean all && yum makecache
# 系统更新
yum update -y
printf "5.同步时区,上海时区\n"
timedatectl set-timezone "Asia/Shanghai"
timedatectl
printf "\n"
# 安装 Docker CE
# 设置仓库
# 安装所需包
printf "6.开始安装docker需要的依赖\n"
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
# 新增 Docker 仓库,速度慢的可以换阿里云的源。
printf "7.新增 Docker 仓库,替换换阿里云的源\n"
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 官方源地址
# https://download.docker.com/linux/centos/docker-ce.repo
# 安装 Docker CE.
printf "8.安装 Docker CE\n"
yum install -y containerd.io-1.2.10 \
docker-ce-19.03.4 \
docker-ce-cli-19.03.4
# 启动 Docker 并添加开机启动
printf "9.启动 Docker 并添加开机启动\n"
systemctl start docker
systemctl enable docker
printf "10.修改 Cgroup Driver\n"
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2",
"registry-mirrors":[
"https://kfwkfulq.mirror.aliyuncs.com",
"https://2lqq34jg.mirror.aliyuncs.com",
"https://pee6w651.mirror.aliyuncs.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn",
"https://registry.docker-cn.com"
]
}
EOF
docker info|grep "Cgroup Driver"
mkdir -p /etc/systemd/system/docker.service.d
printf "11.重启docker\n"
# Restart docker.
systemctl daemon-reload
systemctl restart docker
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。