![关注抖音创业](https://img.kancloud.cn/c5/ce/c5ced2ea291122851697114ca415ff95_1125x1680.png) [TOC] # 更新依赖 ``` yum -y update yum install -y conntrack ipvsadm ipset jq sysstat curl iptables libseccomp ``` # 安装设置 ## 安装 * 卸载之前安装的docker ``` sudo yum remove docker docker latest docker-latest-logrotate \ docker-logrotate docker-engine docker-client docker-client-latest docker-common ``` * 安装依赖 ~~~ sudo yum install -y yum-utils device-mapper-persistent-data lvm2 ~~~ * 添加软件源信息 ~~~ sudo yum-config-manager \ --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo yum list | grep docker-ce ~~~ * 更新缓存 ~~~ sudo yum makecache fast ~~~ * 安装 ~~~ sudo yum install -y docker-ce-18.09.0 docker-ce-cli-18.09.0 containerd.io [指定安装docker版本] ~~~ * 启动docker并设置开机启动 ~~~ sudo systemctl start docker && sudo systemctl enable docker ~~~ * 安装校验 ~~~ docker version ~~~ * 实战测试 ~~~ sudo docker run hello-world ~~~ ## 设置hosts 01 `master` > 设置master的hostname,并且修改hosts文件 ~~~ sudo hostnamectl set-hostname m ~~~ 02 `机器` vi /etc/hosts 192.168.136.200 m 03 `使用ping测试一下` ping m # 系统设置 * 关闭防火墙 `systemctl stop firewalld && systemctl disable firewalld` * 关闭selinux ~~~ setenforce 0 sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config ~~~ * 关闭swap ~~~ swapoff -a sed -i '/swap/s/^\(.*\)$/#\1/g' /etc/fstab ~~~ * 配置iptables的ACCEPT规则 ~~~ iptables -F && iptables -X && iptables \ -F -t nat && iptables -X -t nat && iptables -P FORWARD ACCEPT ~~~ * 设置系统参数 ~~~ cat <<EOF > /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 EOF sysctl --system ~~~