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中新安装好的虚拟机把以下两个文件添加注释后,即可转换为虚拟机模板
[root]# 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

[root]# 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

systemctl disable postfix

# 同步时间
#yum -y install ntpdate
#/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

# 同步时间
yum -y install chrony
sed -i 's/server/#server/' /etc/chrony.conf
echo "server 192.168.5.99" >> /etc/chrony.conf
systemctl start chronyd
systemctl enable chronyd
chronyc sources

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


# 禁用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 -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.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



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值