tiancheng91 / collection

笔记
https://github.com/tiancheng91/collection/issues
21 stars 1 forks source link

sysctl #14

Open tiancheng91 opened 6 years ago

tiancheng91 commented 6 years ago

中文文档 https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/6/html/performance_tuning_guide/

# 实时修改
sysctl -w 
# 刷新配置 /et/sysctl.conf
sysctl -p
# 转发, 前端网关机器
net.ipv4.ip_forward = 1
net.ipv4.tcp_fin_timeout = 15
net.core.somaxconn=1000    # tcp连接队列(连接中)

net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1

net.ipv4.ip_forward=1
fs.file-max=655360
vm.max_map_count=300000

# grep -i commit /proc/meminfo, 参看内存被申请量, 
# http://linuxperf.com/?p=102, 可用于替代oom配置, 1表示, 运行所有内存申请, 2 表示拒绝, 0表示自动
# vm.overcommit_memory=0

fs.file-max = 10000
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
net.ipv4.tcp_notsent_lowat = 16384

# 内存剩余多少时开始使用swap,尽量别用swap, 内存不够时, 内存操作会导致磁盘交换,速度变慢, kswapd0高负载, IO跑满
vm.swappiness = 30
vm.swappiness = 1   // 推荐
vm.swappiness = 0   // 会导致oom

磁盘io策略, optimize for ssd

echo noop > /sys/block/sdb/queue/scheduler

磁盘IO