Cafemmo Club
← Quay lại danh sách

Tăng tốc tốc độ import mysql

wpresources10/05/20213430 lượt xem17 bình luận

Có nhiều nguyên nhân khiến bạn cần import lại mysql.VD như chuyển qua vps khác... Nếu file nhỏ thì cứ import như bình thường,còn nếu file lớn hơn GB thì bạn có thể dùng cách sau

+sudo nano /etc/mysql/my.cnf;


[mysqld]
innodb_buffer_pool_size = 8G
innodb_log_buffer_size = 256M
innodb_log_file_size = 1G
innodb_write_io_threads = 16
innodb_flush_log_at_trx_commit = 0
+sudo service mysql restart --innodb-doublewrite=0; +sudo mysql -uuser -ppass databaseName<backup.sql +Khi backup song thì vào lại my.cnf xóa những dòng trên đi.Vì để lại nó sẽ tiêu tốn ram,cpu không cần thiết +sudo service mysql restart

Ý nghĩa những thông số trên,để nguyên tiếng anh vì mình cũng không hoàn toàn hiểu nó [QUOTE] innodb_buffer_pool_size will cache frequently read data innodb_log_buffer_size : Larger buffer reduces write I/O to Transaction Logs innodb_log_file_size : Larger log file reduces checkpointing and write I/O innodb_write_io_threads : Service Write Operations to .ibd files. According to MySQL Documentation on Configuring the Number of Background InnoDB I/O Threads, each thread can handle up to 256 pending I/O requests. Default for MySQL is 4, 8 for Percona Server. Max is 64. innodb_flush_log_at_trx_commit In the event of a crash, both 0 and 2 can lose once second of data. The tradeoff is that both 0 and 2 increase write performance. I choose 0 over 2 because 0 flushes the InnoDB Log Buffer to the Transaction Logs (ib_logfile0, ib_logfile1) once per second, with or without a commit. Setting 2 flushes the InnoDB Log Buffer only on commit. There are other advantages to setting 0 mentioned by @jynus, a former Percona instructor. [/QUOTE]

Bình luận

Đang tải...

Đang kiểm tra đăng nhập...