Linux内核优化

修改ip地址、网关、主机名、DNS等
关闭selinux,清空iptables
添加普通用户并进行sudo授权管理
更新yum源及必要软件安装
定时自动更新服务器时间
精简开机自启动服务
定时自动清理/var/spool/clientmqueue/目录垃圾文件,放置inode节点被占满
变更默认的ssh服务端口,禁止root用户远程连接
锁定关键文件系统
调整文件描述符大小
调整字符集,使其支持中文
去除系统及内核版本登录前的屏幕显示
禁止ping
历史记录
内核参数优化
升级具有典型漏洞的软件版本


yum update -y

reboot

vi /etc/sysctl.conf ==内核优化

vm.swappiness = 0
net.ipv4.neigh.default.gc_stale_time = 120
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_announce = 2
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_synack_retries = 2
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
kernel.sysrq = 1
fs.file-max = 1048576
net.ipv4.ip_local_port_range = 1024 65535
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216

sysctl -p 配置文件生效

vi /etc/security/limits.conf

root soft nofile 65535
root hard nofile 65535

  • soft nofile 65535
  • hard nofile 65535
    追加到文件末尾

一般情况下,需要关闭selinux和firewalld
setenforce 0 设置不启动
sed -i “s/SELINUX=enforcing/SELINUX=disabled/g” /etc/selinux/config
关闭selinux

#vi /etc/sysconfig/selinux
永久关闭selinux enforcing

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值