空闲服务器负载约为 1.4

空闲服务器负载约为 1.4

我已经从 Scalr 的 AMI 启动了一个服务器。Top 一直显示 ~1.4。我预计它会像我之前使用的所有服务器一样为 0。该服务器在 ubuntu-10-04 上运行 mysql 5.1

您可以在下面找到 TOP 输出。

服务器出了什么问题?如何找出导致 CPU 消耗大的原因?

编辑:流程如下:

57 testuser 85.45.44.74:37833 cbar 睡眠 1299
63 testuser 85.45.44.74:40814 cbar 睡眠 81
64 testuser 85.45.44.74:40815 cbar 查询 0 显示完整进程列表

以下是最消耗记忆力的

509 mysql     20   0  482m 370m 4084 S    0 21.3  17:25.74 mysqld
537 root      20   0 38060  12m 2096 S    0  0.7   0:00.20 scalarizr
471 root      20   0 57432  11m 2964 S    0  0.7   0:00.32 scalarizr
514 root      20   0  8776 3008 2340 S    0  0.2   0:00.14 sshd
585 root      20   0 20940 2916 1832 S    0  0.2   0:00.02 console-kit-dae
1744 root      20   0  4588 1912 1524 S    0  0.1   0:00.02 bash
 1 root      20   0  2808 1392 1108 S    0  0.1   0:00.14 init
395 syslog    20   0 34672 1204  932 S    0  0.1   0:00.03 rsyslogd
1985 root      20   0  2540 1188  940 R    0  0.1   0:00.00 top
 476 root      20   0  2400  924  732 S    0  0.1   0:00.00 cron
 419 root      20   0  5572  852  532 S    0  0.0   0:00.00 sshd

-

Jtop - 15:32:19 up  3:33,  1 user,  load average: 1.28, 1.28, 1.22
Tasks:  76 total,   1 running,  75 sleeping,   0 stopped,   0 zombie
Cpu(s):  4.0%us,  0.4%sy,  0.0%ni, 93.0%id,  2.1%wa,  0.0%hi,  0.0%si,  0.4%st
Mem:   1781976k total,  1715924k used,    66052k free,    13300k buffers
Swap:   917496k total,     1696k used,   915800k free,  1233484k cached

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
1 root      20   0  2808 1392 1108 S    0  0.1   0:00.14 init               
2 root      20   0     0    0    0 S    0  0.0   0:00.00 kthreadd           
3 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/0        
4 root      20   0     0    0    0 S    0  0.0   0:00.00 ksoftirqd/0        
5 root      RT   0     0    0    0 S    0  0.0   0:00.00 watchdog/0         
6 root      20   0     0    0    0 S    0  0.0   0:00.01 events/0           
7 root      20   0     0    0    0 S    0  0.0   0:00.00 cpuset             
8 root      20   0     0    0    0 S    0  0.0   0:00.00 khelper            
9 root      20   0     0    0    0 S    0  0.0   0:00.00 netns              
10 root      20   0     0    0    0 S    0  0.0   0:00.00 async/mgr          
11 root      20   0     0    0    0 S    0  0.0   0:00.00 xenwatch           
12 root      20   0     0    0    0 S    0  0.0   0:00.00 xenbus             
14 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/1        
15 root      20   0     0    0    0 S    0  0.0   0:00.00 ksoftirqd/1        
16 root      RT   0     0    0    0 S    0  0.0   0:00.00 watchdog/1         
17 root      20   0     0    0    0 S    0  0.0   0:00.00 events/1           
18 root      20   0     0    0    0 S    0  0.0   0:00.00 sync_supers        
19 root      20   0     0    0    0 S    0  0.0   0:00.00 bdi-default        
20 root      20   0     0    0    0 S    0  0.0   0:00.00 kintegrityd/0      
21 root      20   0     0    0    0 S    0  0.0   0:00.00 kintegrityd/1      
22 root      20   0     0    0    0 S    0  0.0   0:00.00 kblockd/0          
23 root      20   0     0    0    0 S    0  0.0   0:00.00 kblockd/1          
24 root      20   0     0    0    0 S    0  0.0   0:00.00 kseriod            
27 root      20   0     0    0    0 S    0  0.0   0:00.00 khungtaskd         
29 root      20   0     0    0    0 S    0  0.0   0:00.95 kswapd0            
30 root      20   0     0    0    0 S    0  0.0   0:00.00 aio/0              
31 root      20   0     0    0    0 S    0  0.0   0:00.00 aio/1              
32 root      20   0     0    0    0 S    0  0.0   0:00.00 jfsIO              
33 root      20   0     0    0    0 S    0  0.0   0:00.00 jfsCommit          
34 root      20   0     0    0    0 S    0  0.0   0:00.00 jfsCommit          
35 root      20   0     0    0    0 S    0  0.0   0:00.00 jfsSync            
36 root      20   0     0    0    0 S    0  0.0   0:00.00 xfs_mru_cache      
37 root      20   0     0    0    0 S    0  0.0   0:00.00 xfslogd/0          
38 root      20   0     0    0    0 S    0  0.0   0:00.00 xfslogd/1          
39 root      20   0     0    0    0 S    0  0.0   0:00.00 xfsdatad/0         
40 root      20   0     0    0    0 S    0  0.0   0:00.00 xfsdatad/1         
41 root      20   0     0    0    0 S    0  0.0   0:00.00 xfsconvertd/0      
42 root      20   0     0    0    0 S    0  0.0   0:00.00 xfsconvertd/1      
43 root      20   0     0    0    0 S    0  0.0   0:00.00 glock_workqueue    
44 root      20   0     0    0    0 S    0  0.0   0:00.00 glock_workqueue    
45 root      20   0     0    0    0 S    0  0.0   0:00.00 delete_workqueu    
46 root      20   0     0    0    0 S    0  0.0   0:00.00 delete_workqueu    
47 root      15  -5     0    0    0 S    0  0.0   0:00.00 kslowd000          
48 root      15  -5     0    0    0 S    0  0.0   0:00.00 kslowd001          
49 root      20   0     0    0    0 S    0  0.0   0:00.00 crypto/0           
50 root      20   0     0    0    0 S    0  0.0   0:00.00 crypto/1           
53 root      20   0     0    0    0 S    0  0.0   0:00.00 net_accel/0        
54 root      20   0     0    0    0 S    0  0.0   0:00.00 net_accel/1        
55 root      20   0     0    0    0 S    0  0.0   0:00.00 sfc_netfront/0     
56 root      20   0     0    0    0 S    0  0.0   0:00.00 sfc_netfront/1     
57 root      20   0     0    0    0 S    0  0.0   0:00.00 kstriped           
58 root      20   0     0    0    0 S    0  0.0   0:00.01 kjournald          
86 root      20   0  2340  628  624 S    0  0.0   0:00.05 upstart-udev-br    
88 root      16  -4  2340  344  340 S    0  0.0   0:00.03 udevd              
172 root      18  -2  2336  392  368 S    0  0.0   0:00.00 udevd              
173 root      18  -2  2336  308  304 S    0  0.0   0:00.00 udevd              
310 root      20   0     0    0    0 S    0  0.0   0:00.10 flush-8:1          
324 root      20   0  2256  140  136 S    0  0.0   0:00.00 dhclient3          
365 root      20   0     0    0    0 S    0  0.0   0:00.00 kjournald          
368 root      20   0     0    0    0 S    0  0.0   0:00.03 kjournald          
395 syslog    20   0 34672 1204  932 S    0  0.1   0:00.03 rsyslogd           
411 messageb  20   0  2688  776  644 S    0  0.0   0:00.00 dbus-daemon        
419 root      20   0  5572  852  532 S    0  0.0   0:00.00 sshd               
471 root      20   0 57432  11m 2964 S    0  0.7   0:00.28 scalarizr          
476 root      20   0  2400  924  732 S    0  0.1   0:00.00 cron               
477 daemon    20   0  2272  444  304 S    0  0.0   0:00.00 atd                
493 root       0 -20     0    0    0 S    0  0.0   0:00.00 loop0              
499 root      20   0     0    0    0 S    0  0.0   0:00.00 kjournald          
509 mysql     20   0  481m 368m 3760 S    0 21.2  17:24.94 mysqld             
514 root      20   0  8776 3008 2340 S    0  0.2   0:00.10 sshd               
537 root      20   0 38060  12m 2096 S    0  0.7   0:00.18 scalarizr          
585 root      20   0 20940 2916 1832 S    0  0.2   0:00.02 console-kit-dae    
763 root      20   0  1812  544  468 S    0  0.0   0:00.00 getty              
804 root      20   0  2024  660  544 S    0  0.0   0:00.00 sftp-server



