MySQL常见的配置参数概览

一、MySQL常见的配置参数有400+项,其中DBA常用的配置参数大概可以分为如下几种:

①、各种buffer:缓冲各种配置参数
②、各种cache:缓存各种配置参数
③、各种log:日志相关配置参数
④、各种file:文件相关配置参数
⑤、各种max:各种最大值配置参数

二、在MySQL中输入命令 show global variablesG;可以查看配置参数的明细。如下为结尾部分:

mysql> show global variables\G

省略部分内容

*************************** 435. row ***************************
Variable_name: version
        Value: 5.6.36
*************************** 436. row ***************************
Variable_name: version_comment
        Value: MySQL Community Server (GPL)
*************************** 437. row ***************************
Variable_name: version_compile_machine
        Value: x86_64
*************************** 438. row ***************************
Variable_name: version_compile_os
        Value: linux-glibc2.5
*************************** 439. row ***************************
Variable_name: wait_timeout
        Value: 28800
439 rows in set (0.11 sec)

三、各种buffer相关配置参数

mysql> show global variables like "%buffer%";
+-------------------------------------+----------------+
| Variable_name                       | Value          |
+-------------------------------------+----------------+
| bulk_insert_buffer_size             | 8388608        |
| innodb_buffer_pool_dump_at_shutdown | OFF            |
| innodb_buffer_pool_dump_now         | OFF            |
| innodb_buffer_pool_filename         | ib_buffer_pool |
| innodb_buffer_pool_instances        | 8              |
| innodb_buffer_pool_load_abort       | OFF            |
| innodb_buffer_pool_load_at_startup  | OFF            |
| innodb_buffer_pool_load_now         | OFF            |
| innodb_buffer_pool_size             | 134217728      | 相当于128M
| innodb_change_buffer_max_size       | 25             |
| innodb_change_buffering             | all            |
| innodb_log_buffer_size              | 8388608        |
| innodb_sort_buffer_size             | 1048576        |
| join_buffer_size                    | 262144         |
| key_buffer_size                     | 8388608        |
| myisam_sort_buffer_size             | 8388608        |
| net_buffer_length                   | 16384          |
| preload_buffer_size                 | 32768          |
| read_buffer_size                    | 131072         |
| read_rnd_buffer_size                | 262144         |
| sort_buffer_size                    | 262144         |
| sql_buffer_result                   | OFF            |
+-------------------------------------+----------------+
22 rows in set (0.00 sec)

参数说明:

①、innodb_buffer_pool_size:缓冲池字节大小(建议为物理内存的75%)
默认为128M,MySQL中以KB为单位显示。

②、innodb_log_buffer_size:为尚未执行的日志写入事务分配的缓存(起到I/O加速的作用)

四、各种cache相关配置参数

mysql> show global variables like "%cache%";
+--------------------------------+----------------------+
| Variable_name                  | Value                |
+--------------------------------+----------------------+
| binlog_cache_size              | 32768                |
| binlog_stmt_cache_size         | 32768                |
| have_query_cache               | YES                  |
| host_cache_size                | 279                  |
| innodb_disable_sort_file_cache | OFF                  |
| innodb_ft_cache_size           | 8000000              |
| innodb_ft_result_cache_limit   | 2000000000           |
| innodb_ft_total_cache_size     | 640000000            |
| key_cache_age_threshold        | 300                  |
| key_cache_block_size           | 1024                 |
| key_cache_division_limit       | 100                  |
| max_binlog_cache_size          | 18446744073709547520 |
| max_binlog_stmt_cache_size     | 18446744073709547520 |
| metadata_locks_cache_size      | 1024                 |
| query_cache_limit              | 1048576              |
| query_cache_min_res_unit       | 4096                 |
| query_cache_size               | 1048576              |
| query_cache_type               | OFF                  |
| query_cache_wlock_invalidate   | OFF                  |
| stored_program_cache           | 256                  |
| table_definition_cache         | 1400                 |
| table_open_cache               | 2000                 |
| table_open_cache_instances     | 1                    |
| thread_cache_size              | 9                    |
+--------------------------------+----------------------+
24 rows in set (0.00 sec)

五、各种log相关配置参数

