2.14、制作Centos模板及优化操作
1、安装系统:
(1)规范网卡为eth0的模式:
(2)选择时区:
(3)选择支持的语言包含中文:
(4)选择软件包:
补充:桌面版包选择:
(5)关闭down机内存日志:
(6)分区:
1)分区说明:
A、使用标准分区,不使用LVM等;
B、不使用swap分区;
C、只分一个/(根分区),方便日后硬盘的整体扩容;
(7)网卡设置,方便连接:
(8)设置密码:
#提示:这里设置的密码是123456
2、系统优化:
(1)关闭防火墙:
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl status firewalld.service
(2)关闭selinux:
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
grep "SELINUX=disabled" /etc/selinux/config
setenforce 0
getenforce
(3)关闭postfix:
systemctl stop postfix.service
systemctl disable postfix.service
systemctl status postfix.service
(4)关闭NetworkManager:
systemctl stop NetworkManager.service
systemctl disable NetworkManager.service
systemctl status NetworkManager.service
(5)安装必备的软件:
yum install lrzsz dos2unix bash-completion nmap telnet tree wget vim net-tools ntpdate salt-minion git zabbix-agent -y
#安装监控代理软件,可选;
(6)配置软件的安装源:
1)配置阿里的yum源:
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
2)配置阿里的epel源:
yum install epel-release
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
3)设置yum和epel源的缓存:
yum clean all
yum makecache
4)查看系统可用的源:
yum repolist enabled
(7)优化网卡:
1)备份原网卡配置文件:
cp -a /etc/sysconfig/network-scripts/ifcfg-eth0{,.bak}
2)原配置:
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0
UUID=666c063d-8431-48be-a78f-31ac4ac16969
DEVICE=eth0
ONBOOT=yes
IPADDR=10.0.0.100
PREFIX=24
DNS1=114.114.114.114
IPV6_PRIVACY=no
GATEWAY=10.0.0.253
3)优化后的网卡参数:
TYPE=Ethernet
BOOTPROTO=static
IPV4_FAILURE_FATAL=no
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=10.0.0.100
PREFIX=24
DNS1=114.114.114.114
GATEWAY=10.0.0.253
#提示:优化网卡配置根据情况而定;
(8)同步时间:
crontab -e
*/5 * * * * /usr/sbin/ntpdate ntp.aliyun.com $>/dev/null