配置虚拟机-模板机

232 阅读1分钟

配置网络

vi /etc/sysconfig/network-scripts/ifcfg-ens33

BOOTPROTO=static
ONBOOT=yes 
IPADDR=192.168.87.10 
GATEWAY=192.168.87.2
NETMASK=255.255.255.0 
DNS1=192.168.87.2 
UUID=192.168.87.10

systemctl restart network

安装插件

yum -y install vim* wget net-tools yum-utils iputils
yum -y install ntp 时间同步

设置机器名称

hostnamectl set-hostname basic

永久关闭防火墙

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
systemctl stop firewalld
systemctl disable firewalld

关闭swap

临时关闭 
swapoff -a 
永久关闭 
sed -ri 's/.*swap.*/#$/' /etc/fstab

更新源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum -y install epel-release.noarch
yum clean all
yum makecache
yum update

配置Docker仓库地址

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

安装docker

yum install -y docker-ce

设置开机启动

systemctl start docker 开启守护进程

systemctl enable docker 设置开机启动

去阿里云获取

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://wngn20n6.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker