我对 Linux 服务器还很陌生。我正在使用 centos。有时我的 CPU 会因为 mysqld 进程超过 100% 而过载
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2221 mysql 20 0 2810m 797m 5648 S 99.3 5.0 262:15.91 mysqld
因此为了调试我运行顶部ssh 中的命令,我得到下面的结果
Cpu(s): 2.9%us, 2.3%sy, 0.0%ni, 94.7%id, 0.0%wa, 0.0%hi, 0.1%si, 0.0%st
Mem: 16291440k total, 14893024k used, 1398416k free, 1673232k buffers
Swap: 16433144k total, 30168k used, 16402976k free, 10713048k cached
我对此一无所知,但是我看到,只有一个 CPU(94.7%id)被大量使用,其他 CPU 都是空闲的。如何让 mysql 共享更多 CPU 并减少负载。
答案1
第 3 行:在顶部命令指示CPU 的使用方式. 分别了解每一个
% of the CPU for user processes (2.9%us)
% of the CPU for system processes (2.3%sy)
% of the CPU processes with priority upgrade nice (0.0%ni)
% of the CPU not used (94.7%id)
% of the CPU processes waiting for I/O operations(0.0%wa)
% of the CPU serving hardware interrupts (0.0% hi)
% of the CPU serving software interrupts (0.1% si)
第 4 行和第 5 行:提供 RAM(物理内存)和 SWAP 详细信息。
这表明进程列表
%CPU – % of CPU used by this process (99.3)
%MEM – % of RAM used by the process (5.0)
有关 CPU 分配,请参阅
https://stackoverflow.com/questions/14787046/how-to-allocate-more-cpu-and-ram-to-ac-program-in-linux
https://askubuntu.com/questions/115478/how-do-i-assign-different-cpu-cores-to-different-processes