mysql> show global variables like "%log%";
+-----------------------------------------+-----------------------------+
| Variable_name                           | Value                       |
+-----------------------------------------+-----------------------------+
| back_log                                | 80                          |
| binlog_cache_size                       | 32768                       |
| binlog_checksum                         | CRC32                       |
| binlog_direct_non_transactional_updates | OFF                         |
| binlog_error_action                     | IGNORE_ERROR                |
| binlog_format                           | STATEMENT                   |
| binlog_gtid_simple_recovery             | OFF                         |
| binlog_max_flush_queue_time             | 0                           |
| binlog_order_commits                    | ON                          |
| binlog_row_image                        | FULL                        |
| binlog_rows_query_log_events            | OFF                         |
| binlog_stmt_cache_size                  | 32768                       |
| binlogging_impossible_mode              | IGNORE_ERROR                |
| expire_logs_days                        | 0                           |
| general_log                             | OFF                         |
| general_log_file                        | /data/mysql/JSH-01.log      |
| innodb_api_enable_binlog                | OFF                         |
| innodb_flush_log_at_timeout             | 1                           |
| innodb_flush_log_at_trx_commit          | 1                           |
| innodb_locks_unsafe_for_binlog          | OFF                         |
| innodb_log_buffer_size                  | 8388608                     |
| innodb_log_compressed_pages             | ON                          |
| innodb_log_file_size                    | 50331648                    |
| innodb_log_files_in_group               | 2                           |
| innodb_log_group_home_dir               | ./                          |
| innodb_mirrored_log_groups              | 1                           |
| innodb_online_alter_log_max_size        | 134217728                   |
| innodb_undo_logs                        | 128                         |
| log_bin                                 | OFF                         |
| log_bin_basename                        |                             |
| log_bin_index                           |                             |
| log_bin_trust_function_creators         | OFF                         |
| log_bin_use_v1_row_events               | OFF                         |
| log_error                               | /data/mysql/JSH-01.err      |
| log_output                              | FILE                        |
| log_queries_not_using_indexes           | OFF                         |
| log_slave_updates                       | OFF                         |
| log_slow_admin_statements               | OFF                         |
| log_slow_slave_statements               | OFF                         |
| log_throttle_queries_not_using_indexes  | 0                           |
| log_warnings                            | 1                           |
| max_binlog_cache_size                   | 18446744073709547520        |
| max_binlog_size                         | 1073741824                  |
| max_binlog_stmt_cache_size              | 18446744073709547520        |
| max_relay_log_size                      | 0                           |
| relay_log                               |                             |
| relay_log_basename                      |                             |
| relay_log_index                         |                             |
| relay_log_info_file                     | relay-log.info              |
| relay_log_info_repository               | FILE                        |
| relay_log_purge                         | ON                          |
| relay_log_recovery                      | OFF                         |
| relay_log_space_limit                   | 0                           |
| simplified_binlog_gtid_recovery         | OFF                         |
| slow_query_log                          | OFF                         |
| slow_query_log_file                     | /data/mysql/JSH-01-slow.log |
| sql_log_bin                             | ON                          |
| sql_log_off                             | OFF                         |
| sync_binlog                             | 0                           |
| sync_relay_log                          | 10000                       |
| sync_relay_log_info                     | 10000                       |
+-----------------------------------------+-----------------------------+
61 rows in set (0.00 sec)

六、各种file相关配置参数

mysql> show global variables like "%file%";
+---------------------------------------+-----------------------------+
| Variable_name                         | Value                       |
+---------------------------------------+-----------------------------+
| character_set_filesystem              | binary                      |
| core_file                             | OFF                         |
| ft_stopword_file                      | (built-in)                  |
| general_log_file                      | /data/mysql/JSH-01.log      |
| init_file                             |                             |
| innodb_buffer_pool_filename           | ib_buffer_pool              |
| innodb_data_file_path                 | ibdata1:12M:autoextend      |
| innodb_disable_sort_file_cache        | OFF                         |
| innodb_file_format                    | Antelope                    |
| innodb_file_format_check              | ON                          |
| innodb_file_format_max                | Antelope                    |
| innodb_file_per_table                 | ON                          |
| innodb_log_file_size                  | 50331648                    |
| innodb_log_files_in_group             | 2                           |
| innodb_open_files                     | 2000                        |
| keep_files_on_create                  | OFF                         |
| large_files_support                   | ON                          |
| local_infile                          | ON                          |
| lower_case_file_system                | OFF                         |
| myisam_max_sort_file_size             | 9223372036853727232         |
| open_files_limit                      | 65535                       |
| performance_schema_max_file_classes   | 50                          |
| performance_schema_max_file_handles   | 32768                       |
| performance_schema_max_file_instances | 7693                        |
| pid_file                              | /data/mysql/JSH-01.pid      |
| relay_log_info_file                   | relay-log.info              |
| secure_file_priv                      | NULL                        |
| slow_query_log_file                   | /data/mysql/JSH-01-slow.log |
+---------------------------------------+-----------------------------+
28 rows in set (0.00 sec)

