# 官方提供@yunTaoScripts 系统调优 🔥🔥
最好的方式升级硬件,没钱就去试试调优。或者优化应用程序。
# 内核调优
[root@server1 ~]# ls /proc/sys/vm/
admin_reserve_kbytes dirtytime_expire_seconds memory_failure_recovery numa_stat stat_interval
block_dump dirty_writeback_centisecs min_free_kbytes numa_zonelist_order stat_refresh
compaction_proactiveness drop_caches min_slab_ratio oom_dump_tasks swappiness
compact_memory extfrag_threshold min_unmapped_ratio oom_kill_allocating_task user_reserve_kbytes
compact_unevictable_allowed hugetlb_shm_group mmap_min_addr overcommit_kbytes vfs_cache_pressure
dirty_background_bytes laptop_mode mmap_rnd_bits overcommit_memory watermark_boost_factor
dirty_background_ratio legacy_va_layout mmap_rnd_compat_bits overcommit_ratio watermark_scale_factor
dirty_bytes lowmem_reserve_ratio nr_hugepages page-cluster zone_reclaim_mode
dirty_expire_centisecs max_map_count nr_hugepages_mempolicy panic_on_oom
dirty_ratio memory_failure_early_kill nr_overcommit_hugepages percpu_pagelist_fraction
[root@server1 ~]# cat /proc/sys/vm/swappiness
30
# TUNED
[root@server1 ~]# rpm -qa | grep tuned
tuned-2.15.0-2.el8.noarch
[root@server1 ~]# tuned
tuned tuned-adm
[root@server1 ~]# tuned
tuned tuned-adm
[root@server1 ~]# tuned-adm
active list off profile recommend verify
[root@server1 ~]# tuned-adm profile
Available profiles:
- accelerator-performance - Throughput performance based tuning with disabled higher latency STOP states
- balanced - General non-specialized tuned profile
- desktop - Optimize for the desktop use-case
- hpc-compute - Optimize for HPC compute workloads
- intel-sst - Configure for Intel Speed Select Base Frequency
- latency-performance - Optimize for deterministic performance at the cost of increased power consumption
- network-latency - Optimize for deterministic performance at the cost of increased power consumption, focused on low latency network performance
- network-throughput - Optimize for streaming network throughput, generally only necessary on older CPUs or 40G+ networks
- optimize-serial-console - Optimize for serial console use.
- powersave - Optimize for low power consumption
- throughput-performance - Broadly applicable tuning that provides excellent performance across a variety of common server workloads
- virtual-guest - Optimize for running inside a virtual guest
- virtual-host - Optimize for running KVM guests
Current active profile: virtual-guest
- 选择推荐模式
[root@server1 ~]# tuned-adm active #查看当前模式
Current active profile: powersave
[root@server1 ~]# tuned-adm recommend #查看推荐模式
virtual-guest
[root@server1 ~]# tuned-adm profile virtual-guest #切换到virtual-guest 模式
[root@server1 ~]# tuned-adm active
Current active profile: virtual-gues
- 自定义优化方案
[root@server1 ~]# cd /usr/lib/tuned/
[root@server1 tuned]# ll
total 16
drwxr-xr-x. 2 root root 24 Jul 12 17:02 accelerator-performance
drwxr-xr-x. 2 root root 24 Jul 12 17:02 balanced
drwxr-xr-x. 2 root root 24 Jul 12 17:02 desktop
-rw-r--r--. 1 root root 14833 Dec 18 2020 functions
drwxr-xr-x. 2 root root 24 Jul 12 17:02 hpc-compute
drwxr-xr-x. 2 root root 24 Jul 12 17:02 intel-sst
drwxr-xr-x. 2 root root 24 Jul 12 17:02 latency-performance
drwxr-xr-x. 2 root root 24 Jul 12 17:02 network-latency
drwxr-xr-x. 2 root root 24 Jul 12 17:02 network-throughput
drwxr-xr-x. 2 root root 24 Jul 12 17:02 optimize-serial-console
drwxr-xr-x. 2 root root 41 Jul 12 17:02 powersave
drwxr-xr-x. 2 root root 27 Jul 12 17:02 recommend.d
drwxr-xr-x. 2 root root 24 Jul 12 17:02 throughput-performance
drwxr-xr-x. 2 root root 24 Jul 12 17:02 virtual-guest
drwxr-xr-x. 2 root root 24 Jul 12 17:02 virtual-host
[root@server1 tuned]# cp -a virtual-guest/ self-modify
[root@server1 tuned]# ll
total 16
drwxr-xr-x. 2 root root 24 Jul 12 17:02 accelerator-performance
drwxr-xr-x. 2 root root 24 Jul 12 17:02 balanced
drwxr-xr-x. 2 root root 24 Jul 12 17:02 desktop
-rw-r--r--. 1 root root 14833 Dec 18 2020 functions
drwxr-xr-x. 2 root root 24 Jul 12 17:02 hpc-compute
drwxr-xr-x. 2 root root 24 Jul 12 17:02 intel-sst
drwxr-xr-x. 2 root root 24 Jul 12 17:02 latency-performance
drwxr-xr-x. 2 root root 24 Jul 12 17:02 network-latency
drwxr-xr-x. 2 root root 24 Jul 12 17:02 network-throughput
drwxr-xr-x. 2 root root 24 Jul 12 17:02 optimize-serial-console
drwxr-xr-x. 2 root root 41 Jul 12 17:02 powersave
drwxr-xr-x. 2 root root 27 Jul 12 17:02 recommend.d
drwxr-xr-x. 2 root root 24 Jul 31 21:40 self-modify
drwxr-xr-x. 2 root root 24 Jul 12 17:02 throughput-performance
drwxr-xr-x. 2 root root 24 Jul 12 17:02 virtual-guest
drwxr-xr-x. 2 root root 24 Jul 12 17:02 virtual-host
- 修改swapiness为0
[root@server1 tuned]# cat self-modify/tuned.conf
#
# tuned configuration
#
[main]
summary=Optimize for running inside a virtual guest
include=throughput-performance
[sysctl]
# If a workload mostly uses anonymous memory and it hits this limit, the entire
# working set is buffered for I/O, and any more write buffering would require
# swapping, so it's time to throttle writes until I/O can catch up. Workloads
# that mostly use file mappings may be able to use even higher values.
#
# The generator of dirty data starts writeback at this percentage (system default
# is 20%)
vm.dirty_ratio = 30
# Filesystem I/O is usually much more efficient than swapping, so try to keep
# swapping low. It's usually safe to go even lower than this on systems with
# server-grade storage.
vm.swappiness = 0
- 切换到自定义profile
[root@server1 self-modify]# tuned-adm profile self-modify
[root@server1 self-modify]# tuned-adm profile | grep self
- self-modify - Optimize for running inside a virtual guest
[root@server1 self-modify]# cat /proc/sys/vm/swappiness
0
← 快速链接