centos7初始优化
#!/bin/bash
echo '开始优化'
#添加公网DNS地址
echo '添加公网DNS地址'
cat >> /etc/resolv.conf << EOF
nameserver 114.114.114.114
EOF
echo 'Yum源更换为国内阿里源'
#Yum源更换为国内阿里源
yum install wget telnet net-tools -y
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
echo '添加阿里的epel源':
#添加阿里的epel源
#add the epel
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
# rpm -ivh http://dl.Fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
echo 'yum重新建立缓存'
#yum重新建立缓存
yum clean all
yum makecache
echo '同步时间'
#同步时间
yum -y install ntpdate
echo '同步阿里时间服务器'
ntpdate ntp1.aliyun.com
date
sleep 5
#安装常用软件
echo '安装常用软件'
yum -y install vim bash-completion lrzsz zip unzip tree gcc*
#禁用selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0
#关闭防火墙
systemctl disable firewalld.service
systemctl stop firewalld.service
#yum update
yum -y update