=Start=
缘由:
这是在GitHub上看到的一个MySQL配置文件模板,觉得不错,在此记录一下,方便以后在有需要的时候进行参考(因为MySQL的参数优化是个很复杂的东西,对于不同的网站,及其在线量、访问量、帖子数量、网络情况,以及机器硬件配置都有关系,优化不可能一次性完成,需要不断的观察以及调试,才有可能得到最佳效果)。
如果觉得这个配置文件太复杂了,也可以考虑按需使用安装时自带的一些配置文件:
/usr/share/mysql/my-large.cnf /usr/share/mysql/my-huge.cnf /usr/share/mysql/my-innodb-heavy-4G.cnf /usr/share/mysql/my-medium.cnf /usr/share/mysql/my-small.cnf
正文:
# author: [email protected] # This configration file opts for MySQL 5.6 and 5.7. # assume: 32 CPU core / 256G Memory / SSD storage with 20000 IOPS in 16K page size [mysql] prompt = [\\u@\\h][\\d]>\\_ [mysqld] # basic settings # user = mysql sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER" autocommit = 1 character_set_server=utf8mb4 transaction_isolation = READ-COMMITTED explicit_defaults_for_timestamp = 1 max_allowed_packet = 16777216 event_scheduler = 1 # connection # interactive_timeout = 1800 wait_timeout = 1800 lock_wait_timeout = 1800 skip_name_resolve = 1 max_connections = 512 max_connect_errors = 1000000 # session memory setting # read_buffer_size = 16777216 read_rnd_buffer_size = 33554432 sort_buffer_size = 33554432 tmp_table_size = 67108864 join_buffer_size = 134217728 # log settings # log_error = error.log slow_query_log = 1 slow_query_log_file = slow.log log_queries_not_using_indexes = 1 log_slow_admin_statements = 1 log_slow_slave_statements = 1 log_throttle_queries_not_using_indexes = 10 expire_logs_days = 90 long_query_time = 2 min_examined_row_limit = 100 binlog-rows-query-log-events = 1 log-bin-trust-function-creators = 1 expire-logs-days = 90 log-slave-updates = 1 # innodb settings # innodb_page_size = 16384 innodb_buffer_pool_size = 160G innodb_buffer_pool_instances = 16 innodb_buffer_pool_load_at_startup = 1 innodb_buffer_pool_dump_at_shutdown = 1 innodb_lru_scan_depth = 4096 innodb_lock_wait_timeout = 5 innodb_io_capacity = 10000 innodb_io_capacity_max = 20000 innodb_flush_method = O_DIRECT innodb_file_format = Barracuda innodb_file_format_max = Barracuda innodb_undo_logs = 128 innodb_undo_tablespaces = 3 innodb_flush_neighbors = 0 innodb_log_file_size = 17179869184 innodb_log_files_in_group = 2 innodb_log_buffer_size = 16777216 innodb_purge_threads = 4 innodb_large_prefix = 1 innodb_thread_concurrency = 64 innodb_print_all_deadlocks = 1 innodb_strict_mode = 1 innodb_sort_buffer_size = 67108864 innodb_write_io_threads = 16 innodb_read_io_threads = 16 innodb_file_per_table = 1 innodb_stats_persistent_sample_pages = 64 innodb_autoinc_lock_mode = 2 # replication setting # master_info_repository = TABLE relay_log_info_repository = TABLE sync_binlog = 1 gtid_mode = on enforce_gtid_consistency = 1 log_slave_updates binlog_format = ROW binlog_rows_query_log_events = 1 relay_log = relay.log relay_log_recovery = 1 binlog_gtid_simple_recovery = 1 slave_skip_errors = ddl_exist_errors slave-rows-search-algorithms = 'INDEX_SCAN,HASH_SCAN' # semi sync replication settings # plugin_load = "validate_password.so;rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so" rpl_semi_sync_master_enabled = 1 rpl_semi_sync_master_timeout = 3000 rpl_semi_sync_slave_enabled = 1 # password plugin # validate_password_policy=STRONG validate-password=FORCE_PLUS_PERMANENT [mysqld-5.7] # new innodb setting # loose_innodb_numa_interleave=1 innodb_buffer_pool_dump_pct = 40 innodb_page_cleaners = 16 innodb_undo_log_truncate = 1 innodb_max_undo_log_size = 2G innodb_purge_rseg_truncate_frequency = 128 # new replication setting # slave-parallel-type = LOGICAL_CLOCK slave-parallel-workers = 16 slave_preserve_commit_order=1 slave_transaction_retries=128 # other change setting # binlog_gtid_simple_recovery=1 log_timestamps=system show_compatibility_56=on
参考链接:
- https://github.com/jdaaaaaavid/mysql_best_configuration/blob/master/my.cnf
- mysql用于分配内存的参数
- MySQL配置文件my.cnf中文详解附mysql性能优化方法分享
- MySQL配置文件my.cnf参数优化和中文详解
- Mysql my.cnf配置
- Mysql 配置文件详解
=END=
《 “常用的MySQL配置文件模板” 》 有 4 条评论
在MySQL配置文件my.cnf中配置prompt(需重启生效):
`
[mysql]
prompt = [\u@\h:\p][\d]>\_
`
显示效果:
`
[[email protected]:3307] [bash]> status;
`
http://www.thegeekstuff.com/2010/02/mysql_ps1-6-examples-to-make-your-mysql-prompt-like-angelina-jolie/
http://blog.csdn.net/dba_waterbin/article/details/8779502
http://dev.mysql.com/doc/refman/5.7/en/mysql-commands.html
一张思维导图学会如何构建高性能MySQL系统!
https://mp.weixin.qq.com/s/OBIOAjHo5k8ioNz-F2LoQA
一张思维导图纵观MySQL数据安全体系!
https://mp.weixin.qq.com/s?__biz=MzI4NTA1MDEwNg==&mid=2650762063&idx=1&sn=af712351dee10bbef6c2ebd649bba312
http://pan.baidu.com/s/1dFpI4t7
关于MySQL慢日志,你想知道的都在这
https://mp.weixin.qq.com/s/Ifbq0Dk13SO3WVghqWVUbA
https://flyerboy.github.io/2016/12/23/mysql_slow/
`
1、什么是慢日志?
2、什么情况下产生慢日志?
3、慢日志相关参数
4、慢日志输出内容
5、慢日志分析工具
6、慢日志的清理与备份
`
58到家MySQL军规升级版
https://mp.weixin.qq.com/s/YfCORbcCX1hymXBCrZbAZg
`
一、基础规范
二、命名规范
三、表设计规范
四、列设计规范
五、索引规范
六、SQL规范
`