centos 7 服务初始化

更新yum源及必要软件安装

yum groupinstall "Development tools" "Compatibility libraries" 
yum install -y ntpdate vim mlocate lsof wget lrzsz telnet traceroute tree rsync cmake autoconf automake pcre pcre-devel zlib zlib-devel epel-release

yum重新建立缓存

yum clean all
yum makecache

关闭防火墙、selinux
systemctl stop firewalld #临时关闭防火墙
systemctl disable firewalld #防火墙开机关闭

setenforce 0 #临时关闭SELinux
sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/‘ /etc/selinux/config #开机关闭SELinux

设置最大打开文件描述符数

echo "ulimit -SHn 102400" >> /etc/rc.local

cat >> /etc/security/limits.conf << EOF
* soft nofile 655350
* hard nofile 655350
EOF

内核参数优化

#cat >> /etc/sysctl.conf << EOF
vm.overcommit_memory = 1
net.ipv4.ip_local_port_range = 1024 65536
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_abort_on_overflow = 0
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 262144
net.core.somaxconn = 262144
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_max_syn_backlog = 262144
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.ipv4.netfilter.ip_conntrack_max = 2097152
net.nf_conntrack_max = 655360
net.netfilter.nf_conntrack_tcp_timeout_established = 1200
EOF

#/sbin/sysctl -p

主机名修改

hostname 主机名 #先修改临时名,重启后会失效
hostnamectl set-hostname 主机名 #永久修改主机名,需要重启

相关推荐