优化centos7系统内核

2.1给/etc/rc.local添加执行权限
[root@localhost ~]# chmod +x /etc/rc.d/rc.local #为rc.local添加可执行权限

2.2禁用selinux
[root@localhost ~]# sed -i ‘/^SELINUX/s/enforcing/disabled/g’ /etc/selinux/config
[root@localhost ~]# grep -i ^selinux /etc/selinux/config SELINUX=disabled SELINUXTYPE=targeted [root@localhost ~]# setenforce 0

2.3查看并管理服务
[root@hequan ~]# systemctl -t service
[root@hequan ~]# systemctl list-unit-files -t service yum install -y bash-completion #补全服务名称,退出bash再进就可以

2.4 yum 安装常用组件包
[root@localhost ~]#yum install gcc cmake bzip2-devel curl-devel db4-devel libjpeg-devel libpng-devel freetype-devel libXpm-devel gmp-devel libc-client-devel openldap-devel unixODBC-devel postgresql-devel sqlite-devel aspell-devel net-snmp-devel libxslt-devel libxml2-devel pcre-devel mysql-devel pspell-devel libmemcached libmemcached-devel zlib-devel vim wget lrzsz tree

2.5配置sshd
[root@localhost ~]#sed -i -e ‘49s/^#//g’ /etc/ssh/sshd_config ##启用49行配置
[root@localhost ~]#sed -i -e ‘129s/#/ /g’ /etc/ssh/sshd_config ##禁止UseDNS
[root@localhost ~]#sed -i ‘/^GSS/s/yes/no/g’ /etc/ssh/sshd_config ##禁用GSSAPI认证加快登录速度
[root@localhost ~]#systemctl restart sshd ##重新启动服务
[root@localhost ~]#systemctl enable sshd ##设置为开机启动
[root@localhost ~]#systemctl status sshd ##查看状态

2.6加大打开文件数的限制(open files)
[root@localhost ~]#vi /etc/security/limits.conf #在文件末尾添加

  • soft nofile 1024000
  • hard nofile 1024000 hive
  • nofile 1024000 hive
  • nproc 1024000

2.7加大普通用户进程数限制
[root@hequan ~]# sed -i ‘s#4096#65535#g’ /etc/security/limits.d/20-nproc.conf
2.8优化系统内核
[root@hequan ~]#vi /etc/sysctl.conf #CTCDN系统优化参数在文件末尾添加
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.ip_forward = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536 kernel.msgmax = 65536
kernel.shmall = 4294967296
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 262144
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 1800
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_intvl = 15
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0

[root@hequan ~]#sysctl -p #生效
[root@hequan ~]#reboot #重启系统使上述优化生效

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值