转mysql8 my.cnf文件

# Example MySQL config file for very large systems.

#

# This is for a large system with memory of 1G-2G where the system runs mainly

# MySQL.

#

# MySQL programs look for option files in a set of

# locations which depend on the deployment platform.

# You can copy this option file to one of those

# locations. For information about these locations, see:

# http://dev.mysql.com/doc/mysql/en/option-files.html

#

# In this file, you can use all long options that a program supports.

# If you want to know which options a program supports, run the program

# with the "--help" option.

# The following options will be passed to all MySQL clients

[client]

#password=your_password

port = 3306

socket = /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server

[mysqld]

# required unique id between 1 and 2^32 - 1

# defaults to 1 if master-host is not set

# but will not function as a master if omitted

server-id = 11

################################ 指定数据库使用user ##############################

user = mysql

################################ 创建function+view ##############################

log_bin_trust_function_creators=1

################################ performance_schema ##############################

performance_schema = 1

################################ innodb_stats_on_metadata ##############################

innodb_stats_on_metadata=0

################################ default_authentication_plugin ##############################

default_authentication_plugin=mysql_native_password

################################ common parameter ################################

# 默认innodb存储引擎, 默认utf8字符集,默认不忽略大小写

default-storage-engine = INNODB

#character_set_server=utf8mb4

#collation_server = utf8mb4_unicode_ci

character_set_server=utf8

collation_server = utf8_general_ci

#sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"

# 文件系统中小写表名,避免兼容性问题

lower_case_table_names=1

# 不解析dns,忽略外部锁

#skip_name_resolve = 1

skip-name-resolve

skip-external-locking

# 数据目录

datadir = /data/mysqldata/3306/data/

# 取消query_cache

#query_cache_type = 0

#query_cache_size = 0

# Try number of CPU's*2 for thread_concurrency , only for solaris

#thread_concurrency = 8

# table and thread cache

#table_open_cache = 2000

#table_definition_cache = 512

#thread_cache_size = 100

#事务隔离级别

transaction_isolation = READ-COMMITTED

max_heap_table_size = 32M

# max_length_for_sort_data 避免再次回表获得数据,使用优化过的排序算法

max_length_for_sort_data = 16k

# 是否只读

read_only=0

#关闭TIMESTAMP警告

explicit_defaults_for_timestamp = 1

#数据库或表不可以存储在my.cnf中指定datadir之外的分区或目录,需支持符号链接

#skip-symbolic-links

log_timestamps=system

#transaction_write_set_extraction=MURMUR32

#transaction_write_set_extraction=XXHASH64

transaction_write_set_extraction=OFF

#show_compatibility_56=on

################################ connection parameter ################################

#bind_address = 0.0.0.0

back_log = 100

port = 3306

socket = /tmp/mysql.sock

tmpdir = /tmp

#最大连接数

max_connections=5000

# 加大该次数,以免is blocked的报错

max_connect_errors = 1844674407370954751

max_allowed_packet = 512M

# 报表计算的程序是一天算一次,所以需要增大该时间以免被MySQL服务器kill会话

wait_timeout = 7200

interactive_timeout = 2880000

################################ per thread memory ################################

thread_stack = 512k

net_buffer_length = 8K

sort_buffer_size = 32M

join_buffer_size = 128M

read_buffer_size = 16M

read_rnd_buffer_size = 32M

# 最大内存临时表大小

tmp_table_size = 64M

binlog_cache_size = 1M

################################ log parameter ################################

#错误日志

log_error=/data/mysqldata/3306/data/mysql-error.log

#将影响general log和slow log的存放方式,支持TABLE|FILE

log_output=FILE

#log_error_verbosity

log_error_verbosity=2

#通用日志,记录所有客户端的连接和执行的语句

general_log=OFF

general_log_file=/data/mysqldata/3306/data/mysql-general.log

#慢查

slow_query_log=1

slow_query_log_file=/data/mysqldata/3306/data/mysql-slow.log

long_query_time = 2

#如果运行的SQL语句没有使用索引,则mysql数据库同样会将这条SQL语句记录到慢查询日志文件中

log_queries_not_using_indexes = 1

#由于log_queries_not_using_indexes为1,设置每分钟记录能够记录的数量

log_throttle_queries_not_using_indexes = 10

#记录执行速度较慢的管理命令,如OPTIMEZE TABLE

log_slow_admin_statements = 1

#复制从库记录复制查询的日志###a replication slave does not write replicated queries to the slow query log

log_slow_slave_statements = 1

#查询检查返回少于该参数指定行的SQL不被记录到慢查询日志

min_examined_row_limit = 100

################################ replication parameter ################################

log_slave_updates

relay_log=/data/mysqldata/3306/relay-log/relay_log

master_info_repository = "TABLE"

relay_log_info_repository = "TABLE"

relay_log_recovery = 1

skip-slave-start

# 设置复制过滤

replicate_ignore_table=mysql.columns_priv

replicate_ignore_table=mysql.db

replicate_ignore_table=mysql.host

replicate_ignore_table=mysql.procs_priv

replicate_ignore_table=mysql.tables_priv

replicate_ignore_table=mysql.user

replicate-wild-ignore-table = test.%

replicate-wild-ignore-table = sys.%

# 半同步配置

#plugin_dir=/usr/local/mysql/lib/plugin/

#plugin_load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so"

# 增加强密码策略

#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

#rpl_semi_sync_master_trace_level=64

#rpl_semi_sync_slave_trace_level=64

#rpl_semi_sync_master_wait_no_slave=1

#下面这三个参数打开,则上面rpl_semi相关参数相当于同步打开

#loose_rpl_semi_sync_master_enabled = 1

#loose_rpl_semi_sync_slave_enabled = 1

#loose_rpl_semi_sync_master_timeout = 5000

# password plugin #

#validate_password_policy=STRONG

#validate-password=FORCE_PLUS_PERMANENT

# Replication Master Server (default)

# binary logging is required for replication

log_bin=/data/mysqldata/3306/binlog/mysql-bin

# binlog

autocommit=1

binlog_format=row

# binlog最大值

max_binlog_size=512M

#binlog删除的过期时间 30天

binlog_expire_logs_seconds=2592000

# 保障二进制日志能够刷到磁盘 sync_binlog=1

# 我们这里丢失一些数据没有关系可设置为0

sync_binlog=1

# slave库重连间隔时间

slave_net_timeout=60

#启用GTID

#gtid_mode = on

#enforce_gtid_consistency = 1

#当mysql启动或重启时,mysql在搜寻GTIDs时是如何迭代使用binlog文件的,会提升mysql执行恢复的性能

binlog_gtid_simple_recovery = 1

#复制出错跳过

slave_skip_errors = ddl_exist_errors

#可以在binlog_format=row中记录执行的SQL语句。

binlog_rows_query_log_events = 1

#更好的从机回放算法

slave_rows_search_algorithms = 'INDEX_SCAN,HASH_SCAN'

#基于组提交的并行复制方式

slave_parallel_type = LOGICAL_CLOCK

#复制线程数,但如果主机负载不大,很有可能发生每组提交的事务数量仅有1个,但从机回放时就会有延迟。压力大时可设置为16

slave_parallel_workers = 0

slave_preserve_commit_order=1

slave_transaction_retries=128

################################ MyISAM parameter ################################

key_buffer_size = 64M

myisam_sort_buffer_size = 64M

myisam_repair_threads = 1

################################ innodb parameter ################################

# innodb 独立表空间

innodb_file_per_table=1

# Uncomment the following if you are using InnoDB tables

innodb_data_home_dir=/data/mysqldata/3306/data/

innodb_data_file_path=ibdata1:100M:autoextend

innodb_log_group_home_dir=/data/mysqldata/3306/data/

# Set .._log_file_size to 25 % of buffer pool size

innodb_log_file_size = 1G

innodb_log_buffer_size = 16M

# You can set .._buffer_pool_size up to 50 - 80 %

# of RAM but beware of setting memory usage too high

innodb_buffer_pool_size = 2G

#保障innodb tx log innodb_flush_log_at_trx_commit = 1

# 我们这里丢失一些数据没有关系可设置为2

innodb_flush_log_at_trx_commit = 1

innodb_lock_wait_timeout = 50

# 在innodb lru list 先呆一秒再放到lru头

innodb_old_blocks_time=1000

# 取消二阶段事务

#innodb_support_xa = OFF

# O_DIRECT 刷新

innodb_flush_method=O_DIRECT

#InnoDB缓存池被划分的区域数量,建议每个区域不小于1GB的空间

innodb_buffer_pool_instances = 2

#本地热数据加载到InnoDB缓冲池中

innodb_buffer_pool_load_at_startup = 1

#停止MySQL服务时,InnoDB将InnoDB缓冲池中的热数据保存到本地硬盘

innodb_buffer_pool_dump_at_shutdown = 1

#default 1024, 根据innodb_io_capacity 增加而增加

innodb_lru_scan_depth = 2000

#如果事务因为加锁超时,则整个事务都会回滚

innodb_rollback_on_timeout = 1

# 不开启event

event_scheduler=0

# auto-inc 如果等于2时不会锁表,来一个处理一个,并发最高 ,但不安全,不适合replication

innodb_autoinc_lock_mode = 1

# repair table

myisam_recover_options=force

#收集统计信息每次采样的块数,默认为20

innodb_stats_persistent_sample_pages=64

# 自增ID步长

auto_increment_increment=1

auto_increment_offset=1

# innodb文件格式

#innodb_file_format = Barracuda

#innodb_file_format_max=Barracuda

innodb_io_capacity = 400

innodb_io_capacity_max = 1000

innodb_change_buffering=inserts

innodb_use_native_aio = 1

innodb_strict_mode = 1

innodb_purge_threads=4

innodb_read_io_threads = 4

innodb_write_io_threads = 4

innodb_undo_directory = /data/mysqldata/3306/data

#innodb_undo_logs = 128

innodb_undo_tablespaces = 3

innodb_flush_neighbors = 1

#innodb_large_prefix = 1

innodb_thread_concurrency = 64

innodb_print_all_deadlocks = 1

innodb_sort_buffer_size = 64M

innodb_max_dirty_pages_pct = 90

innodb_log_files_in_group = 3

innodb_buffer_pool_dump_pct = 40

innodb_page_cleaners = 8

innodb_undo_log_truncate = 1

innodb_max_undo_log_size = 2G

innodb_purge_rseg_truncate_frequency = 128

#innodb_rollback_segments=16

#innodb_spin_wait_delay=30

#innodb_sync_spin_loops=100

[mysqldump]

quick

max_allowed_packet = 160M

[mysql]

no-auto-rehash

show-warnings

prompt="8.0 \\u@\\h : \\d \\r:\\m:\\s> "

default-character-set = utf8

# Remove the next comment character if you are not familiar with SQL

#safe-updates

[myisamchk]

key_buffer_size = 256M

sort_buffer_size = 256M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout​​​​

发布了17 篇原创文章 · 获赞 10 · 访问量 15万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章