هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
المهارات في هذا الفصل
- ضبط ملف الأداء وتغيير أولوية العمليات
Know what tuned does
The tuned service applies a profile: CPU governor, disk scheduler, kernel settings (sysctl), power saving. RHEL picks a good profile at installation.
dnf install tuned
systemctl enable --now tuned
tuned-adm active
Current active profile: virtual-guest
tuned-adm list
Available profiles:
- accelerator-performance - Throughput performance based tuning with disabled higher latency STOP states
- balanced - General non-specialized tuned profile
- 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
- 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| Profile | Good for |
|---|---|
balanced | Desktops and laptops: a mix of speed and saving power |
powersave | Lowest power use |
throughput-performance | Servers that move a lot of data (the server default on hardware) |
latency-performance / network-latency | Fast answers: trading, VoIP, real time |
virtual-guest | Virtual machines (the default inside KVM, VMware …) |
virtual-host | Machines that run many VMs |
Choose and check a profile
tuned-adm recommend says which profile fits this machine. tuned-adm profile NAME switches. The choice stays after a reboot.
tuned-adm recommend
virtual-guest
tuned-adm profile throughput-performance
tuned-adm active
Current active profile: throughput-performance
tuned-adm verify
Verification succeeded, current system settings match the preset profile.
tuned-adm profile virtual-guest powersave
tuned-adm off- You can merge two profiles:
tuned-adm profile virtual-guest powersave(the later one wins when both set the same thing). tuned-adm offstops all tuning (not recommended).
نصيحة للامتحان
A task "use the recommended tuning profile" means: tuned-adm recommend, then tuned-adm profile with exactly that name, then tuned-adm active to check.
Make your own profile
A custom profile includes a built-in one and changes only a few settings. Put it in /etc/tuned/NAME/tuned.conf.
Understand nice values
Every process has a nice value from -20 (most important, gets the CPU first) to 19 (least important). The normal value is 0.
-20 ◄──────── 0 ────────► 19
higher priority normal lower priority ("nicer" to the others)- A normal user may only make his processes nicer (raise the value). Only root may lower it (raise the priority).
- The nice value matters only when the CPU is busy. On an idle CPU every process runs at full speed.
In top, the column NI is the nice value and PR the kernel priority.
Start a process with a nice value
nice -n N COMMAND starts the command with nice value N (default 10).
Change the priority of a running process
renice changes the nice value of a process that already runs — by PID, by user or by group.
renice -n 10 -p 6120
6120 (process ID) old priority 0, new priority 10
renice -n -5 -p 2210
renice -n 5 -u anna
ps -o pid,ni,cmd -p 6120In top, press r, type the PID and the new nice value.
انتبه
Do not give many processes -20. If everything is "most important", nothing is — and system services may get too little CPU.
Find what slows the system down
Before you tune, measure. Find out if the CPU, the memory or the disk is the bottleneck.
uptime
top -b -n 1 | head -15
free -h
vmstat 2 5
procs -----------memory---------- ---swap-- -----io---- -system-- -------cpu-------
r b swpd free buff cache si so bi bo in cs us sy id wa st gu
5 0 0 812340 4120 1203320 0 0 2 8 210 320 85 10 5 0 0 0
ps aux --sort=-%mem | head -5| In vmstat | High value means |
|---|---|
r | Many processes wait for the CPU |
b / wa | Processes wait for the disk |
si / so | The system swaps: too little memory |
us / sy | CPU time for programs / for the kernel |