mysql5.7参数文件

[mysql]
auto-rehash

[mysqld]
####: for global
user                                ={{ mysql_user }}                          #    mysql
basedir                             ={{ mysql_base_dir }}              #    /usr/local/mysql/
datadir                             ={{ mysql_data_dir_base }}/data/{{mysql_port}}      #   /usr/local/mysql/data
tmpdir                  ={{ mysql_data_dir_base }}/tmp/{{mysql_port}}  # /tmp
server_id                           ={{ mysql_server_id }}                            # 0
port                                ={{ mysql_port }}                           #   3306
character_set_server                ={{ mysql_character_set_server }}                           #   latin1
log_bin_trust_function_creators     =on                             #   0
max_prepared_stmt_count             =1048576
log_timestamps                      =system                         #   utc
read_only                           =0                              #   off
skip_name_resolve                   =1                              #   0
auto_increment_increment            =1                              #   1
auto_increment_offset               =1                              #   1
lower_case_table_names              =1                              #   0
secure_file_priv                    =                               #   null
open_files_limit                    =65536                          #   1024
max_connections                     ={{mysql_max_connections | default(1000)}}
thread_cache_size                   ={{ [(server_specs_processor_count|int) * 8,256] | max}}                              #   9
table_open_cache                    =4096                           #   2000
table_definition_cache              =2000                           #   1400
table_open_cache_instances          =32                             #   16
local_infile                        =off                            #   on
disabled_storage_engines=archive,blackhole,example,federated,memory,merge,ndb
plugin_load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so;validate_password=validate_password.so"
pid_file=mysqld.pid
transaction_isolation           ={{ mysql_transaction_isolation }} #RR
{% if sock_type == 1 %}
socket                                  = mysql.sock                 #    /tmp/mysql.sock          
{% elif sock_type == 2 %}
socket                                  = /tmp/mysql{{ mysql_port }}.sock
{% elif sock_type == 3 %}
socket                                  = {{ mysql_data_dir_base }}/run/mysql{{ mysql_port }}.sock
{% endif %}

####: for binlog
binlog_format                       ={{mysql_binlog_format}}                          # row
binlog_error_action                 =abort_server          # abort_server
log_bin                             ={{ mysql_data_dir_base }}/log/binlog/{{mysql_port}}/mysql-bin                      #   off
binlog_rows_query_log_events        =on                             #   off
log_slave_updates                   =on                             #   off
expire_logs_days                    =8                              #   0
{# set binlog cache size #}
{% if mysql_binlog_format == 'mixed' %}
binlog_cache_size                   =32768                          #   32768(32k)
{% else %}
binlog_cache_size                   =65536                          #   65536(64k)
{% endif %}
{# set binlog cache size #}
binlog_checksum                     =CRC32                           #  CRC32
sync_binlog                         =1                              #   1
slave_preserve_commit_order         =ON                             #  OFF 

####: for error-log
log_error                           =err.log                        #   /usr/local/mysql/data/localhost.localdomain.err

{# set general log #}
general_log                         =off                            #   off
general_log_file                    =general.log                    #   hostname.log
{# set general log #}

####: for slow query log
slow_query_log                      =on                             #    off
slow_query_log_file                 =slow.log                       #    hostname-slow.log
log_queries_not_using_indexes       =off                             #    off
long_query_time                     =2.000000                       #    10.000000

####: for gtid
gtid_executed_compression_period    =1000                          #    1000
gtid_mode                           =on                            #    off
enforce_gtid_consistency            =on                            #    off


####: for replication
skip_slave_start                    =0                              #   
relay_log                           ={{ mysql_data_dir_base }}/log/relaylog/{{mysql_port}}/relay-bin
relay_log_recovery=1
master_info_repository              =table                         #    file
relay_log_info_repository           =table                         #    file
slave_parallel_type                 =logical_clock                 #    database | LOGICAL_CLOCK
slave_parallel_workers              ={{[(server_specs_processor_count |int) * 4 ,32] | min}}                             #    0
rpl_semi_sync_master_enabled        =1                             #    0
rpl_semi_sync_slave_enabled         =1                             #    0
rpl_semi_sync_master_timeout        =1000                          #    1000(1 second)
binlog_group_commit_sync_delay      =500                           #    0      500(0.05% seconde) 
binlog_group_commit_sync_no_delay_count = 13                       #    0
{% if use_write_set == 1 %}
binlog_transaction_dependency_tracking  = WRITESET                 #    COMMIT_ORDER          
transaction_write_set_extraction        = XXHASH64
{% endif %}


####: for innodb
default_storage_engine                          =innodb                     #   innodb
default_tmp_storage_engine                      =innodb                     #   innodb
innodb_data_file_path                           =ibdata1:64M:autoextend     #   ibdata1:12M:autoextend
innodb_temp_data_file_path                      =ibtmp1:12M:autoextend      #   ibtmp1:12M:autoextend
innodb_buffer_pool_filename                     =ib_buffer_pool             #   ib_buffer_pool
innodb_log_group_home_dir                       ={{ mysql_data_dir_base }}/log/redolog/{{mysql_port}}                         # ./
innodb_log_files_in_group                       ={{ mysql57_innodb_log_files_in_group }}                          # 2
innodb_log_file_size                            ={{ mysql57_innodb_log_file_size }}                        #    50331648(48M)
innodb_file_per_table                           =on                         #   on
innodb_online_alter_log_max_size                =128M                  #   134217728(128M)
innodb_open_files                               ={{mysql_innodb_open_files}}                       #   2000
innodb_page_size                                =16k                        #   16384(16k)
innodb_thread_concurrency                       =0                          #   0
innodb_read_io_threads                          =4                          #   4
innodb_write_io_threads                         =4                          #   4
innodb_purge_threads                            =4                          #   4(garbage collection)
innodb_page_cleaners                            =4                          #   4(flush lru list)
innodb_print_all_deadlocks                      =on                         #   off
innodb_deadlock_detect                          =on                         #   on
innodb_lock_wait_timeout                        =50                         #   50
innodb_spin_wait_delay                          =6                          #   6
innodb_autoinc_lock_mode                        =2                          #   1
innodb_io_capacity                              =200                        #   200
innodb_io_capacity_max                          =2000                       #   2000
#--------Persistent Optimizer Statistics
innodb_stats_auto_recalc                        =on                         #   on
innodb_stats_persistent                         =on                         #   on
innodb_stats_persistent_sample_pages            =20                         #   20
{# --                 set innodb_buffer_pool_instances                                 -- #}
{% if ((server_specs_memtotal_gb | int ) * 0.6 ) < 64  %}
innodb_buffer_pool_instances                    ={{ [ (((server_specs_memtotal_gb | int ) * 0.6) | round(0, 'ceil') | int ) , 1 ] | max }}
{% else %}
innodb_buffer_pool_instances                    =64
{% endif %}
{# --                 set innodb_buffer_pool_instances                                 -- #}
innodb_adaptive_hash_index                      =on                         #   on
innodb_change_buffering                         =all                        #   all
innodb_change_buffer_max_size                   =25                         #   25
innodb_flush_neighbors                          =1                          #   1
#innodb_flush_method                             =                           #  
innodb_doublewrite                              =on                         #   on
innodb_log_buffer_size                          ={{mysql_innodb_log_buffer_size}}                        #  16777216(16M)
innodb_flush_log_at_timeout                     =1                          #   1
innodb_flush_log_at_trx_commit                  =1                          #   1
innodb_buffer_pool_size                         ={{ ((server_specs_memtotal_gb | int ) * 1024 * 0.6 // 128 * 128 ) | round(0, 'ceil') | int }}M  # 134217728(128M)
autocommit                                      =1                          #   1
#--------innodb scan resistant
innodb_old_blocks_pct                           =37                         #    37
innodb_old_blocks_time                          =1000                       #    1000
#--------innodb read ahead
innodb_read_ahead_threshold                     =56                         #    56 (0..64)
innodb_random_read_ahead                        =OFF                        #    OFF
#--------innodb buffer pool state
innodb_buffer_pool_dump_pct                     =25                         #    25 
innodb_buffer_pool_dump_at_shutdown             =ON                         #    ON
innodb_buffer_pool_load_at_startup              =ON                         #    ON

#--------undo log
innodb_undo_log_truncate                        = 1                         #    0
innodb_max_undo_log_size                        = 2G                        #    1G
#innodb_undo_logs                                = 128                       #    128   
innodb_undo_tablespaces                         = 2                         #    0

#--------disable QC
query_cache_size = 0
query_cache_type = 0

#--------
slave_rows_search_algorithms = 'INDEX_SCAN,HASH_SCAN'
report_host = {{ ansible_default_ipv4.address }}
default_time_zone = {{ mysql_default_time_zone }}

{% if mtls_with_mysql_group_replication == 1 %}
####: for mysql group replication 
loose-group_replication_recovery_retry_count          =10                                         #   10
loose-group_replication_recovery_reconnect_interval   =60                                         #   60
loose-group_replication_allow_local_disjoint_gtids_join=off                                       #   off
loose-group_replication_allow_local_lower_version_join=off                                        #   off
loose-group_replication_ip_whitelist                  =AUTOMATIC                                  #   AUTOMATIC
loose-transaction_write_set_extraction                =XXHASH64                                   # off
loose-group_replication_group_name                    ="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"     # 
loose-group_replication_start_on_boot                 =off                                        # off
loose-group_replication_bootstrap_group               =off                                        # off
loose-group_replication_single_primary_mode           =on                                         #   on
loose-group_replication_enforce_update_everywhere_checks=off
loose-group_replication_gtid_assignment_block_size    =1000000                                    #   1000000
loose-group_replication_poll_spin_loops               =0                                          #   0
loose-group_replication_compression_threshold         =1024                                       #   1000000
loose-group_replication_flow_control_mode             =QUOTA                                      #   QUOTA
{% for ip in ansible_all_ipv4_addresses %}
    {%- for host_ip in mysql_mgr_hosts %}
        {%- if ip == host_ip %}
loose-group_replication_local_address                 ="{{ip}}:{{mysql_mgr_port}}"
        {%- endif %}
    {%- endfor %}
{% endfor %}

{% set gs = ':' + (mysql_mgr_port | string)+',' %}
loose-group_replication_group_seeds                   ="{{ mysql_mgr_hosts | join(gs) + ':' + (mysql_mgr_port | string)  }}"
{% endif %}


####  for performance_schema
performance_schema                                                      =on    #    on
performance_schema_consumer_global_instrumentation                      =on    #    on
performance_schema_consumer_thread_instrumentation                      =on    #    on
performance_schema_consumer_events_stages_current                       =on    #    off
performance_schema_consumer_events_stages_history                       =on    #    off
performance_schema_consumer_events_stages_history_long                  =off   #    off
performance_schema_consumer_statements_digest                           =on    #    on
performance_schema_consumer_events_statements_current                   =on    #    on
performance_schema_consumer_events_statements_history                   =on    #    on
performance_schema_consumer_events_statements_history_long              =off   #    off
performance_schema_consumer_events_waits_current                        =on    #    off
performance_schema_consumer_events_waits_history                        =on    #    off
performance_schema_consumer_events_waits_history_long                   =off   #    off
performance-schema-instrument                                           ='memory/%=COUNTED'


[dbops: dbops 专注于解决开源数据库各种部署问题,第一期只支持 MySQL,第二期会支持 openGauss (gitee.com)](https://gitee.com/fanderchan/dbops)

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 199,393评论 5 467
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 83,790评论 2 376
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 146,391评论 0 330
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,703评论 1 270
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,613评论 5 359
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,003评论 1 275
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,507评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,158评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,300评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,256评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,274评论 1 328
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,984评论 3 316
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,569评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,662评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,899评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,268评论 2 345
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 41,840评论 2 339

推荐阅读更多精彩内容