实验环境配置

2019-07-02 14:39:04 浏览数 (1)

版权声明:本文为耕耘实录原创文章,各大自媒体平台同步更新。欢迎转载,转载请注明出处,谢谢。联系本人:ecsboy(微信),136625317(QQ) https://cloud.tencent.com/developer/article/1454628

实验环境配置

一 默认环境

1.1 操作系统

代码语言:javascript复制
[root@gysl-DevOps ~]# cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)

2.1 Swap 设置

代码语言:javascript复制
[root@gysl-DevOps ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           972M        182M        175M        7.6M        615M        571M
Swap:            0B          0B          0B

为了后期 Kubernetes 实验,在安装系统的时候关闭了 Swap 。

二 更改默认配置

安装Docker Engine,修改相关内核参数,关闭防火墙,禁用SELinux,安装EPEL,重启机器。脚本如下:

代码语言:javascript复制
#!/bin/bash
UserName='gysl'
PassWord='drh123'
# Install the Docker engine. This needs to be executed on every machine.
curl http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo>&/dev/null
if [ $? -eq 0 ] ;
    then
        yum remove docker 
                      docker-client 
                      docker-client-latest 
                      docker-common 
                      docker-latest 
                      docker-latest-logrotate 
                      docker-logrotate 
                      docker-selinux 
                      docker-engine-selinux 
                      docker-engine>&/dev/null
        yum list docker-ce --showduplicates|grep "^doc"|sort -r
        yum -y install docker-ce-18.09.3-3.el7
        rm -f /etc/yum.repos.d/docker-ce.repo
        systemctl enable docker --now && systemctl status docker
    else
        echo "Install failed! Please try again! ";
        exit 110
fi
# Modify related kernel parameters. 
cat>/etc/sysctl.d/kubernetes.conf<<EOF
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF 
sysctl -p /etc/sysctl.d/kubernetes.conf>&/dev/null 
# Turn off and disable the firewalld.  
systemctl stop firewalld  
systemctl disable firewalld  
# Disable the SELinux.  
sed -i.bak 's/=enforcing/=disabled/' /etc/selinux/config  
# Disable the swap.  
sed -i.bak 's/^.*swap/#&/g' /etc/fstab
# Install EPEL/vim/git.  
yum -y install epel-release vim git
yum repolist
# Add a docker user.
useradd $UserName
echo $PassWord|passwd $UserName --stdin
usermod $UserName -aG docker  
# Reboot the machine.  
reboot

0 人点赞