设为首页 收藏本站
查看: 824|回复: 0

[经验分享] MySQL5.7配置参数

[复制链接]

尚未签到

发表于 2018-10-11 09:31:12 | 显示全部楼层 |阅读模式
  MySQL5.7的参数调整配置,参考例子,某些具体参数的设置还需要根据实际来调整。
  [client]
  port                            = 3306
  socket                          = /tmp/mysql3306.sock
  default_character_set           = utf8mb4
  [mysqld]
  lower_case_table_names  = 1
  port                            = 3306
  basedir                         = /usr/local/mysql
  datadir                         = /home/mysql3306/mysql3306
  socket                          = /tmp/mysq3306.sock
  pid_file                        = /home/mysql3306/mysql5711.pid
  tmpdir                          = /tmp/
  slave_load_tmpdir               = /tmp/
  # *** dns resolve *** #
  skip_name_resolve               = 1
  external_locking
  explicit_defaults_for_timestamp= true
  character_set_client_handshake = FALSE
  character_set_server            = utf8mb4
  collation_server                = utf8mb4_unicode_ci
  init_connect                    = 'SET NAMES utf8m2b4'
  # *** connection *** #
  max_connections                 = 512
  max_connect_errors              = 100000
  back_log                        = 102
  interactive_timeout             = 600
  wait_timeout                    = 600
  table_definition_cache          = 5000
  table_open_cache                = 2048
  #query_cache_size                = 64M
  #query_cache_limit               = 2M
  thread_cache_size               = 51
  ft_min_word_len                = 4
  #performance_schema              = OFF
  ##If large data transfer problems,enlarge max_allowed_packet
  thread_stack = 192K
  # *** global memory parameter *** #
  max_allowed_packet              = 16M
  tmp_table_size                  = 256M
  max_tmp_tables                  = 128
  max_heap_table_size             = 96M
  #close query cache
  #query_cache_type                = 0
  # *** session memory parameter *** #
  sort_buffer_size                = 4M
  read_buffer_size                = 4M
  join_buffer_size                = 4M
  read_rnd_buffer_size            = 8M
  bulk_insert_buffer_size         = 64M
  # *** engine *** #
  default_storage_engine          = InnoDB
  #ignore_builtin_innodb
  #plugin_load=innodb=ha_innodb_plugin.so;innodb_trx=ha_innodb_plugin.so;innodb_locks=ha_innodb_plugin.so;innodb_lock_waits=ha_innodb_plugin.so;innodb_cmp=ha_innodb_plugin.so;innodb_cmp_reset=ha_innodb_plugin.so;innodb_cmpmem=ha_innodb_plugin.so;innodb_cmpmem_reset=ha_innodb_plugin.so
  # *** log *** #
  log_timestamps                  = system
  log_bin                         = /home/mysql3306/logs/mysql-bin
  expire_logs_days                = 10
  binlog_format                   = mixed
  #binlog_gtid_simple_recovery     = 1
  #binlog_do_db
  #binlog_ignore_db
  log_slave_updates=1
  relay_log                       = /home/mysql3306/logs/mysql5711_relay_bin
  relay_log_index                = /home/mysql3306/logs/mysql5711_relay_bin.index
  relay_log_info_file             = /home/mysql3306/logs/mysql5711_relay_bin.info
  relay_log_recovery              = 0
  log_error                       = /home/mysql3306/logs/mysql5711.err
  slow_query_log                  = 1
  slow_query_log_file             = /home/mysql3306/logs/mysql5711_slow.log
  long_query_time                 = 1
  log_output                      = FILE
  log_queries_not_using_indexes   = 1
  log_slow_admin_statements       = 1
  log_slow_slave_statements       = 1
  log_throttle_queries_not_using_indexes = 10
  min_examined_row_limit          = 100
  #general_log                     = off
  general_log_file                = /home/mysql3306/logs/mysql5711_general.log
  #log_queries_not_using_indexes  = /mysqllog/mysql5711/mysql5711_not_useing_index.log
  max_binlog_cache_size           = 8M
  max_binlog_size                 = 1024M
  binlog_cache_size               = 4M
  sync_binlog                     = 1
  server_id                       = 28703306
  #read_only                       = 0
  #slave_skip_errors               = all
  # *** MyISAM Specific options *** #
  #key_buffer_size                 = 128M
  #bulk_insert_buffer_size         = 64M
  #myisam_sort_buffer_size         = 128M
  #myisam_max_sort_file_size       = 10G
  #myisam_repair_threads           = 1
  #myisam_recover_options          = BACKUP,FORCE
  # *** INNODB Specific options *** #
  innodb_data_home_dir            = /home/mysql3306/mysql3306/
  innodb_data_file_path           = ibdata1:1024M:autoextend
  innodb_log_group_home_dir       = /home/mysql3306/mysql3306/
  innodb_buffer_pool_instances    = 1
  innodb_buffer_pool_size         = 1024MB
  innodb_buffer_pool_dump_pct     = 40
  innodb_page_cleaners            = 4
  innodb_log_file_size            = 256M
  innodb_log_files_in_group       = 2
  innodb_log_buffer_size          = 32M  #default 16M
  innodb_flush_log_at_trx_commit  = 1
  innodb_lock_wait_timeout        = 30
  innodb_undo_directory           = /home/mysql3306/mysql3306/
  innodb_undo_logs                = 128  #must >=35.default 128
  innodb_undo_tablespaces         = 3    #must >=2
  innodb_undo_log_truncate        = 1
  innodb_max_undo_log_size        = 256M
  innodb_purge_rseg_truncate_frequency = 128
  innodb_print_all_deadlocks      = 1
  innodb_sort_buffer_size         = 64M
  disabled_storage_engines=MyISAM
  innodb_buffer_pool_load_at_startup = 1
  innodb_buffer_pool_dump_at_shutdown = 1
  innodb_file_format_max=Antelope
  innodb_file_format=Antelope
  sql_mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"
  innodb_open_files               = 4000
  innodb_file_per_table           = 1
  innodb_status_file              = 1
  innodb_lock_wait_timeout        = 30
  innodb_read_io_threads          = 8
  innodb_write_io_threads         = 8
  innodb_io_capacity              = 200
  innodb_thread_concurrency       = 32
  innodb_commit_concurrency       = 0
  #innodb_flush_neighbors          = 0  #for ssd
  #innodb_flush_neighbors          = 1  #for other
  innodb_purge_batch_size         = 1000
  innodb_flush_log_at_trx_commit  = 0
  innodb_flush_method             = O_DIRECT
  innodb_purge_threads            = 4
  #innodb_file_format              = barracuda
  innodb_strict_mode              = 1
  innodb_support_xa               = 1
  skip_innodb_adaptive_hash_index
  innodb_force_recovery           =0
  #innodb_fast_shutdown
  innodb_change_buffering        = all
  #innodb_use_native_aio          = 1
  innodb_max_dirty_pages_pct      =50
  ##replication
  #replicate_do_db
  #replicate_ignore_db             = mysql
  #replicate_ignore_db             = test
  #replicate_do_table
  #replicate_ignore_table
  #replicate_wild_do_table
  #replicate_wild_ignore_table
  #gtid_mode                       = on
  #enforce_gtid_consistency        = true
  #open mts
  master_info_repository          = TABLE
  relay_log_info_repository       = TABLE
  sync_master_info                = 1
  slave-parallel-type=LOGICAL_CLOCK #default databases,group rep
  slave_parallel_workers          = 16
  relay_log_recovery=ON
  binlog_checksum                 = CRC32 #default crc32
  master_verify_checksum          = 1     #default off
  slave_sql_verify_checksum       = 1
  #binlog_rows_query_log_events    = 1    #
  ##semi sync replication settings
  #plugin_dir=/usr/local/mysql57/lib/plugin
  #plugin_load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so"
  #loose_rpl_semi_sync_master_enabled = 1
  #loose_rpl_semi_sync_slave_enabled  = 1
  #loose_rpl_semi_sync_master_timeout = 10000 # 10 second
  ##transaction
  transaction_isolation          = REPEATABLE-READ
  #transaction_write_set_extraction= MURMUR32 #open --single-tra no use
  [mysqldump]
  quick
  max_allowed_packet              = 16M
  [mysql]
  no_auto_rehash
  default_character_set           = utf8mb4
  [myisamchk]
  #key_buffer_size                 = 20M
  #sort_buffer_size                = 4M
  #read_buffer                     = 4M
  #write_buffer                    = 2M
  [mysqlhotcopy]
  interactive_timeout
  [mysqld_safe]
  open_files_limit                = 8192
  总结:参数的调整,能对RW的性能有帮助,调整不好也是个坑......http://blog.51cto.com/e/u261/themes/default/images/spacer.gif


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-620221-1-1.html 上篇帖子: mysql mysql_upgrade主从升级造成的1580错误 下篇帖子: (转)MySQL Group Replication介绍
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表