centos 优化

# 标准化网卡
sed -i 's/crashkernel=auto/crashkernel=auto net.ifnames=0 biosdevname=0/g' /etc/default/grub
mv /etc/sysconfig/network-scripts/ifcfg-ens192 /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i 's/ens192/eth0/g' /etc/sysconfig/network-scripts/ifcfg-eth0
grub2-mkconfig -o /etc/grub2.cfg
reboot

VMware/vSphere中新安装好的虚拟机把以下两个文件添加注释后,即可转换为虚拟机模板
# vi /etc/udev/rules.d/70-persistent-net.rules
# SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:8c:19:a6", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# 注释此行 SUBSYSTEM

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
# HWADDR=00:50:56:8C:19:A6
# 注释 HWADDR  &  UUID

# 关闭IPV6
## 临时
sysctl net.ipv6.conf.all.disable_ipv6=1
## 永久
echo "net.ipv6.conf.all.disable_ipv6=1" >> /etc/sysctl.conf
## ALL 表示全部网卡 可改为eth0 指定网卡

# 改名
hostnamectl set-hostname centos7

# yum epel源
yum install wget telnet -y
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
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache


# 同步时间
yum -y install ntp
/usr/sbin/ntpdate cn.pool.ntp.org
echo "* 4 * * * /usr/sbin/ntpdate 192.168.5.99 > /dev/null 2>&1" >> /var/spool/cron/root
systemctl  restart crond.service

# 安装vim  lrzsz  ifconfig tree
yum -y install lrzsz net-tools tree


# 禁用selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0

# 关闭防火墙
systemctl disable firewalld.service
systemctl stop firewalld.service 


# 编译环境
yum -y install perl gcc make kernel-headers kernel-devel
yum -y install gcc gcc-c++ gcc-g77 make unzip automake openssl openssl-devel curl curl-devel pcre-devel



#################
#  centos6优化  #
#################
# 禁用selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0


# 关闭防火墙
iptables –F
/etc/init.d/iptables save


# yum源
yum install wget -y
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
yum clean all
yum makecache


#安装
yum install lrzsz ntpdate sysstat -y


# 精简开机自启动服务
操作系统可以只保留crond,network,syslog,sshd这四个服务
for sun in `chkconfig --list|grep 3:on|awk '{print $1}'`;do chkconfig --level 3 $sun off;done
for sun in crond rsyslog sshd network;do chkconfig --level 3 $sun on;done
chkconfig --list|grep 3:on



猜你喜欢

转载自blog.csdn.net/lswzw/article/details/89468405