我正在尝试对其中包含2亿条记录的表进行分区。并且它会引发异常,因为锁的总数超过了锁表大小。我在网上阅读了一些建议并更改了my.cnf文件。这是配置:
# PER CLIENT SETTINGS #
# bit high but I got tons of ram here #
sort_buffer_size = 2M
read_buffer_size = 2M
binlog_cache_size = 1M
wait_timeout = 31536000
interactive_timeout = 300
max_allowed_packet = 12M
thread_stack = 128K
table_cache = 1024
myisam_sort_buffer_size = 1M
tmp_table_size = 12M
max_heap_table_size = 12M
# LOGGING #
log_queries_not_using_indexes = 1
slow_query_log = 1
slow_query_log_file = /var/lib/mysql/slowquery.log
# MyISAM #
key_buffer_size = 32M
myisam_recover = FORCE,BACKUP
# SAFETY #
max_allowed_packet = 16M
max_connect_errors = 1000000
# BINARY LOGGING #
log_bin = /var/lib/mysql/mysql-bin
expire_logs_days = 14
sync_binlog = 1
# 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
# INNODB #
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 2
innodb-log-file-size = 512M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table = 1
innodb-buffer-pool-size = 40G
我在进行这些更改后重新启动了mysql。它仍然抛出异常。我的服务器有12个内核和48GB Ram,我可以将此服务器专门用于此分区过程。是否有任何建议绕过此异常(超过锁定总数)?
答案 0 :(得分:0)
如果您可以将此服务器专用于分区,则在分区之前使用LOCK TABLES
锁定整个表。另请参阅https://stackoverflow.com/a/7066272/3182500