我正在使用带有以下存储引擎的MariaDB(10.1.21):
系统配置是:
我已经尝试使用pt-mysql-summary
工具来识别内存使用情况,并且当服务器上没有运行任何进程时,它会显示90%的innodb缓冲池大小已填满。
我还尝试重新启动MariaDB服务器,这只会减少内存大约1-2个小时,然后就会耗尽内存。
任何线索为什么消耗太多内存?
在下面分享我的配置:
在my.cnf
[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]
#performance_schema=ON
tmp_table_size=16M
max_heap_table_size=16M
skip-log-bin
#table_open_cache =16384
#table_definition_cache =16384
#
# * 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
lc_messages = en_US
skip-external-locking
#bind-address = 127.0.0.1
#skip-networking
# SAFETY #
max_allowed_packet= 16M
max-connect-errors = 1000000
skip-name-resolve
#sql-mode = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY
# CACHES AND LIMITS #
tmp-table-size = 32M
max-heap-table-size = 32M
query-cache-type = 0
query-cache-size = 0
max-connections = 500
thread-cache-size = 50
open-files-limit = 65535
table-definition-cache = 1024
table-open-cache = 2048
# LOGGING #
log_warnings = 2
slow_query_log =1
log-output = TABLE
long_query_time = 5
log_slow_verbosity = query_plan
log-error =/var/log/mysql/system_error.err
# INNODB #
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 2
innodb-log-file-size = 128M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table = 1
innodb-buffer-pool-size = 1720M
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
#no-auto-rehash # faster start of mysql but no tab completion
[isamchk]
key_buffer = 16M
TokuDB.cnf
plugin-load-add=ha_tokudb.so
tokudb_data_dir=/var/lib/mysql/toku_db_data
tokudb_read_block_size=64k
tokudb_row_format=tokudb_zlib
tokudb_directio=on
Spider.cnf
[mariadb]
#spider_internal_limit =1
spider_direct_order_limit =1
spider_skip_default_condition =1
spider_casual_read =1
spider_bgs_mode =2
spider_direct_dup_insert =1
spider_auto_increment_mode =2
#optimizer_switch='engine_condition_pushdown=on'
#optimizer_switch='mrr=on,mrr_sort_keys=off'
答案 0 :(得分:1)
innodb-buffer-pool-size = 1720M
对于3GB机器而言太大了,特别是如果TokuDB和Spider也在使用中。
真正的问题是,"是否有任何交换"?如果没有交换,则没有问题。如果有交换,那么第一道防线是降低该设置。我建议500M。对于MySQL的性能,交换非常不好。
看到90%是正常的。 92%是机器抽样(Innodb_buffer_pool_bytes_data / innodb_buffer_pool_size)
的中值。由于buffer_pool是一个缓存,因此#34; full"是正常的。大多数时候。 (它很少超过98% - 很可能留下一些空间可以快速重复使用。)如果它在运行几个小时之后低于50%,我会说innodb_buffer_pool_size
对于数据集来说太大了问题。
建议降低到long_query_time = 2
以便捕获更快但频繁的查询。
答案 1 :(得分:0)
以下文档可以帮助您正确配置内存,并根据数据库引擎选择教育您对内存分配进行默认分配。
https://mariadb.com/kb/en/mariadb/mariadb-memory-allocation/