加快InnoDB mysql数据库导入速度

发布于 2024-11-18 07:03:00 字数 1165 浏览 1 评论 0原文

我刚买了一台新的 mysql 机器(16gb 内存,4 个 SAS 15k rpm 300GB 驱动器,RAID10),所以机器速度相当快。

我一直在导入几个数据库,每个数据库有几百万个项目,但需要相当长的时间,比我想象的要长。我看到每秒大约有 1000 次插入,我相信它应该能够做更多的事情。此外,进程运行的时间越长,速度就越慢。

这是我的配置,任何加快速度的技巧,但这不会损害数据的可靠性。

[mysqld]
skip-name-resolve
datadir=/var/lib/mysql
#socket=/tmp/mysql.sock
log-error=/var/log/mysqld.log
port=48221
user=mysql
old_passwords=0
max_connections = 1500
table_cache = 1024
max_allowed_packet = 16M
sort_buffer_size = 2M
thread_cache = 8
thread_concurrency = 32
query_cache_size = 0M
query_cache_type = 0
default-storage-engine = innodb
transaction_isolation = REPEATABLE-READ
tmp_table_size = 256M
long_query_time = 3
log_slow_queries = 1
innodb_additional_mem_pool_size=48M
innodb_flush_log_at_trx_commit=2
innodb_log_buffer_size=32M
innodb_buffer_pool_size=2G
innodb_autoinc_lock_mode=2
innodb_io_capacity=500
innodb_read_io_threads=16
innodb_write_io_threads=8
innodb_buffer_pool_size = 5000M
innodb_lock_wait_timeout = 300
innodb_max_dirty_pages_pct = 90
innodb_thread_concurrency =32

[mysqldump]
quick
single-transaction

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

i just got a new mysql machine (16gb ram, 4x SAS 15k rpm 300GB drives in RAID10), so quite a fast machine.

I have been importing a few databases with a couple million items each, but it takes quite a long time, longer than it should I think. I'm seeing about 1000 inserts per second, and I believe it should be able to do much more. Also the longer the process runs, the slower it gets.

This is my config, any tips to speed things up, but that doesn't hurt reliability of the data.

[mysqld]
skip-name-resolve
datadir=/var/lib/mysql
#socket=/tmp/mysql.sock
log-error=/var/log/mysqld.log
port=48221
user=mysql
old_passwords=0
max_connections = 1500
table_cache = 1024
max_allowed_packet = 16M
sort_buffer_size = 2M
thread_cache = 8
thread_concurrency = 32
query_cache_size = 0M
query_cache_type = 0
default-storage-engine = innodb
transaction_isolation = REPEATABLE-READ
tmp_table_size = 256M
long_query_time = 3
log_slow_queries = 1
innodb_additional_mem_pool_size=48M
innodb_flush_log_at_trx_commit=2
innodb_log_buffer_size=32M
innodb_buffer_pool_size=2G
innodb_autoinc_lock_mode=2
innodb_io_capacity=500
innodb_read_io_threads=16
innodb_write_io_threads=8
innodb_buffer_pool_size = 5000M
innodb_lock_wait_timeout = 300
innodb_max_dirty_pages_pct = 90
innodb_thread_concurrency =32

[mysqldump]
quick
single-transaction

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

做个ˇ局外人 2024-11-25 07:03:00

您可以在导入期间删除索引,并在完成后重建它们。您还应该尝试对插入进行分块,在自动提交和单个事务中的所有插入之间寻找最佳点。

You could drop the indexes for the duration of the import, and rebuild them when it's done. You should also try chunking the inserts, searching for the sweet spot between autocommit and all inserts in a single transaction.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文