CentOS7.2(RHEL 7.2)的CPU占用高(%system 占用高)

作者:袖梨 2022-06-30

开机后,发现节点1的CPU使用率很高:
[root@lunar1 ~]# sar -u 1 10
Linux 3.10.0-327.el7.x86_64 (lunar1.oracle.com)         03/22/2016      _x86_64_        (2 CPU)
 
06:16:57 PM     CPU     %user     %nice   %system   %iowait    %steal     %idle
06:16:58 PM     all      0.55      0.00     78.14      0.00      0.00     21.31
06:16:59 PM     all      0.00      0.00     73.91      0.00      0.00     26.09
06:17:00 PM     all      0.52      0.00     81.68      0.00      0.00     17.80
06:17:01 PM     all      0.00      0.00     82.81      0.00      0.00     17.19
06:17:02 PM     all      0.00      0.00     84.13      0.00      0.00     15.87
06:17:03 PM     all      0.55      0.00     70.72      0.00      0.00     28.73
^C
 
06:17:03 PM     all      0.00      0.00     57.14      0.00      0.00     42.86
Average:        all      0.26      0.00     77.88      0.00      0.00     21.86
[root@lunar1 ~]#

节点2的也比较高:
[root@lunar2 ~]# sar -u 1 10
Linux 3.10.0-327.el7.x86_64 (lunar2.oracle.com)         03/22/2016      _x86_64_        (2 CPU)
 
06:17:20 PM     CPU     %user     %nice   %system   %iowait    %steal     %idle
06:17:21 PM     all      0.50      0.00      0.50      0.00      0.00     99.00
06:17:22 PM     all      0.00      0.00      0.00      0.00      0.00    100.00
06:17:23 PM     all     55.44      0.00      6.74      0.00      0.00     37.82
06:17:24 PM     all     59.79      0.00     11.34      0.00      0.00     28.87
06:17:25 PM     all     38.38      0.00     28.11      0.54      0.00     32.97
06:17:26 PM     all      8.67      0.00      8.67      0.00      0.00     82.65
06:17:27 PM     all      0.00      0.00      0.00      0.00      0.00    100.00
06:17:28 PM     all      0.00      0.00      0.00      0.00      0.00    100.00
06:17:29 PM     all      0.00      0.00      0.00      0.00      0.00    100.00
06:17:30 PM     all      0.50      0.00      1.00      0.00      0.00     98.51
Average:        all     15.90      0.00      5.43      0.05      0.00     78.62
[root@lunar2 ~]#

在节点1检查哪些进程使用CPU资源较多:
Tasks: 287 total,   4 running, 283 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.4 us, 80.8 sy,  0.0 ni, 18.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  3145636 total,  1630448 free,  1073504 used,   441684 buff/cache
KiB Swap:  4190204 total,  4190204 free,        0 used.  2000056 avail Mem
 
  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                    
 3205 oracle    20   0  214120   1828   1328 R  79.1  0.1   3:40.27 /usr/bin/VBoxClient --clipboard                                                                                            
 3208 root      20   0  222392   1844   1312 R  78.7  0.1   3:40.10 /usr/bin/VBoxClient --clipboard                                                                                            
 3279 oracle    20   0  147044   1292    884 S   0.3  0.0   0:00.26 /usr/bin/VBoxClient --draganddrop                                                                                          
 3850 grid      20   0  322112   6092   4604 S   0.3  0.2   0:00.04 /usr/libexec/goa-identity-service                                                                                         
 7179 root      20   0  146308   2336   1520 R   0.3  0.1   0:00.02 top -c                                                                                                                     
    1 root      20   0  189244   4316   2380 S   0.0  0.1   0:01.54 /usr/lib/systemd/systemd --switched-root --system --deserialize 22                                                         
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 [kthreadd]                                                                                                                 
    3 root      20   0       0      0      0 S   0.0  0.0   0:00.15 [ksoftirqd/0]                                                                                                              
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 [kworker/0:0H]                                                                                                             
    7 root      rt   0       0      0      0 S   0.0  0.0   0:00.38 [migration/0]                                                                                                              
    8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 [rcu_bh]                                 

