centos
一种常见的linux操作系统,目前主流的两个版本是centos7和centos8
启动流程(centos7)

下载地址
https://archive.kernel.org/centos-vault/
优化原则
企业生产最小化原则:
1、安装软件包最小化
2、用户权限最小化
3、目录文件权限最小化
4、自启动服务最小化
5、服务运行用户最小化
centos7优化
#修改主机名
hostnamectl set-hostname name1
bash
#配置网络
sed -i 's#200#51#g' /etc/sysconfig/network-scripts/ifcfg-eth*
systemctl restart network
# 关闭swap分区
swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
#更新yum源信息(示例是阿里源)
curl -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
#关闭selinux
sed -i 's#SELINUX=.*#SELINUX=disabled#g' /etc/selinux/config
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
grep SELINUX=disabled /etc/selinux/config
setenforce 0
getenforce
#关闭firewalld防火墙服务
systemctl stop firewalld
systemctl disable firewalld
# 设置系统时间同步
yum install ntpdate -y
/usr/sbin/ntpdate ntp3.aliyun.com
echo '#crond-id-001:time sync by oldboy' >>/var/spool/cron/root
echo "*/5 * * * * /usr/sbin/ntpdate ntp3.aliyun.com >/dev/null 2>&1">>/var/spool/cron/root
crontab -l
#加大文件描述
echo '* - nofile 65535 ' >>/etc/security/limits.conf
tail -1 /etc/security/limits.conf
ulimit -SHn 65535
ulimit -n
#优化系统内核(从高并发的角度来优化)
cat >>/etc/sysctl.conf<<EOF
net.ipv4.tcp_fin_timeout = 2
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_keepalive_time = 600
net.ipv4.ip_local_port_range = 4000 65000
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_max_tw_buckets = 36000
net.ipv4.route.gc_timeout = 100
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_synack_retries = 1
net.core.somaxconn = 16384
net.core.netdev_max_backlog = 16384
net.ipv4.tcp_max_orphans = 16384
#以下参数是对iptables防火墙的优化,防火墙不开会提示,可以忽略不理。
net.nf_conntrack_max = 25000000
net.netfilter.nf_conntrack_max = 25000000
net.netfilter.nf_conntrack_tcp_timeout_established = 180
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.wmem_max = 16777216
net.core.rmem_max = 16777216
EOF
sysctl -p
#优化SSH远程连接效率
\cp /etc/ssh/sshd_config{,.ori}
sed -i "s/GSSAPIAuthentication yes/GSSAPIAuthentication no/g" /etc/ssh/sshd_config
sed -i "s/#UseDNS yes/UseDNS no/g" /etc/ssh/sshd_config
systemctl restart sshd
# 提升命令行安全
echo 'export TMOUT=300' >>/etc/profile
echo 'export HISTFILESIZE=5' >>/etc/profile
echo 'export HISTSIZE=10000000' >>/etc/profile
. /etc/profile
# 设置普通用户提权操作
useradd xiaotao
echo 123456|passwd --stdin xiaotao
\cp /etc/sudoers /etc/sudoers.ori
echo "xiaotao ALL=(ALL) NOPASSWD: ALL " >>/etc/sudoers
tail -1 /etc/sudoers
visudo -c
# 设置系统中文UTF8字符集(目的是防止汉字乱码,现在xshell兼容很好,不改也没问题)
cp /etc/locale.conf{,.ori}
localectl set-locale LANG="zh_CN.UTF-8"
cat /etc/locale.conf
# 保留yum安装的软件包
#将/etc/yum.conf中的keepcache=0改为keepcache=1,为日后一键安装网站集群留好rpm及依赖工具包。