MySQL DBA好帮手

Wesley13
• 阅读 620

导读

作者:蒋乐兴    MySQL-DBA 目前在 github 上维护着两套 MySQL 开源工具 mysqltools & dbm(dbm-agent dbm-center),对机器学习和程序化交易也有些心得。

MySQL DBA好帮手

一想到你在关注我就忍不住有点紧张

目录

  • 用dbm来解放生产力

  • 安装&初始化dbm-agent

  • 一行命令解决安装单机的问题

  • 一行命令解决增加slave的问题

  • 一行命令解决搭建MGR集群的问题

  • dbm-agent建设出来的实例质量如何

一、用dbm来解放生产力

对于 dbm 来说不管你是搭建单机、主从复制、异或是 MGR 都只需要一行命令就能高效、高质量的解决;并且几乎不会有任何成本(dbm是全开源的,包含dbm-agent,dbm-center),下面先来检验一下 dbm-agent 常来的效率提升。

二、安装&初始化dbm-agent

1、 通过 pip3 这个 python 包管理工具来安装 dbm-agent

  1. bash

  2. sudo su

  3. pip3 install dbm-agent

  4. Installing collected packages: dbm-agent

  5. Running setup.py install for dbm-agent ... done

  6. Successfully installed dbm-agent-0.4.2

2、 初始化 dbm-agent

  1. bash

  2. sudo su

  3. dbm-agent init

  4. # 成功后可以看到如下目录结构

  5. tree /usr/local/dbm-agent/

  6. ├── etc

  7. │ ├── dbma.cnf # dbm-agent 的配置文件

  8. │ ├── init-users.sql # 在初始化数据库里将使用这个文件中的用户名和密码来创建用户

  9. │ └── templates

  10. │ ├── create-innodb-cluster.js

  11. │ ├── init-users.sql.jinja

  12. │ ├── mysql-8.0.17.cnf.jinja # mysql-8.0.17 版本对应的配置文件模板

  13. │ ├── mysql-8.0.18.cnf.jinja # mysql-8.0.18 版本对应的配置文件模板

  14. │ ├── mysql-8.0-init-only.jinja # 只有初始化时才用到的配置文件

  15. │ └── mysqld.service.jinja # mysql systemd 配置文件模板

  16. ├── logs # dbm-agent 的日志文件保存目录(只要有守护进程模式下才会向这时写日志)

  17. └── pkg

init 的时候可以通过 --init-pwd 设置 mysql 用户的密码,如果没有指定那么默认为 dbma@0352

3、 下载 mysql 与 mysql-shell 的二进制安装包到 /usr/local/dbm-agent/pkg, 完成后目录的内容如下

  1. bash

  2. tree /usr/local/dbm-agent/pkg

  3. ├── mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz # 各个软件的安装包(要自己下载并保存到这里,dbm-agent不会自动下载它

  4. └── mysql-shell-8.0.18-linux-glibc2.12-x86-64bit.tar.gz # 各个软件的安装包(要自己下载并保存到这里,dbm-agent不会自动下载它)

下面的内容不会再加上 sudo su 了,默认都在 root 下运行


三、一行命令解决安装单机的问题

1、 安装一个监听在 3306 端口上的实例,限制它最大给用 1G 内存

  1. bash

  2. dbma-cli-single-instance --port=3306 --max-mem=1024 install

  3. 2019-11-17 16:48:03,108 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller.install - im - INFO - 1115 - execute checkings for install mysql

  4. 2019-11-17 16:48:03,135 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller._create_mysql_user - im - INFO - 864 - create user 'mysql3306' complete

  5. 2019-11-17 16:48:03,136 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller._create_data_dir - im - INFO - 888 - create datadir '/database/mysql/data/3306' complete

  6. 2019-11-17 16:48:03,137 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller._create_binlog_dir - im - INFO - 910 - create binary dir '/binlog/mysql/binlog/3306' complete

  7. 2019-11-17 16:48:03,138 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller._create_backup_dir - im - INFO - 932 - create backup dir '/backup/mysql/backup/3306' complete

  8. 2019-11-17 16:48:03,138 - dbm-agent.dbma.mysqldeploy.MyCnfInitRender.render_template_file - im - INFO - 518 - using template 'mysql-8.0-init-only.jinja'

  9. 2019-11-17 16:48:03,138 - dbm-agent.dbma.mysqldeploy.MyCnfInitRender.set_template - im - INFO - 457 - using template file 'mysql-8.0-init-only.jinja'

  10. 2019-11-17 16:48:03,175 - dbm-agent.dbma.mysqldeploy.MyCnfInitRender.render - im - INFO - 497 - render mysql config file /tmp/mysql-init.cnf

  11. 2019-11-17 16:48:03,175 - dbm-agent.dbma.mysqldeploy.MyCnfInitRender.render_template_file - im - INFO - 524 - render template file complete

  12. 2019-11-17 16:48:03,175 - dbm-agent.dbma.mysqldeploy.MyCnfMSRender.render_template_file - im - INFO - 548 - using template 'mysql-8.0.18.cnf.jinja'

  13. 2019-11-17 16:48:03,175 - dbm-agent.dbma.mysqldeploy.MyCnfMSRender.set_template - im - INFO - 457 - using template file 'mysql-8.0.18.cnf.jinja'

  14. 2019-11-17 16:48:03,208 - dbm-agent.dbma.mysqldeploy.MyCnfMSRender.render - im - INFO - 497 - render mysql config file /etc/my-3306.cnf

  15. 2019-11-17 16:48:03,208 - dbm-agent.dbma.mysqldeploy.MyCnfMSRender.render_template_file - im - INFO - 554 - render template file complete

  16. 2019-11-17 16:48:03,208 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller._render_production_cnf - im - INFO - 956 - render production cnf complete

  17. 2019-11-17 16:48:03,209 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller._init_database - im - INFO - 1004 - ['/usr/local/mysql-8.0.18-linux-glibc2.12-x86_64/bin/mysqld', '--defaults-file=/tmp/mysql-init.cnf', '--initialize-insecure', '--user=mysql3306', '--init-file=/usr/local/dbm-agent/etc/init-users.sql']

  18. 2019-11-17 16:48:13,963 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller._init_database - im - INFO - 1011 - init database complete

  19. 2019-11-17 16:48:13,967 - dbm-agent.dbma.mysqldeploy.MySQLSystemdRender.render - im - INFO - 666 - render systemd config file complete

  20. 2019-11-17 16:48:13,967 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller._config_systemd - im - INFO - 1027 - mysql systemd config complete

  21. 2019-11-17 16:48:14,146 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller._enable_mysql - im - INFO - 1038 - config mysql auto start on boot complete

  22. 2019-11-17 16:48:16,172 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller._start_mysql - im - INFO - 1068 - start mysql complete

  23. 2019-11-17 16:48:16,173 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller._export_path - im - INFO - 1078 - export path complete

  24. 2019-11-17 16:48:16,177 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller._export_header_file - im - INFO - 1106 - export header file complete

  25. 2019-11-17 16:48:16,177 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller._export_so - im - INFO - 1093 - so file has been exported

  26. 2019-11-17 16:48:16,177 - dbm-agent.dbma.mysqldeploy.SingleInstanceInstaller.install - im - INFO - 1150 - install mysql single instance complete

2、 检查进程是否运行

  1. bash

  2. ps -ef | grep mysql

  3. mysql33+ 7418 1 1 16:48 ? 00:00:02 /usr/local/mysql-8.0.18-linux-glibc2.12-x86_64/bin/mysqld --defaults-file=/etc/my-3306.cnf

  4. root 7463 7271 0 16:51 pts/0 00:00:00 grep --color=auto mysql

3、 连接进去测试一下

  1. sql

  2. mysql -h127.0.0.1 -P3306 -uroot -pdbma@0352

  3. mysql: [Warning] Using a password on the command line interface can be insecure.

  4. Welcome to the MySQL monitor. Commands end with ; or \g.

  5. Your MySQL connection id is 8

  6. Server version: 8.0.18 MySQL Community Server - GPL

  7. Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

  8. Oracle is a registered trademark of Oracle Corporation and/or its

  9. affiliates. Other names may be trademarks of their respective

  10. owners.

  11. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  12. mysql> select user,host from mysql.user order by user;

  13. +--------------------+-----------+

  14. | user | host |

  15. +--------------------+-----------+

  16. | cloneuser | % |

  17. | cloneuser | 127.0.0.1 |

  18. | cloneuser | localhost |

  19. | dbma | 127.0.0.1 |

  20. | innodbclusteradmin | % |

  21. | monitor | 127.0.0.1 |

  22. | mysql.infoschema | localhost |

  23. | mysql.session | localhost |

  24. | mysql.sys | localhost |

  25. | repluser | % |

  26. | root | 127.0.0.1 |

  27. | root | localhost |

  28. +--------------------+-----------+

  29. 12 rows in set (0.01 sec)


四、一行命令解决增加slave的问题

上一个例子中的单机是在 172.16.192.100 这台主机上的,如果想把 172.16.192.110 作为它的 slave ;手工做的话就要“备份”,“还原”,“建立主从关系”,dbm-agent 把这些逻辑都实现了,并且只要一行命令就能解决

1、 假设你已经在 172.16.192.110 主机上完成了 dbm-agent 的安装与初始化

  1. bash

  2. dbma-cli-build-slave --host=172.16.192.100 --port=3306 build-slave

  3. 2019-11-17 17:03:46,620 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave.remote_clone - bms - INFO - 1590 - execute checkings for install mysql

  4. 2019-11-17 17:03:46,654 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave.install - bms - INFO - 1115 - execute checkings for install mysql

  5. 2019-11-17 17:03:46,695 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave._create_mysql_user - bms - INFO - 864 - create user 'mysql3306' complete

  6. 2019-11-17 17:03:46,698 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave._create_data_dir - bms - INFO - 888 - create datadir '/database/mysql/data/3306' complete

  7. 2019-11-17 17:03:46,701 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave._create_binlog_dir - bms - INFO - 910 - create binary dir '/binlog/mysql/binlog/3306' complete

  8. 2019-11-17 17:03:46,704 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave._create_backup_dir - bms - INFO - 932 - create backup dir '/backup/mysql/backup/3306' complete

  9. 2019-11-17 17:03:46,706 - dbm-agent.dbma.mysqldeploy.MyCnfInitRender.render_template_file - bms - INFO - 518 - using template 'mysql-8.0-init-only.jinja'

  10. 2019-11-17 17:03:46,706 - dbm-agent.dbma.mysqldeploy.MyCnfInitRender.set_template - bms - INFO - 457 - using template file 'mysql-8.0-init-only.jinja'

  11. 2019-11-17 17:03:46,741 - dbm-agent.dbma.mysqldeploy.MyCnfInitRender.render - bms - INFO - 497 - render mysql config file /tmp/mysql-init.cnf

  12. 2019-11-17 17:03:46,741 - dbm-agent.dbma.mysqldeploy.MyCnfInitRender.render_template_file - bms - INFO - 524 - render template file complete

  13. 2019-11-17 17:03:46,742 - dbm-agent.dbma.mysqldeploy.MyCnfMSRender.render_template_file - bms - INFO - 548 - using template 'mysql-8.0.18.cnf.jinja'

  14. 2019-11-17 17:03:46,742 - dbm-agent.dbma.mysqldeploy.MyCnfMSRender.set_template - bms - INFO - 457 - using template file 'mysql-8.0.18.cnf.jinja'

  15. 2019-11-17 17:03:46,779 - dbm-agent.dbma.mysqldeploy.MyCnfMSRender.render - bms - INFO - 497 - render mysql config file /etc/my-3306.cnf

  16. 2019-11-17 17:03:46,779 - dbm-agent.dbma.mysqldeploy.MyCnfMSRender.render_template_file - bms - INFO - 554 - render template file complete

  17. 2019-11-17 17:03:46,779 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave._render_production_cnf - bms - INFO - 956 - render production cnf complete

  18. 2019-11-17 17:03:46,779 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave._init_database - bms - INFO - 1004 - ['/usr/local/mysql-8.0.18-linux-glibc2.12-x86_64/bin/mysqld', '--defaults-file=/tmp/mysql-init.cnf', '--initialize-insecure', '--user=mysql3306', '--init-file=/usr/local/dbm-agent/etc/init-users.sql']

  19. 2019-11-17 17:03:57,934 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave._init_database - bms - INFO - 1011 - init database complete

  20. 2019-11-17 17:03:57,938 - dbm-agent.dbma.mysqldeploy.MySQLSystemdRender.render - bms - INFO - 666 - render systemd config file complete

  21. 2019-11-17 17:03:57,938 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave._config_systemd - bms - INFO - 1027 - mysql systemd config complete

  22. 2019-11-17 17:03:58,110 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave._enable_mysql - bms - INFO - 1038 - config mysql auto start on boot complete

  23. 2019-11-17 17:04:00,144 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave._start_mysql - bms - INFO - 1068 - start mysql complete

  24. 2019-11-17 17:04:00,145 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave._export_path - bms - INFO - 1078 - export path complete

  25. 2019-11-17 17:04:00,147 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave._export_header_file - bms - INFO - 1106 - export header file complete

  26. 2019-11-17 17:04:00,148 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave._export_so - bms - INFO - 1093 - so file has been exported

  27. 2019-11-17 17:04:00,148 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave.install - bms - INFO - 1150 - install mysql single instance complete

  28. 2019-11-17 17:04:00,167 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave.remote_clone - bms - INFO - 1613 - prepare execute 'set @@global.clone_valid_donor_list='172.16.192.100:3306';'

  29. 2019-11-17 17:04:00,168 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave.remote_clone - bms - INFO - 1618 - prepare execute 'clone instance from cloneuser@'172.16.192.100':3306 identified by 'dbma@0352';'

  30. 2019-11-17 17:04:03,431 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave.remote_clone - bms - INFO - 1629 - remote clone complete (mysql will auto restart,please wait)

  31. 2019-11-17 17:04:03,432 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave.build_slave - bms - INFO - 1689 - wait mysql protocol avaiable

  32. 2019-11-17 17:04:14,454 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave.build_slave - bms - INFO - 1710 - prepare execute 'change master to master_host='172.16.192.100',master_port=3306,master_user='repluser',master_password='dbma@0352',master_ssl = 1,master_auto_position=1;'

  33. 2019-11-17 17:04:14,466 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave.build_slave - bms - INFO - 1716 - prepare execute 'start slave;'

  34. 2019-11-17 17:04:14,472 - dbm-agent.dbma.mysqldeploy.MySQLBuildSlave.build_slave - bms - INFO - 1728 - rebuild mysql slave complete

