使用高VIRT内存和RES的Mysql是分区的

有没有办法减lessVIRT的使用? 我不确定这么高的用途是什么原因。 它也达到了12g。

使用top命令

Tasks: 348 total, 1 running, 344 sleeping, 0 stopped, 3 zombie Cpu(s): 1.4%us, 0.2%sy, 0.0%ni, 98.3%id, 0.1%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 39131036k total, 4522864k used, 34608172k free, 228124k buffers Swap: 16764924k total, 0k used, 16764924k free, 1316196k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 26760 www-data 20 0 312m 39m 4292 S 11 0.1 0:01.84 /usr/sbin/apache2 - 27149 www-data 20 0 312m 38m 3760 S 11 0.1 0:00.34 /usr/sbin/apache2 - 27193 www-data 20 0 312m 39m 4984 S 11 0.1 0:00.90 /usr/sbin/apache2 - 1103 mysql 20 0 9.8g 195m 8244 S 1 0.5 5:40.69 /usr/sbin/mysqld 27180 www-data 20 0 0 0 0 Z 1 0.0 0:00.47 [apache2] <defunct> 66 root 20 0 0 0 0 S 0 0.0 0:00.23 [kworker/15:0] 8037 ntp 20 0 31496 1588 1244 S 0 0.0 0:01.13 /usr/sbin/ntpd -p / 26676 www-data 20 0 332m 58m 3960 S 0 0.2 0:01.73 /usr/sbin/apache2 - 26737 www-data 20 0 290m 16m 3476 S 0 0.0 0:00.23 /usr/sbin/apache2 - 26738 www-data 20 0 312m 39m 4292 S 0 0.1 0:00.68 /usr/sbin/apache2 - 26772 www-data 20 0 289m 15m 3928 S 0 0.0 0:00.41 /usr/sbin/apache2 - 26883 www-data 20 0 312m 39m 4300 S 0 0.1 0:00.48 /usr/sbin/apache2 - 27150 www-data 20 0 284m 8372 1516 S 0 0.0 0:00.02 /usr/sbin/apache2 - 27154 www-data 20 0 312m 39m 3876 S 0 0.1 0:00.44 /usr/sbin/apache2 - 27191 www-data 20 0 329m 55m 3644 S 0 0.1 0:00.44 /usr/sbin/apache2 - 27222 webaau 20 0 17568 1636 1072 R 0 0.0 0:00.06 top 1 root 20 0 24428 2388 1352 S 0 0.0 0:03.60 /sbin/init 

my.cnf中

 # # 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] # # * Basic Settings # user = mysql pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp lc-messages-dir = /usr/share/mysql 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 = 16M 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 = 300 #table_cache = 64 #thread_concurrency = 10 # # * Query Cache Configuration # query_cache_limit = 1M query_cache_size = 64M #added by SRTPL # changed qauery_cache_size from 16M to 32 tmp_table_size = 64M max_heap_table_size = 64M table_cache = 500 wait_timeout = 900 interactive_timeout = 900 #2880 #End of adding # # * 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 # # Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf. # # 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/ 

我遇到的另一个问题是,实际的内存使用率很高,虽然没有进程使用内存。 在my.cnf中有一些tweeking后,重新启动实际mem的高使用率不会再发生。

使用Ubuntu 12.04
5.5.22-0ubuntu1
Apache2.2.22
PHP版本5.3.10-1ubuntu3.1

MySQL只映射了内存页面,实际上并没有使用它们。 VIRT !=内存使用。 Linux内存使用情况有时可能会非常混乱。

你可以从你自己的顶级输出中看到,没有使用交换,而且RAM也大部分都没有使用。