#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port        = 3306
socket      = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0

[mysqld]
log_bin = /mnt/dbstorage/mysql-misc/binlog.log

#
# * Basic Settings
#

#
# * IMPORTANT
#   If you make changes to these settings and your system uses apparmor, you may
#   also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.
#

user        = mysql
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /mnt/dbstorage/mysql-data/
tmpdir      = /tmp
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address       = 127.0.0.1
#
# * Fine Tuning
#
key_buffer      = 300M
max_allowed_packet  = 16M
thread_stack        = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
max_connections        = 200
max_heap_table_size = 50000000
#table_cache            = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit   = 1M
query_cache_size        = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1

log_error                = /var/log/mysql/error.log

# Here you can see queries with especially long duration
#log_slow_queries   = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id      = 1
#log_bin            = /var/log/mysql/mysql-bin.log
expire_logs_days    = 10
max_binlog_size         = 100M
#binlog_do_db       = include_database_name
#binlog_ignore_db   = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem



[mysqldump]
quick
quote-names
max_allowed_packet  = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer      = 16M

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/

!include /etc/mysql/farm-replication.cnf

答案1

根据上面的评论,MySQL 似乎正在消耗内存。显示上面的完整进程列表,看看它是否正在执行任何操作,如果没有,只需重新启动 MySQL 即可解决问题。如果仍然没有帮助,my.cnf 的内容将帮助我们进一步诊断。

答案2

由于这是一台服务器,是否有其他机器正在向其发出请求?也许几分钟前有一连串的外部调用。这可能解释了 mysql 的使用情况,但没有显示其他进程正在使用 CPU。

既然您关心的是 top 在这台机器上显示的内容与其他机器上的差异,那么这里的差异是什么:这是一台单处理器机器还是磁盘速度比其他机器慢?或者这是不同版本的 Ubuntu?提供两台机器的 cpuinfo 和系统版本信息可以解决这些问题。

相关内容