2、 检查主从关系是否正常

  1. sql

  2. mysql -uroot -pdbma@0352 -h127.0.0.1

  3. mysql: [Warning] Using a password on the command line interface can be insecure.

  4. Welcome to the MySQL monitor. Commands end with ; or \g.

  5. Your MySQL connection id is 12

  6. Server version: 8.0.18 MySQL Community Server - GPL

  7. Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

  8. Oracle is a registered trademark of Oracle Corporation and/or its

  9. affiliates. Other names may be trademarks of their respective

  10. owners.

  11. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  12. mysql> show slave status \G

  13. *************************** 1. row ***************************

  14. Slave_IO_State: Waiting for master to send event

  15. Master_Host: 172.16.192.100

  16. Master_User: repluser

  17. Master_Port: 3306

  18. Connect_Retry: 60

  19. Master_Log_File: mysql-bin.000002

  20. Read_Master_Log_Pos: 151

  21. Relay_Log_File: relay.000002

  22. Relay_Log_Pos: 357

  23. Relay_Master_Log_File: mysql-bin.000002

  24. Slave_IO_Running: Yes

  25. Slave_SQL_Running: Yes


五、****一行命令解决搭建MGR集群的问题

这里不再举例了可以直接到 github 上看 dbm-agent 的说明, mysql-group-replication,mysql-shell,innodb-cluster,mysql-router 个个都支持。