检查果然vnc都自动开启:
[root@lunar1 ~]# systemctl status vncserver@:1.service
● vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/usr/lib/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2016-03-22 18:12:24 CST; 6min ago
  Process: 1420 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :1 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 1832 (Xvnc)
   CGroup: /system.slice/system-vncserver.slice/vncserver@:1.service
           ‣ 1832 /usr/bin/Xvnc :1 -desktop lunar1.oracle.com:1 (root) -auth /root/.Xauthority -geometry 1024x768 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5901 -fp catalogue:/etc/...
 
Mar 22 18:12:24 lunar1.oracle.com systemd[1]: Starting Remote desktop service (VNC)...
Mar 22 18:12:24 lunar1.oracle.com systemd[1]: Started Remote desktop service (VNC).
[root@lunar1 ~]#
[root@lunar1 ~]# systemctl status vncserver@:2.service
● vncserver@:2.service - Remote desktop service (VNC)
   Loaded: loaded (/usr/lib/systemd/system/vncserver@:2.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2016-03-22 18:12:24 CST; 6min ago
  Process: 1425 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :2 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 1833 (Xvnc)
   CGroup: /system.slice/system-vncserver.slice/vncserver@:2.service
           ‣ 1833 /usr/bin/Xvnc :2 -desktop lunar1.oracle.com:2 (grid) -auth /home/grid/.Xauthority -geometry 1024x768 -rfbwait 30000 -rfbauth /home/grid/.vnc/passwd -rfbport 5902 -fp catal...
 
Mar 22 18:12:24 lunar1.oracle.com systemd[1]: Starting Remote desktop service (VNC)...
Mar 22 18:12:24 lunar1.oracle.com systemd[1]: Started Remote desktop service (VNC).
[root@lunar1 ~]#
[root@lunar1 ~]# systemctl status vncserver@:3.service
● vncserver@:3.service - Remote desktop service (VNC)
   Loaded: loaded (/usr/lib/systemd/system/vncserver@:3.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2016-03-22 18:12:24 CST; 6min ago
  Process: 1423 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :3 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 1828 (Xvnc)
   CGroup: /system.slice/system-vncserver.slice/vncserver@:3.service
           ‣ 1828 /usr/bin/Xvnc :3 -desktop lunar1.oracle.com:3 (oracle) -auth /home/oracle/.Xauthority -geometry 1024x768 -rfbwait 30000 -rfbauth /home/oracle/.vnc/passwd -rfbport 5903 -fp...
 
Mar 22 18:12:24 lunar1.oracle.com systemd[1]: Starting Remote desktop service (VNC)...
Mar 22 18:12:24 lunar1.oracle.com systemd[1]: Started Remote desktop service (VNC).
[root@lunar1 ~]#

停止vnc并设置开机不启动:
[root@lunar1 ~]# systemctl stop  vncserver@:1.service
[root@lunar1 ~]# systemctl stop  vncserver@:2.service
[root@lunar1 ~]# systemctl stop  vncserver@:3.service
[root@lunar1 ~]# systemctl disable vncserver@:1.service
Removed symlink /etc/systemd/system/multi-user.target.wants/vncserver@:1.service.
[root@lunar1 ~]# systemctl disable vncserver@:2.service
Removed symlink /etc/systemd/system/multi-user.target.wants/vncserver@:2.service.
[root@lunar1 ~]# systemctl disable vncserver@:3.service
Removed symlink /etc/systemd/system/multi-user.target.wants/vncserver@:3.service.
[root@lunar1 ~]# systemctl status vncserver@:1.service
● vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/usr/lib/systemd/system/vncserver@:1.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
 
Mar 22 18:12:24 lunar1.oracle.com systemd[1]: Starting Remote desktop service (VNC)...
Mar 22 18:12:24 lunar1.oracle.com systemd[1]: Started Remote desktop service (VNC).
Mar 22 18:20:48 lunar1.oracle.com systemd[1]: Stopping Remote desktop service (VNC)...
Mar 22 18:20:49 lunar1.oracle.com systemd[1]: Stopped Remote desktop service (VNC).
[root@lunar1 ~]# systemctl status vncserver@:2.service
● vncserver@:2.service - Remote desktop service (VNC)
   Loaded: loaded (/usr/lib/systemd/system/vncserver@:2.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
 
Mar 22 18:12:24 lunar1.oracle.com systemd[1]: Starting Remote desktop service (VNC)...
Mar 22 18:12:24 lunar1.oracle.com systemd[1]: Started Remote desktop service (VNC).
Mar 22 18:20:53 lunar1.oracle.com systemd[1]: Stopping Remote desktop service (VNC)...
Mar 22 18:20:53 lunar1.oracle.com systemd[1]: Stopped Remote desktop service (VNC).
[root@lunar1 ~]# systemctl status vncserver@:3.service
● vncserver@:3.service - Remote desktop service (VNC)
   Loaded: loaded (/usr/lib/systemd/system/vncserver@:3.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
 
Mar 22 18:12:24 lunar1.oracle.com systemd[1]: Starting Remote desktop service (VNC)...
Mar 22 18:12:24 lunar1.oracle.com systemd[1]: Started Remote desktop service (VNC).
Mar 22 18:20:57 lunar1.oracle.com systemd[1]: Stopping Remote desktop service (VNC)...
Mar 22 18:20:57 lunar1.oracle.com systemd[1]: Stopped Remote desktop service (VNC).
[root@lunar1 ~]#

优化效果非常明显,可以看到CPU基本空闲了,符合现在的情况(Oracle的CRS还没启动呢):
[root@lunar1 ~]# sar -u 1 10
Linux 3.10.0-327.el7.x86_64 (lunar1.oracle.com)         03/22/2016      _x86_64_        (2 CPU)
 
06:21:47 PM     CPU     %user     %nice   %system   %iowait    %steal     %idle
06:21:48 PM     all      0.00      0.00      0.00      0.00      0.00    100.00
06:21:49 PM     all      0.00      0.00      0.50      0.00      0.00     99.50
06:21:50 PM     all      1.01      0.00      1.52      0.00      0.00     97.47
06:21:51 PM     all      0.00      0.00      0.00      0.00      0.00    100.00
06:21:53 PM     all      0.50      0.00      0.50      0.00      0.00     99.00
06:21:54 PM     all      0.00      0.00      0.00      0.00      0.00    100.00
06:21:55 PM     all      0.00      0.00      0.00      0.00      0.00    100.00
06:21:56 PM     all      1.51      0.00      3.52      0.00      0.00     94.97
06:21:57 PM     all      0.00      0.00      0.00      0.00      0.00    100.00
06:21:58 PM     all      0.00      0.00      0.00      0.00      0.00    100.00
Average:        all      0.30      0.00      0.60      0.00      0.00     99.10
[root@lunar1 ~]#

再来看看节点2:
Tasks: 284 total,   2 running, 282 sleeping,   0 stopped,   0 zombie
%Cpu(s):  4.3 us,  0.7 sy,  0.0 ni, 95.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  3145636 total,  1645972 free,  1070152 used,   429512 buff/cache
KiB Swap:  4190204 total,  4190204 free,        0 used.  2003876 avail Mem
 
  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                    
 3643 grid      20   0 1442740 154600  44292 S   3.3  4.9   0:06.48 /usr/bin/gnome-shell                                                                                                      
 3651 oracle    20   0 1593832 154216  44296 S   3.0  4.9   0:06.94 /usr/bin/gnome-shell                                                                                                      
 3520 root      20   0 1580060 154488  43804 S   2.7  4.9   0:06.18 /usr/bin/gnome-shell                                                                                                      
   12 root      20   0       0      0      0 S   0.3  0.0   0:00.30 [rcuos/0]                                                                                                                  
 1023 root      20   0 1721880 153028   9952 S   0.3  4.9   0:09.38 /u01/app/12.1.0.2/grid/jdk/jre/bin/java -Xms128m -Xmx512m -classpath /u01/app/12.1.0.2/grid/tfa/lunar2/tfa_home/jlib/RATFA+
 1873 oracle    20   0  222688  24820   8192 S   0.3  0.8   0:00.22 /usr/bin/Xvnc :3 -desktop lunar2.oracle.com:3 (oracle) -auth /home/oracle/.Xauthority -geometry 1024x768 -rfbwait 30000 -r+
 3299 root      20   0  220832   1340    892 S   0.3  0.0   0:00.31 /usr/bin/VBoxClient --draganddrop                                                                                          
 7208 root      20   0  146308   2316   1512 R   0.3  0.1   0:00.11 top -c                                                                                                                     
    1 root      20   0  189236   4292   2380 S   0.0  0.1   0:01.56 /usr/lib/systemd/systemd --switched-root --system --deserialize 21                                                         
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 [kthreadd]                                                                                                                 
    3 root      20   0       0      0      0 S   0.0  0.0   0:00.02 [ksoftirqd/0]                                                                                                              
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 [kworker/0:0H]                                                                                                             
    7 root      rt   0       0      0      0 S   0.0  0.0   0:00.67 [migration/0]                                                                                                              
    8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 [rcu_bh]                                                                                                                   
    9 root      20   0       0      0      0 S   0.0  0.0   0:00.00 [rcuob/0]                                                                                                                  
   10 root      20   0       0      0      0 S   0.0  0.0   0:00.00 [rcuob/1]                                                                                                                  
   11 root      20   0       0      0      0 R   0.0  0.0   0:00.47 [rcu_sched]                        

同样的方法,也停止vnc服务和vnc的开机自动启动:
[root@lunar2 ~]# systemctl status vncserver@:1.service
● vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/usr/lib/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2016-03-22 18:12:23 CST; 10min ago
  Process: 1470 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :1 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 1872 (Xvnc)
   CGroup: /system.slice/system-vncserver.slice/vncserver@:1.service
           ‣ 1872 /usr/bin/Xvnc :1 -desktop lunar2.oracle.com:1 (root) -auth /root/.Xauthority -geometry 1024x768 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5901 -fp catalogue:/etc/...
 
Mar 22 18:12:23 lunar2.oracle.com systemd[1]: Starting Remote desktop service (VNC)...
Mar 22 18:12:23 lunar2.oracle.com systemd[1]: Started Remote desktop service (VNC).
[root@lunar2 ~]# systemctl status vncserver@:2.service
● vncserver@:2.service - Remote desktop service (VNC)
   Loaded: loaded (/usr/lib/systemd/system/vncserver@:2.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2016-03-22 18:12:23 CST; 10min ago
  Process: 1469 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :2 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 1869 (Xvnc)
   CGroup: /system.slice/system-vncserver.slice/vncserver@:2.service
           ‣ 1869 /usr/bin/Xvnc :2 -desktop lunar2.oracle.com:2 (grid) -auth /home/grid/.Xauthority -geometry 1024x768 -rfbwait 30000 -rfbauth /home/grid/.vnc/passwd -rfbport 5902 -fp catal...
 
Mar 22 18:12:23 lunar2.oracle.com systemd[1]: Starting Remote desktop service (VNC)...
Mar 22 18:12:23 lunar2.oracle.com systemd[1]: Started Remote desktop service (VNC).
[root@lunar2 ~]# systemctl status vncserver@:3.service
● vncserver@:3.service - Remote desktop service (VNC)
   Loaded: loaded (/usr/lib/systemd/system/vncserver@:3.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2016-03-22 18:12:23 CST; 10min ago
  Process: 1474 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :3 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 1873 (Xvnc)
   CGroup: /system.slice/system-vncserver.slice/vncserver@:3.service
           ‣ 1873 /usr/bin/Xvnc :3 -desktop lunar2.oracle.com:3 (oracle) -auth /home/oracle/.Xauthority -geometry 1024x768 -rfbwait 30000 -rfbauth /home/oracle/.vnc/passwd -rfbport 5903 -fp...
 
Mar 22 18:12:23 lunar2.oracle.com systemd[1]: Starting Remote desktop service (VNC)...
Mar 22 18:12:23 lunar2.oracle.com systemd[1]: Started Remote desktop service (VNC).
[root@lunar2 ~]#

停止vnc服务和进制vnc开机自动启动:
[root@lunar2 ~]# systemctl disable vncserver@:1.service
systemctl stop  vncserver@:1.service
systemctl status vncserver@:1.service
Removed symlink /etc/systemd/system/multi-user.target.wants/vncserver@:1.service.
[root@lunar2 ~]# systemctl stop  vncserver@:1.service
[root@lunar2 ~]# systemctl status vncserver@:1.service
● vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/usr/lib/systemd/system/vncserver@:1.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
 
Mar 22 18:12:23 lunar2.oracle.com systemd[1]: Starting Remote desktop service (VNC)...
Mar 22 18:12:23 lunar2.oracle.com systemd[1]: Started Remote desktop service (VNC).
Mar 22 18:23:23 lunar2.oracle.com systemd[1]: Stopping Remote desktop service (VNC)...
Mar 22 18:23:23 lunar2.oracle.com systemd[1]: Stopped Remote desktop service (VNC).
[root@lunar2 ~]# systemctl disable vncserver@:2.service
systemctl stop  vncserver@:2.service
systemctl status vncserver@:2.service
Removed symlink /etc/systemd/system/multi-user.target.wants/vncserver@:2.service.
[root@lunar2 ~]# systemctl stop  vncserver@:2.service
[root@lunar2 ~]# systemctl status vncserver@:2.service
● vncserver@:2.service - Remote desktop service (VNC)
   Loaded: loaded (/usr/lib/systemd/system/vncserver@:2.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
 
Mar 22 18:12:23 lunar2.oracle.com systemd[1]: Starting Remote desktop service (VNC)...
Mar 22 18:12:23 lunar2.oracle.com systemd[1]: Started Remote desktop service (VNC).
Mar 22 18:23:28 lunar2.oracle.com systemd[1]: Stopping Remote desktop service (VNC)...
Mar 22 18:23:28 lunar2.oracle.com systemd[1]: Stopped Remote desktop service (VNC).
[root@lunar2 ~]#
[root@lunar2 ~]# systemctl disable vncserver@:3.service
systemctl stop  vncserver@:3.service
systemctl status vncserver@:3.service
 
Removed symlink /etc/systemd/system/multi-user.target.wants/vncserver@:3.service.
[root@lunar2 ~]# systemctl stop  vncserver@:3.service
[root@lunar2 ~]# systemctl status vncserver@:3.service
● vncserver@:3.service - Remote desktop service (VNC)
   Loaded: loaded (/usr/lib/systemd/system/vncserver@:3.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
 
Mar 22 18:12:23 lunar2.oracle.com systemd[1]: Starting Remote desktop service (VNC)...
Mar 22 18:12:23 lunar2.oracle.com systemd[1]: Started Remote desktop service (VNC).
Mar 22 18:23:32 lunar2.oracle.com systemd[1]: Stopping Remote desktop service (VNC)...
Mar 22 18:23:32 lunar2.oracle.com systemd[1]: Stopped Remote desktop service (VNC).
[root@lunar2 ~]#
[root@lunar2 ~]#

看一下节点2的优化效果:
[root@lunar2 ~]# sar -u 1 10
Linux 3.10.0-327.el7.x86_64 (lunar2.oracle.com)         03/22/2016      _x86_64_        (2 CPU)
 
06:24:01 PM     CPU     %user     %nice   %system   %iowait    %steal     %idle
06:24:02 PM     all      0.51      0.00      0.51      0.00      0.00     98.99
06:24:03 PM     all      0.50      0.00      1.01      0.00      0.00     98.49
06:24:04 PM     all      0.00      0.00      0.50      0.00      0.00     99.50
06:24:05 PM     all      0.44      0.00      0.00      0.00      0.00     99.56
06:24:06 PM     all      0.00      0.00      0.50      0.00      0.00     99.50
06:24:07 PM     all      0.50      0.00      1.51      0.00      0.00     97.99
06:24:08 PM     all      0.50      0.00      0.50      0.00      0.00     99.00
06:24:09 PM     all      0.00      0.00      0.50      0.00      0.00     99.50
06:24:10 PM     all      0.00      0.00      0.00      0.00      0.00    100.00
06:24:11 PM     all      0.00      0.00      0.00      0.00      0.00    100.00
Average:        all      0.25      0.00      0.50      0.00      0.00     99.26
[root@lunar2 ~]#

相关文章

精彩推荐