الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

الفصل 9الاسم في الدورة: Tuning System Performance

Tune the system and set process priorities

A database server, a laptop and a virtual machine need different kernel and power settings. tuned applies a whole set of good settings with one command: a tuning profile. For single processes, the nice value decides who gets the CPU first. This chapter shows both.

  • 7 الدروس
  • 13 الأوامر
  • 1 المعامل

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

المهارات في هذا الفصل

  • ضبط ملف الأداء وتغيير أولوية العمليات

9.1

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
ProfileGood for
balancedDesktops and laptops: a mix of speed and saving power
powersaveLowest power use
throughput-performanceServers that move a lot of data (the server default on hardware)
latency-performance / network-latencyFast answers: trading, VoIP, real time
virtual-guestVirtual machines (the default inside KVM, VMware …)
virtual-hostMachines that run many VMs

9.2

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

نصيحة للامتحان

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.

الأوامر في هذا الدرس

9.3

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.

/etc/tuned/myweb/tuned.conf
[main]
summary=Throughput profile with less swapping for the web servers
include=throughput-performance
 
[sysctl]
vm.swappiness=10
net.core.somaxconn=4096
tuned-adm profile myweb
tuned-adm active
sysctl vm.swappiness
vm.swappiness = 10

9.4

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.
ps -o pid,ni,pri,cmd -p $$
ps -eo pid,user,ni,%cpu,comm --sort=-%cpu | head
top

In top, the column NI is the nice value and PR the kernel priority.

الأوامر في هذا الدرس

9.5

Start a process with a nice value

nice -n N COMMAND starts the command with nice value N (default 10).

nice tar czf /tmp/big.tgz /srv/data
nice -n 15 ./report.sh
nice -n -5 /usr/local/bin/important-job
nice -n 19 ionice -c 3 rsync -a /srv/ /mnt/backup/

في العمل

Backups, big compressions and reports should run with nice -n 19 (and ionice -c 3 for the disk). Then users of the server hardly notice them.

9.6

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 6120

In 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.

9.7

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 vmstatHigh value means
rMany processes wait for the CPU
b / waProcesses wait for the disk
si / soThe system swaps: too little memory
us / syCPU time for programs / for the kernel

تدرّب

كل الأوامر في هذا الفصل