六、dbm-agent建设出来的实例质量如何

1、 一份完整、按需优化&渲染过后的配置文件

  1. ini

  2. #cat /etc/my-3306.cnf

  3. [mysqld]

  4. # basic

  5. user = mysql3306

  6. basedir = /usr/local/mysql-8.0.18-linux-glibc2.12-x86_64

  7. datadir = /database/mysql/data/3306

  8. server_id = 1388

  9. port = 3306

  10. bind_address = *

  11. admin_address = 127.0.0.1

  12. mysqlx_port = 33060

  13. admin_port = 33062

  14. socket = /tmp/mysql-3306.sock

  15. mysqlx_socket = /tmp/mysqlx-33060.sock

  16. pid_file = /tmp/mysql-3306.pid

  17. character_set_server = utf8mb4

  18. open_files_limit = 102000

  19. max_prepared_stmt_count = 1048576

  20. skip_name_resolve = 1

  21. super_read_only = OFF

  22. log_timestamps = system

  23. event_scheduler = OFF

  24. auto_generate_certs = ON

  25. activate_all_roles_on_login = ON

  26. end_markers_in_json = OFF

  27. tmpdir = /tmp/

  28. max_connections = 128

  29. autocommit = ON

  30. sort_buffer_size = 256K

  31. join_buffer_size = 256K

  32. eq_range_index_dive_limit = 200

  33. ## table

  34. big_tables = OFF

  35. sql_require_primary_key = OFF

  36. lower_case_table_names = 1

  37. auto_increment_increment = 1

  38. auto_increment_offset = 1

  39. table_open_cache = 4000

  40. table_definition_cache = 2000

  41. table_open_cache_instances = 32

  42. ## net

  43. max_allowed_packet = 1G

  44. connect_timeout = 10

  45. interactive_timeout = 28800

  46. net_read_timeout = 30

  47. net_retry_count = 10

  48. net_write_timeout = 60

  49. net_buffer_length = 32K

  50. ## logs

  51. log_output = FILE

  52. general_log = OFF

  53. general_log_file = general.log

  54. # error

  55. log_error = err.log

  56. log_statements_unsafe_for_binlog = ON

  57. # slow

  58. slow_query_log = ON

  59. slow_query_log_file = slow.log

  60. long_query_time = 2

  61. log_queries_not_using_indexes = OFF

  62. log_slow_admin_statements = OFF

  63. log_slow_slave_statements = OFF

  64. # binlog

  65. log_bin = /binlog/mysql/binlog/3306/mysql-bin

  66. binlog_checksum = none

  67. log_bin_trust_function_creators = ON

  68. binlog_direct_non_transactional_updates = OFF

  69. binlog_expire_logs_seconds = 604800

  70. binlog_error_action = ABORT_SERVER

  71. binlog_format = ROW

  72. max_binlog_stmt_cache_size = 1G

  73. max_binlog_cache_size = 1G

  74. max_binlog_size = 1G

  75. binlog_order_commits = ON

  76. binlog_row_image = FULL

  77. binlog_row_metadata = MINIMAL

  78. binlog_rows_query_log_events = ON

  79. binlog_stmt_cache_size = 32K

  80. log_slave_updates = ON

  81. binlog_transaction_dependency_history_size =25000

  82. binlog_transaction_dependency_tracking = WRITESET

  83. sync_binlog = 1

  84. binlog_cache_size = 96K

  85. binlog_group_commit_sync_delay = 0

  86. binlog_group_commit_sync_no_delay_count = 0

  87. ## replication

  88. rpl_semi_sync_master_enabled = 1

  89. rpl_semi_sync_slave_enabled = 1

  90. rpl_semi_sync_master_timeout = 1000

  91. rpl_semi_sync_master_wait_point = AFTER_SYNC

  92. rpl_semi_sync_master_wait_no_slave = ON

  93. rpl_semi_sync_master_wait_for_slave_count = 1

  94. master_info_repository = table

  95. sync_master_info = 10000

  96. skip_slave_start = OFF

  97. slave_load_tmpdir = /tmp/

  98. plugin_load_add = semisync_master.so

  99. plugin_load_add = semisync_slave.so

  100. relay_log = relay

  101. sync_relay_log = 10000

  102. sync_relay_log_info = 10000

  103. relay_log_info_repository = table

  104. slave_preserve_commit_order = ON

  105. slave_parallel_type = logical_clock

  106. slave_parallel_workers = 2

  107. slave_max_allowed_packet = 1G

  108. ## gtid

  109. gtid_mode = ON

  110. binlog_gtid_simple_recovery = ON

  111. enforce_gtid_consistency = ON

  112. gtid_executed_compression_period = 1000

  113. ## clone

  114. plugin-load-add = mysql_clone.so

  115. clone = FORCE_PLUS_PERMANEN

  116. # engines

  117. default_storage_engine = innodb

  118. default_tmp_storage_engine = innodb

  119. internal_tmp_mem_storage_engine = TempTable

  120. ## innodb

  121. innodb_data_home_dir = ./

  122. innodb_data_file_path = ibdata1:64M:autoextend

  123. innodb_page_size = 16K

  124. innodb_default_row_format = dynamic

  125. innodb_log_group_home_dir = ./

  126. innodb_redo_log_encrypt = OFF

  127. innodb_online_alter_log_max_size = 256M

  128. innodb_undo_directory = ./

  129. innodb_undo_log_encrypt = OFF

  130. innodb_undo_log_truncate = ON

  131. innodb_max_undo_log_size = 1G

  132. innodb_rollback_on_timeout = OFF

  133. innodb_rollback_segments = 128

  134. innodb_log_checksums = ON

  135. innodb_checksum_algorithm = crc32

  136. innodb_log_compressed_pages = ON

  137. innodb_doublewrite = ON

  138. innodb_commit_concurrency = 0

  139. innodb_read_only = OFF

  140. innodb_dedicated_server = OFF

  141. innodb_old_blocks_pct = 37

  142. innodb_old_blocks_time = 1000

  143. innodb_random_read_ahead = OFF

  144. innodb_read_ahead_threshold = 56

  145. innodb_max_dirty_pages_pct_lwm = 20

  146. innodb_max_dirty_pages_pct = 90

  147. innodb_lru_scan_depth = 1024

  148. innodb_adaptive_flushing = ON

  149. innodb_adaptive_flushing_lwm = 10

  150. innodb_flushing_avg_loops = 30

  151. innodb_buffer_pool_dump_pct = 50

  152. innodb_buffer_pool_dump_at_shutdown = ON

  153. innodb_buffer_pool_load_at_startup = ON

  154. innodb_buffer_pool_filename = ib_buffer_pool

  155. innodb_stats_persistent = ON

  156. innodb_stats_on_metadata = ON

  157. innodb_stats_method = nulls_equal

  158. innodb_stats_auto_recalc = ON

  159. innodb_stats_include_delete_marked = ON

  160. innodb_stats_persistent_sample_pages = 20

  161. innodb_stats_transient_sample_pages = 8

  162. innodb_status_output = OFF

  163. innodb_status_output_locks = OFF

  164. innodb_buffer_pool_dump_now = OFF

  165. innodb_buffer_pool_load_abort = OFF

  166. innodb_buffer_pool_load_now = OFF

  167. innodb_thread_concurrency = 0

  168. innodb_concurrency_tickets = 5000

  169. innodb_thread_sleep_delay = 15000

  170. innodb_adaptive_max_sleep_delay = 150000

  171. innodb_read_io_threads = 4

  172. innodb_write_io_threads = 4

  173. innodb_use_native_aio = ON

  174. innodb_flush_sync = OFF

  175. innodb_spin_wait_delay = 6

  176. innodb_purge_threads = 4

  177. innodb_purge_batch_size = 300

  178. innodb_purge_rseg_truncate_frequency = 128

  179. innodb_deadlock_detect = ON

  180. innodb_print_all_deadlocks = ON

  181. innodb_lock_wait_timeout = 50

  182. innodb_table_locks = ON

  183. innodb_sync_array_size = 1

  184. innodb_sync_spin_loops = 30

  185. innodb_print_ddl_logs = OFF

  186. innodb_replication_delay = 0

  187. innodb_cmp_per_index_enabled = OFF

  188. innodb_disable_sort_file_cache = OFF

  189. innodb_numa_interleave = OFF

  190. innodb_strict_mode = ON

  191. innodb_sort_buffer_size = 1M

  192. innodb_fast_shutdown = 1

  193. innodb_force_load_corrupted = OFF

  194. innodb_force_recovery = 0

  195. innodb_temp_tablespaces_dir = ./#innodb_temp/

  196. innodb_tmpdir = ./

  197. innodb_temp_data_file_path = ibtmp1:64M:autoextend

  198. innodb_page_cleaners = 4

  199. innodb_adaptive_hash_index = ON

  200. innodb_adaptive_hash_index_parts = 8

  201. innodb_flush_log_at_timeout = 1

  202. innodb_fsync_threshold = 0

  203. innodb_fill_factor = 90

  204. innodb_file_per_table = ON

  205. innodb_autoextend_increment = 64

  206. innodb_open_files = 100000

  207. innodb_buffer_pool_chunk_size = 128M

  208. innodb_buffer_pool_instances = 1

  209. innodb_log_files_in_group = 8

  210. innodb_log_file_size = 64M

  211. innodb_flush_neighbors = 0

  212. innodb_io_capacity = 4000

  213. innodb_io_capacity_max = 20000

  214. innodb_autoinc_lock_mode = 2

  215. innodb_change_buffer_max_size = 25

  216. innodb_flush_method = O_DIRECT

  217. innodb_log_buffer_size = 64M

  218. innodb_flush_log_at_trx_commit = 1

  219. innodb_buffer_pool_size = 256M

  220. #### for performance_schema

  221. performance_schema =OFF

  222. performance_schema_consumer_global_instrumentation =ON

  223. performance_schema_consumer_thread_instrumentation =ON

  224. performance_schema_consumer_events_stages_current =ON

  225. performance_schema_consumer_events_stages_history =ON

  226. performance_schema_consumer_events_stages_history_long =OFF

  227. performance_schema_consumer_statements_digest =ON

  228. performance_schema_consumer_events_statements_current =ON

  229. performance_schema_consumer_events_statements_history =ON

  230. performance_schema_consumer_events_statements_history_long =OFF

  231. performance_schema_consumer_events_waits_current =ON

  232. performance_schema_consumer_events_waits_history =ON

  233. performance_schema_consumer_events_waits_history_long =OFF

  234. performance-schema-instrument ='memory/%=COUNTED'

  235. # -- ~ _ ~ ~ _ ~ ~ _ ~ --

  236. # base on mysql-8.0.18

  237. # generated by https://www.sqlpy.com 2019年10月14日 21时47分11秒

  238. # wechat: jianglegege

  239. # email: 1721900707@qq.com

  240. # -- ~ _ ~ --

2、 把规范和流程物化到 dbm-agent 的每一个环节,而不是口头上或文档上;更加详细的内容可以参考 github dbm-agent

MySQL DBA好帮手

MySQL DBA好帮手

MySQL DBA好帮手

扫码加入MySQL技术Q群

(群号:****650149401)

MySQL DBA好帮手

点“在看”给我一朵小黄花MySQL DBA好帮手

MySQL DBA好帮手

本文分享自微信公众号 - 老叶茶馆(iMySQL_WX)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
4个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Stella981 Stella981
3年前
Python3:sqlalchemy对mysql数据库操作,非sql语句
Python3:sqlalchemy对mysql数据库操作,非sql语句python3authorlizmdatetime2018020110:00:00coding:utf8'''
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
为什么mysql不推荐使用雪花ID作为主键
作者:毛辰飞背景在mysql中设计表的时候,mysql官方推荐不要使用uuid或者不连续不重复的雪花id(long形且唯一),而是推荐连续自增的主键id,官方的推荐是auto_increment,那么为什么不建议采用uuid,使用uuid究
Python进阶者 Python进阶者
10个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这