linux性能优化之CentOS7使用tuned性能调优

tuned是redhat系linux自带的系统性能调优工具.
使用tuned可以很方便的设置各种优化参数,调优系统性能
本人推荐使用network-latency配置, 然后结合下面的参数自定义最优配置

tuned性能调优工具安装


yum install -y tuned  # 安装tuned工具
systemctl start tuned  # 启动/停止tuned服务
systemctl enable tuned  # 自启动/禁止自启动
tuned-adm list  #列出所有配置
tuned-adm profile network-latency #选择独立配置
tuned-adm active #激活独立配置

下面是个性化配置,自己可以手动添加

linux CPU性能优化


force_latency=1
governor=performance
energy_perf_bias=performance
min_perf_pct=100

kernel.numa_balancing=0
kernel.sched_latency_ns = 60000000
kernel.sched_migration_cost_ns = 500000
kernel.sched_min_granularity_ns = 15000000
kernel.sched_wakeup_granularity_ns = 2000000

linux内存性能优化


transparent_huggepage=never
vm.swappiness = 1
vm.dirty_background_ratio = 3
vm.dirty_ratio = 10
vm.dirty_expire_centisecs = 500
vm.dirty_writeback_centisecs = 100
vm.transparent_hugepages=never
vm.max_map_count=1600000
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576

linux硬盘性能优化

readahead设置为4096
blockdev --getra /dev/vda
blockdev --setra 4096 /dev/vda
echo 'blockdev --setra 4096 /dev/vda' >> /etc/rc.local
chmod +x /etc/rc.local


linux网络性能调优

#网络低延迟的调节优化
net.core.busy_read = 50 
net.core.busy_poll = 50
net.ipv4.tcp_fastopen =3

linux启动项优化


 sed -i 's/quiet/quiet nosoftlockup mce=off rcu_nocb_poll audit=0 nmi_watchdog=0 nohz=on skew_tick=1 idle=poll hpet=disable  tsc=reliable no_watchdog irqaffinity=0 selinux=0 transparent_hugepage=never intel_idle.max_cstate=0 processor.max_cstate=0 scsi_mod.use_blk_mq=1 elevator=deadline numa=off/' /etc/default/grub

注意: 修改启动项需要重新生成grub配置文件
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg

linux文件系统优化


直接看以前的文章
https://www.livelu.com/201809316.html

linux内核参数优化


#线程数量的调节优化
vm.max_map_count =1600000
kernel.pid_max = 655350
kernel.threads-max= 655350
# 解决inotify打开了太多文件
fs.inotify.max_queued_events = 65535
fs.inotify.max_user_instances  = 4096
fs.inotify.max_user_watches = 65535
#TCP监听队列的长度
net.core.somaxconn = 65535
#防火墙防止连接数过多
net.netfilter.nf_conntrack_max = 1048576  
 net.netfilter.nf_conntrack_checksum = 1
#路由转发
net.ipv4.ip_forward = 1
#支持二层的网桥规则过滤(可选)
net.bridge.bridge-nf-call-iptables = 1 
net.bridge.bridge-nf-call-arptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
#允许网络接口接收数据包超过内核数率的队列
net.core.netdev_max_backlog = 10240
net.core.netdev_budget = 1024
#解决neighbour table overflow问题
net.ipv4.neigh.default.gc_thresh1 = 512   
net.ipv4.neigh.default.gc_thresh2 = 2048
net.ipv4.neigh.default.gc_thresh3 = 4096

参考文章
https://docs.microsoft.com/zh-cn/sql/linux/sql-server-linux-performance-best-practices?view=sql-server-ver15
https://mp.weixin.qq.com/s/WISwRxmOpheg7InuVAeaMw
https://blog.csdn.net/qq_41901686/article/details/105972800

发表评论