七、各种max相关配置参数

mysql> show global variables like "%max%";
+------------------------------------------+----------------------+
| Variable_name                            | Value                |
+------------------------------------------+----------------------+
| binlog_max_flush_queue_time              | 0                    |
| ft_max_word_len                          | 84                   |
| group_concat_max_len                     | 1024                 |
| innodb_adaptive_max_sleep_delay          | 150000               |
| innodb_change_buffer_max_size            | 25                   |
| innodb_compression_pad_pct_max           | 50                   |
| innodb_file_format_max                   | Antelope             |
| innodb_ft_max_token_size                 | 84                   |
| innodb_io_capacity_max                   | 2000                 |
| innodb_max_dirty_pages_pct               | 75                   |
| innodb_max_dirty_pages_pct_lwm           | 0                    |
| innodb_max_purge_lag                     | 0                    |
| innodb_max_purge_lag_delay               | 0                    |
| innodb_online_alter_log_max_size         | 134217728            |
| max_allowed_packet                       | 4194304              |
| max_binlog_cache_size                    | 18446744073709547520 |
| max_binlog_size                          | 1073741824           |
| max_binlog_stmt_cache_size               | 18446744073709547520 |
| max_connect_errors                       | 100                  |
| max_connections                          | 151                  |
| max_delayed_threads                      | 20                   |
| max_digest_length                        | 1024                 |
| max_error_count                          | 64                   |
| max_heap_table_size                      | 16777216             |
| max_insert_delayed_threads               | 20                   |
| max_join_size                            | 18446744073709551615 |
| max_length_for_sort_data                 | 1024                 |
| max_prepared_stmt_count                  | 16382                |
| max_relay_log_size                       | 0                    |
| max_seeks_for_key                        | 18446744073709551615 |
| max_sort_length                          | 1024                 |
| max_sp_recursion_depth                   | 0                    |
| max_tmp_tables                           | 32                   |
| max_user_connections                     | 0                    |
| max_write_lock_count                     | 18446744073709551615 |
| myisam_max_sort_file_size                | 9223372036853727232  |
| optimizer_trace_max_mem_size             | 16384                |
| performance_schema_max_cond_classes      | 80                   |
| performance_schema_max_cond_instances    | 3504                 |
| performance_schema_max_digest_length     | 1024                 |
| performance_schema_max_file_classes      | 50                   |
| performance_schema_max_file_handles      | 32768                |
| performance_schema_max_file_instances    | 7693                 |
| performance_schema_max_mutex_classes     | 200                  |
| performance_schema_max_mutex_instances   | 15906                |
| performance_schema_max_rwlock_classes    | 40                   |
| performance_schema_max_rwlock_instances  | 9102                 |
| performance_schema_max_socket_classes    | 10                   |
| performance_schema_max_socket_instances  | 322                  |
| performance_schema_max_stage_classes     | 150                  |
| performance_schema_max_statement_classes | 168                  |
| performance_schema_max_table_handles     | 4000                 |
| performance_schema_max_table_instances   | 12500                |
| performance_schema_max_thread_classes    | 50                   |
| performance_schema_max_thread_instances  | 402                  |
| slave_max_allowed_packet                 | 1073741824           |
| slave_pending_jobs_size_max              | 16777216             |
+------------------------------------------+----------------------+
57 rows in set (0.00 sec)
上一篇:ECS 7天实践训练营 Day1


下一篇:阿里七天训练营(一):搭建专属的静态网站