简体   繁体   English

MySQL正在使用系统文件缓存,而不是直接使用RAM

[英]Mysql is using system file cache, not RAM directly

I have an Ubuntu 64-bit system and running Mysql version 5.5.32-0ubuntu0.12.04.1-log. 我有一个Ubuntu 64位系统,并运行Mysql版本5.5.32-0ubuntu0.12.04.1-log。 The machine has 64 GB ram. 该机器具有64 GB内存。

I have a pretty huge database which almost has 90 GB of data and one table with 250.000.000 rows. 我有一个非常庞大的数据库,几乎拥有90 GB的数据和一个具有250.000.000行的表。

My problem is, that the mysqld process does not take much memory. 我的问题是,mysqld进程不会占用太多内存。 Just between 2-5 GB. 介于2-5 GB之间。 But the memory of the system is fully used for the file cache. 但是系统的内存已完全用于文件缓存。

I restarted the server, there were 63 GB memory free. 我重新启动服务器,有63 GB可用内存。 Once I started to execute larger queries, the amount of free memory decreases, while the amount of file cached increases. 一旦开始执行较大的查询,可用内存量就会减少,而缓存的文件量会增加。 So mysql is not loading the data in its RAM, but it uses the file cache. 因此,mysql并未将数据加载到其RAM中,而是使用了文件缓存。 Queries are very slow. 查询非常慢。 When I query the big table, which - according to explain - uses an index and only has 500.000 rows to consider, it takes minutes. 当我查询大表时(据解释),该表使用索引并且仅考虑500.000行,因此需要几分钟。

Do you have any explanation for this phenomen? 您对此现象有什么解释吗?

Here is my my.cnf. 这是我的my.cnf。 (This is actually the config of my slave, but it shows exactly the same behaviour) My tables are all InnoDB: (这实际上是我的奴隶的配置,但是它显示出完全相同的行为)我的表都是InnoDB:

[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock

[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock
nice            = 0

[mysqld]
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

bind-address            = 127.0.0.1

key_buffer              = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8

myisam-recover         = BACKUP

query_cache_limit       = 1M
query_cache_size        = 16M

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

server-id               = 2
log_bin                 = /var/log/mysql/mysql-bin.log
expire_logs_days        = 10
max_binlog_size         = 100M


[innodb]

innodb_buffer_pool_size = 55G
innodb_log_file_size    = 256M
innodb_log_buffer_size  = 4M
innodb_flush_log_at_trx_commit=2
innodb_thread_concurrency=0
innodb_file_per_table = 1  # (this is not respected as I changed it after the first    database was created). So my ibdata1 file is over 80GB in size


max_connections        = 1000                # wenn gleichzeitig viele User zugreifen
table_cache            = 10000                # abgeleitet von max_connections, könnte sogar höher sein
tmp_table_size          = 5000M                # wichtig wg. JOINs, zu kleiner Wert macht die extrem langsam
max_heap_table_size     = 5000M

[mysqldump]
quick
quote-names
max_allowed_packet      = 16M

[mysql]

[isamchk]
key_buffer              = 16M

!includedir /etc/mysql/conf.d/

将key_buffer的大小增加到128M并将max_allowed_pa​​cket增大到128M ,因为这将加快查询的执行速度

I finally figured out was the problem was. 我终于弄清楚了问题所在。 The

innodb_buffer_pool_size = 55G innodb_buffer_pool_size = 55G

does not belong in the [innodb] section, but in the [mysqld] section. 不属于[innodb]部分,但属于[mysqld]部分。

All the innodb configs needed to be placed in the mysqld section. 所有的innodb配置都需要放在mysqld部分中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM