时间:2020-08-09来源:www.pcxitongcheng.com作者:电脑系统城
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
#This configration file opts for MySQL 8.0.20 #Let us make an optimal MySQL configuration file template for product enviroment. # #I assume the MySQL Server as followings. You should tune the variables according to your server. # #* 32 CPU core #* 256G Memory #* SSD storage with 20000 IOPS in 16K page size [client] ##client标签设置mysql、mysqldump、mysqladmin的变量。 user = root password = 1111aaA_ [mysql] ##mysql标签设置mysql客户端的变量。 prompt = [\\u@\\p][\\d]>\\_ tee = "/tmp/tee.log" ##设置客户端的查询日志 pager = "less -i -n -S" ##分页显示查询出的数据,方便搜索查询到的数据 no-auto-rehash ##关闭预读取元数据 [mysqld_safe] [mysqldump] single-transaction [mysqld] # basic settings # innodb_temp_data_file_path ##研究一下这个参数设置成多少合适。 default_authentication_plugin=mysql_native_password sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER" ##server_id = 8888 ##datadir = /mysql_data/data transaction_isolation = READ-COMMITTED event_scheduler = OFF open_files_limit = 327675 ##设置MySQL运行过程中可以打开的文件数,避免出现“too many open files”报错。建议设置值使用公式:10+max_connections+(table_open_cache*2)。 secure_file_priv = /tmp # connection # interactive_timeout = 600 ##交互式连接超时时间(mysql工具、mysqldump工具等) wait_timeout = 600 ##非交互式连接超时时间。指连接mysql的api程序,jdbc连接等。 lock_wait_timeout = 1800 ##DDL操作的锁等待时间 skip_name_resolve = ON max_connections = 1024 max_user_connections = 256 max_connect_errors = 1000000 # table cache performance settings # table_open_cache = 4096 table_definition_cache = 4096 table_open_cache_instances = 64 # session memory settings # read_buffer_size = 16M read_rnd_buffer_size = 32M sort_buffer_size = 32M tmp_table_size = 64M join_buffer_size = 128M thread_cache_size = 64 # optimizer switch settings # optimizer_switch = 'index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off,block_nested_loop=on,batched_key_access=off,materialization=on,semijoin=on,loosescan=on,firstmatch=on,duplicateweedout=on,subquery_materialization_cost_based=on,use_index_extensions=on,condition_fanout_filter=on,derived_merge=on,use_invisible_indexes=off,skip_scan=on,hash_join=on' ##优化器开关设置。 # log settings # log_timestamps = system ##general_log = ON ##general_log_file = /usr/local/mysql/data/MySQL01-general.log slow_query_log = ON long_query_time = 1 ##slow_query_log_file = /usr/local/mysql/data/MySQL01-slow.log log_queries_not_using_indexes = ON log_slow_admin_statements = ON ##log_slow_slave_statements = ON log_throttle_queries_not_using_indexes = 10 expire_logs_days = 90 min_examined_row_limit = 100 log_bin_trust_function_creators = ON # innodb settings # innodb_buffer_pool_size = 160G innodb_buffer_pool_instances = 16 innodb_page_cleaners = 16 ##设置page clean线程的个数。这个值推荐和innodb_buffer_poool_instances相等。该值大于innodb_buffer_poool_instances时,自动设置为与innodb_buffer_poool_instances相同的值。 innodb_lru_scan_depth = 2048 ##控制LRU列表中可用页的数量。默认值1024。写密集型负载使IO饱和,或者使用机械盘时建议使用默认值。调整innodb_lru_scan_depth时,从一个较低的值开始,向上配置设置,目标是很少看到零空闲页面。另外,在更改缓冲池实例的数量时,考虑调整innodb_lru_scan_depth,因为innodb_lru scan_depth*innodb_buffer_pool_instances定义了页面清理线程每秒执行的工作量。推荐使用默认值。 innodb_fast_shutdown = 0 ##设置innodb关机模式。有效值0、1、2。0表示执行慢关机,即在关闭前彻底清除和更改缓冲区合并,这种模式下开机是最快的;1表示关机时跳过上述操作,但是在开机时会执行上述操作,称为快关机;2表示刷新其日志并冷关闭,不会丢失任何已提交的事务下,获得最快的关机,这种模式是开机最慢的。 innodb_max_dirty_pages_pct = 80 ##设置当缓冲池中脏页达到百分之80时,强制进行checkpoint,将一部分脏页刷新到磁盘上。默认值90。推荐值80。这个值不建议设置太小,设置太小会加重IO的写操作。 innodb_buffer_pool_dump_pct = 80 ##正常关机时将innodb_buffer_pool中百分之八十的数据保存到磁盘中 innodb_lock_wait_timeout = 5 ##innodb dml锁的等待超时时间,单位秒。 innodb_rollback_on_timeout = ON ##等待超时的事务进行回滚。 innodb_io_capacity = 400 ##设置后台线程每秒操作IO的次数。默认值200。理想情况下尽可能低,如果太大会从缓冲池中清除过多的数据,反而使缓冲池失去了“缓冲”的作用。对于SSD磁盘默认值200已经足够。15000转的机械磁盘建议设置为200。15000转以下的机械磁盘建议设置为100。 innodb_io_capacity_max = 2000 ##设置在刷新落后时,后台任务执行的最大IOPS数。默认值2000。最小值也是2000。这个值在使用SSD磁盘时也无需调大。 innodb_flush_method = O_DIRECT innodb_flush_neighbors = 0 ##对于SSD盘将这个值设置为0。由于该功能会使不怎么脏的页进行了写入,而后该页又会很快变成脏页,而固态硬盘有超高的IOPS,因此要置为0。可选值1表示刷新相同范围内连续的脏页,可选值2表示刷新相同范围内的脏页。 innodb_undo_tablespaces = 3 innodb_log_file_size = 1900MB ##这个值是百度公司统一的。 innodb_log_files_in_group = 2 innodb_log_buffer_size = 64MB innodb_checksum_algorithm = strict_crc32 ##设置innodb存储引擎每次读取页时,使用checksum函数的哪个算法。 innodb_thread_concurrency = 32 innodb_print_all_deadlocks = ON ##将死锁信息打印到mysql错误日志中 innodb_sort_buffer_size = 64M innodb_write_io_threads = 16 innodb_read_io_threads = 16 innodb_stats_persistent_sample_pages = 64 innodb_online_alter_log_max_size = 1G innodb_open_files = 4096 # replication settings # sync_binlog = 1 ##当有多个从库,并且开启了半同步复制这个值可以设置成1000。百度公司在半同步复制时统一设置成1000。 ##gtid_mode = ON ##enforce_gtid_consistency = ON ##binlog_gtid_simple_recovery = ON log_slave_updates = OFF binlog_rows_query_log_events = ON relay_log_recovery = ON ##slave_skip_errors = ddl_exist_errors # replication settings for slave # ##slave_parallel_workers = 16 ##设置多线程SQL线程数量 ##slave_parallel_type = LOGICAL_CLOCK ##设置多线程复制的模式 ##slave_preserve_commit_order = ON ##slave_transaction_retries = 128 # semi sync replication settings # ##rpl_semi_sync_master_enabled = ON ##rpl_semi_sync_master_timeout = 1000 # semi sync replication settings for slave # ##rpl_semi_sync_slave_enabled = ON # perforamnce_schema settings performance_schema_digests_size = 40000 performance_schema_max_table_handles = 40000 performance_schema_max_table_instances = 40000 performance_schema_max_sql_text_length = 4096 performance_schema_max_digest_length = 4096 # group replication settings # ##plugin-load = "group_replication.so;validate_password.so;semisync_master.so;semisync_slave.so" ##transaction-write-set-extraction = XXHASH64 ##report_host = 127.0.0.1 # optional for group replication ##binlog_checksum = NONE # only for group replication ##loose_group_replication = FORCE_PLUS_PERMANENT ##loose_group_replication_group_name = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" ##loose_group_replication_compression_threshold = 100 ##loose_group_replication_flow_control_mode = 0 ##loose_group_replication_single_primary_mode = 0 ##loose_group_replication_enforce_update_everywhere_checks = 1 ##loose_group_replication_transaction_size_limit = 10485760 ##loose_group_replication_unreachable_majority_timeout = 120 ##loose_group_replication_start_on_boot = 0 |
2023-10-30
windows上的mysql服务突然消失提示10061 Unkonwn error问题及解决方案2023-10-30
MySQL非常重要的日志bin log详解2023-10-30
详解MySQL事务日志redo log一、单表查询 1、排序 2、聚合函数 3、分组 4、limit 二、SQL约束 1、主键约束 2、非空约束 3、唯一约束 4、外键约束 5、默认值 三、多表查询 1、内连接 1)隐式内连接: 2)显式内连接: 2、外连接 1)左外连接 2)右外连接 四...
2023-10-30
Mysql删除表重复数据 表里存在唯一主键 没有主键时删除重复数据 Mysql删除表中重复数据并保留一条 准备一张表 用的是mysql8 大家自行更改 创建表并添加四条相同的数据...
2023-10-30