GreatSQL社区

搜索

[讨论中] 使用source命令导入慢问题

301 3 2025-2-28 16:07
GreatSQL版本:8.0.32-26

导入文件大小:1.7G
导入时间:15:26 ~ 16:05
耗时:

配置:
  1. [client]
  2. socket    = /data/soft/GreatSQL/mysql.sock
  3. default-character-set = utf8mb4

  4. [mysql]
  5. loose-skip-binary-as-hex
  6. prompt = "(\\D)[\\u@GreatSQL][\\d]>"
  7. no-auto-rehash
  8. default-character-set = utf8mb4

  9. [mysqld]
  10. user    = mysql
  11. #port    = 3306
  12. #server_id = 3306
  13. basedir = /usr/
  14. #datadir    = /data/soft/GreatSQL
  15. #socket    = /data/soft/GreatSQL/mysql.sock
  16. pid-file = mysql.pid
  17. character-set-server = utf8mb4
  18. collation-server = utf8mb4_0900_ai_ci
  19. init_connect = "SET NAMES utf8mb4 COLLATE utf8mb4_0900_ai_ci"
  20. skip-character-set-client-handshake
  21. skip_name_resolve = ON
  22. default_time_zone = "+8:00"
  23. bind_address = "0.0.0.0"
  24. secure_file_priv = /data/soft/GreatSQL

  25. # Performance
  26. lock_wait_timeout = 3600
  27. open_files_limit    = 65535
  28. back_log = 1024
  29. max_connections = 1024
  30. max_connect_errors = 1000000
  31. table_open_cache = 2048
  32. table_definition_cache = 2048
  33. sort_buffer_size = 4M
  34. join_buffer_size = 4M
  35. read_buffer_size = 8M
  36. read_rnd_buffer_size = 4M
  37. bulk_insert_buffer_size = 64M
  38. thread_cache_size = 768
  39. interactive_timeout = 600
  40. wait_timeout = 600
  41. tmp_table_size = 96M
  42. max_heap_table_size = 96M
  43. max_allowed_packet = 64M
  44. net_buffer_shrink_interval = 180
  45. sql_generate_invisible_primary_key = ON
  46. loose-lock_ddl_polling_mode = ON
  47. loose-lock_ddl_polling_runtime = 200

  48. # Logs
  49. log_timestamps = SYSTEM
  50. log_error = mysqld.log
  51. log_error_verbosity = 3

  52. # 慢查询日志
  53. slow_query_log = ON
  54. log_slow_extra = ON
  55. slow_query_log_file = slow.log
  56. long_query_time = 0.01
  57. log_queries_not_using_indexes = ON
  58. log_throttle_queries_not_using_indexes = 60
  59. min_examined_row_limit = 100
  60. log_slow_admin_statements = ON
  61. log_slow_replica_statements = ON
  62. log_slow_verbosity = FULL

  63. # binlog
  64. log_bin = binlog
  65. binlog_format = ROW
  66. sync_binlog = 1
  67. binlog_cache_size = 4M
  68. max_binlog_cache_size = 6G
  69. max_binlog_size = 1G
  70. binlog_space_limit = 500G
  71. binlog_rows_query_log_events = ON
  72. binlog_expire_logs_seconds = 604800
  73. binlog_checksum = CRC32
  74. binlog_order_commits = OFF
  75. gtid_mode = ON
  76. enforce_gtid_consistency = ON

  77. # InnoDB
  78. innodb_buffer_pool_size = 8G
  79. innodb_buffer_pool_instances = 8
  80. innodb_data_file_path = ibdata1:12M:autoextend
  81. innodb_flush_log_at_trx_commit = 1
  82. innodb_log_buffer_size = 32M
  83. innodb_redo_log_capacity = 4G
  84. innodb_doublewrite_files = 2
  85. innodb_max_undo_log_size = 4G
  86. innodb_io_capacity = 4000
  87. innodb_io_capacity_max = 8000
  88. innodb_open_files = 65534
  89. innodb_flush_method = O_DIRECT
  90. innodb_lru_scan_depth = 4000
  91. innodb_lock_wait_timeout = 10
  92. innodb_rollback_on_timeout = ON
  93. innodb_print_all_deadlocks = ON
  94. innodb_online_alter_log_max_size = 4G
  95. innodb_print_ddl_logs = ON
  96. innodb_status_file = ON
  97. innodb_status_output = OFF
  98. innodb_status_output_locks = ON
  99. innodb_sort_buffer_size = 64M
  100. innodb_adaptive_hash_index = OFF
  101. innodb_numa_interleave = OFF
  102. innodb_spin_wait_delay = 20
  103. innodb_print_lock_wait_timeout_info = ON
  104. innodb_change_buffering = none
  105. kill_idle_transaction = 300
  106. innodb_data_file_async_purge = ON

  107. #innodb monitor settings
  108. #innodb_monitor_enable = "module_innodb,module_server,module_dml,module_ddl,module_trx,module_os,module_purge,module_log,module_lock,module_buffer,module_index,module_ibuf_system,module_buffer_page,module_adaptive_hash"

  109. #pfs settings
  110. performance_schema = 1
  111. #performance_schema_instrument = '%memory%=on'
  112. performance_schema_instrument = '%lock%=on'

  113. [mysqld@3306]
  114. datadir=/data/soft/GreatSQL/3306
  115. socket=/data/soft/GreatSQL/3306/mysql.sock
  116. port=3306
  117. server_id=103306
  118. log-error=/data/soft/GreatSQL/3306/mysqld.log

  119. [mysqld@3307]
  120. datadir=/data/soft/GreatSQL/3307
  121. socket=/data/soft/GreatSQL/3307/mysql.sock
  122. port=3307
  123. server_id=103307
  124. log-error=/data/soft/GreatSQL/3307/mysqld.log
复制代码
服务器IO:
2.png


MySQL版本:5.7.44
导入文件大小:1.7G
导入时间:15:29 ~ 15:35
耗时:6分钟

配置:
  1. [client]
  2. #password       = your_password
  3. #port            = 3306
  4. #socket          = /data/soft/mysql3306/mysql.sock
  5. #default-character-set = utf8mb4

  6. [mysqld@3306]
  7. port            = 3306
  8. socket          = /data/soft/mysql/3306/mysql.sock
  9. datadir         = /data/soft/mysql/3306
  10. #skip-external-locking
  11. #skip_name_resolve = 1
  12. key_buffer_size = 256M
  13. max_allowed_packet = 512M
  14. table_open_cache = 512
  15. sort_buffer_size = 16M
  16. read_buffer_size = 16M
  17. read_rnd_buffer_size = 64M
  18. myisam_sort_buffer_size = 64M
  19. thread_cache_size = 4
  20. query_cache_size= 16M
  21. query_cache_type=1
  22. character_set_server = utf8mb4
  23. collation_server=utf8mb4_general_ci
  24. max_connections = 500
  25. innodb_read_io_threads = 4
  26. innodb_write_io_threads = 4
  27. wait_timeout=2880000
  28. interactive_timeout = 2880000
  29. lower_case_table_names=1

  30. event_scheduler=ON

  31. log-bin=mysql-bin
  32. binlog_format=mixed

  33. log_error = /data/soft/mysql/3306/mysql.log
  34. slow_query_log = 1
  35. long_query_time = 1
  36. slow_query_log_file = /data/soft/mysql/3306/slow.log
  37. log_slow_admin_statements = 1

  38. server-id       = 100
  39. expire_logs_days = 30

  40. innodb_buffer_pool_size = 8G
  41. innodb_buffer_pool_instances = 1
  42. innodb_buffer_pool_load_at_startup = 1
  43. innodb_flush_neighbors = 1
  44. innodb_print_all_deadlocks = 1

  45. innodb_sort_buffer_size = 16M
  46. innodb_flush_log_at_trx_commit=2

  47. [mysqld@3307]
  48. port            = 3307
  49. socket          = /data/soft/mysql/3307/mysql.sock
  50. datadir         = /data/soft/mysql/3307
  51. #skip-external-locking
  52. #skip_name_resolve = 1
  53. key_buffer_size = 256M
  54. max_allowed_packet = 512M
  55. table_open_cache = 512
  56. sort_buffer_size = 16M
  57. read_buffer_size = 16M
  58. read_rnd_buffer_size = 64M
  59. myisam_sort_buffer_size = 64M
  60. thread_cache_size = 4
  61. query_cache_size= 16M
  62. query_cache_type=1
  63. character_set_server = utf8mb4
  64. collation_server=utf8mb4_general_ci
  65. max_connections = 500
  66. innodb_read_io_threads = 4
  67. innodb_write_io_threads = 4
  68. wait_timeout=2880000
  69. interactive_timeout = 2880000
  70. lower_case_table_names=1

  71. event_scheduler=ON

  72. log-bin=mysql-bin
  73. binlog_format=mixed

  74. log_error = /data/soft/mysql/3307/mysql.log
  75. slow_query_log = 1
  76. long_query_time = 3
  77. slow_query_log_file = /data/soft/mysql/3307/slow.log
  78. log_slow_admin_statements = 1

  79. server-id       = 101
  80. expire_logs_days = 30

  81. innodb_buffer_pool_size = 8G
  82. innodb_buffer_pool_instances = 1
  83. innodb_buffer_pool_load_at_startup = 1
  84. innodb_flush_neighbors = 1
  85. innodb_print_all_deadlocks = 1

  86. innodb_sort_buffer_size = 16M
  87. innodb_flush_log_at_trx_commit=2

  88. [mysqldump]
  89. quick
  90. max_allowed_packet = 512M
  91. user=bakuser
  92. password=Ba0k1@db_pass

  93. [mysql]
  94. no-auto-rehash

  95. [myisamchk]
  96. key_buffer_size = 128M
  97. sort_buffer_size = 128M
  98. read_buffer = 2M
  99. write_buffer = 2M

  100. [mysqlhotcopy]
  101. interactive-timeout
复制代码
服务器IO:

全部回复(3)
yejr 2025-2-28 22:01:17
1. 可以用下面的方法跑dd简单测试I/O性能(你上面的方法要加上oflag参数)
time dd oflag=direct if=/dev/zero of=./zero bs=1M count=20480

2. source方式导入的是串行,不是并行

3. 导入期间,可以关闭双1以提速。不知道什么是双1的话,参考:https://greatsql.cn/docs/8.0.32- ... E6%88%96-%E5%8F%8C0
earl86 2025-3-3 09:35:38
source 慢正常,可以试试 mydumper 并行导入导出
caihe.li 2025-3-3 11:23:34
如果允许没有特殊字符的话,可以考虑使用LOAD DATA的方式导入导出,greatsql有并行LOAD DATA,可以参考这个链接:https://greatsql.cn/docs/8.0.32- ... -parallel-load.html
alexyj

5

主题

0

博客

22

贡献

新手上路

Rank: 1

积分
40

合作电话:010-64087828

社区邮箱:greatsql@greatdb.com

社区公众号
社区小助手
QQ群
GMT+8, 2025-4-3 23:56 , Processed in 0.024352 second(s), 18 queries , Redis On.
快速回复 返回顶部 返回列表