MYSQL5.6重要参数

版本msyql5.6,原笔记上面的有些粗糙

一、在线mysql修改timeout值

show processlist;

 set global interactive_timeout=400;

set global wait_timeout=400;

Exit

 

二、关于在线innodb参数使用情况

mysql> show global status like 'innodb_buffer_pool_pages%';

+----------------------------------+---------+

| Variable_name                    | Value   |

+----------------------------------+---------+

| Innodb_buffer_pool_pages_data    | 384598  |   //使用页

| Innodb_buffer_pool_pages_dirty   | 476     |

| Innodb_buffer_pool_pages_flushed | 1329814 |

| Innodb_buffer_pool_pages_free    | 3072    |  //空闲页

| Innodb_buffer_pool_pages_misc    | 5544    |

| Innodb_buffer_pool_pages_total   | 393214  |   //总页数

+----------------------------------+---------+

空闲页面很多,说明设置过大,相反如果空闲页面少,说明需要innodb_buffer_pool_size值调大;

——————————————————————————————————

mysql> show variables like 'innodb_log%';

+-----------------------------+-----------+

| Variable_name               | Value     |

+-----------------------------+-----------+

| innodb_log_buffer_size      | 8388608   | //把这次改动的记录写到日志缓存中

mysql> show global status like '%innodb_log_waits%';

+------------------+-------+

| Variable_name    | Value |

+------------------+-------+

| Innodb_log_waits | 0     |  //大于0,继续增大,要调整innodb_log_buffer_size大小,取值16MB-64MB

+------------------+-------+

 

show global status like '%binlog_cache%';

ERROR 2006 (HY000): MySQL server has gone away

No connection. Trying to reconnect...

Connection id:    17122163

Current database: *** NONE ***

 

+-----------------------+--------+

| Variable_name         | Value  |

+-----------------------+--------+

| Binlog_cache_disk_use | 3306   |  //不为0.说明磁盘上的临时文件被用上, 要调binlog_cache_size

| Binlog_cache_use      | 593010 |

+-----------------------+--------+

Binlog_cache_disk_use表示因为我们binlog_cache_size设计的内存不足导致缓存二进制日志用到了临时文件的次数

配置

a.配置文件设置my.cnf

binlog_cache_size = 1M

b. set global binlog_cache_size = 1048576

 

mysqldumpslow  -s t -t 10 /data/mysql/mysql-slow.log

查询的结果是10条执行时间最慢的sql语句,其中-s t是指此类类型的语句的执

Time=3.73s (2205s) 最长的执行时间,2205统计用的时间

 

 

关于慢查询 slow

Mysqldumpslow 不好用情况下,percona-toolkit工具,pt-query-digest

mysqldumpslow -s t -t 10 /data/mysql/mysql-slow.log

 

Pt-query-digest --since=24h /data/mysql/slow.log >query.log

分析24小时query.log   overall 总有多少条查询

       Time range:查询执行的时间范围

Unique:唯一查询数量

   Total:

   95%:小到大排列

 Median:中位数

Pid文件,将自己唯一进程号记录到自己pid文件中

Socket文件:是服务器与本地客户端进行通信的UNIX套接字文件

对记录做变更操作时不仅会产生redo记录,也会产生undo记录(insert update delete),但undo只记录变更前的旧数据

 

 

Show global status

+-----------------------------------------------+---------------------+

| Variable_name                                 | Value               |

+-----------------------------------------------+---------------------+

| Aborted_clients                               | 70979               |//客户端没有正确关闭连接导致客户端连接终止,以及连接超时

| Aborted_connects                              | 466                 |//连接数据库失败的连接数

| Binlog_cache_disk_use                         | 3308                |//临时二进制日志缓存,是超过binlog_cache_size值并使用临时文件来保存事务中语句的事务数量

| Binlog_cache_use                              | 599563              | //使用临时二进制日志缓存事物数量

| Binlog_stmt_cache_disk_use                    | 2741                |//当非事物语句使用二进制日志缓存,但是超出binlog_stmt_cache_size大小时,就会使用一个临时文件来存放这些语句

| Binlog_stmt_cache_use                         | 4027                | //使用二进制日志缓存文件的非事物语句数量

| Bytes_received                                | 12624572922         |

| Bytes_sent                                    | 38490032931         |

| Com_admin_commands                            | 1220886             |

| Com_assign_to_keycache                        | 0                   |

| Com_alter_db                                  | 0                   |

| Com_alter_db_upgrade                          | 0                   |

| Com_alter_event                               | 0                   |

| Com_alter_function                            | 0                   |

| Com_alter_procedure                           | 0                   |

| Com_alter_server                              | 0                   |

| Com_alter_table                               | 486                 |

| Com_alter_tablespace                          | 0                   |

| Com_alter_user                                | 0                   |

| Com_analyze                                   | 0                   |

| Com_begin                                     | 10954               |

| Com_binlog                                    | 0                   |

| Com_call_procedure                            | 0                   |

| Com_change_db                                 | 41989               |

| Com_change_master                             | 3                   |

| Com_check                                     | 0                   |

| Com_checksum                                  | 0                   |

| Com_commit                                    | 457143              |

| Com_create_db                                 | 8                   |

| Com_create_event                              | 0                   |

| Com_create_function                           | 0                   |

| Com_create_index                              | 0                   |

| Com_create_procedure                          | 0                   |

| Com_create_server                             | 0                   |

| Com_create_table                              | 233                 |

| Com_create_trigger                            | 3                   |

| Com_create_udf                                | 0                   |

| Com_create_user                               | 0                   |

| Com_create_view                               | 0                   |

| Com_dealloc_sql                               | 0                   |

| Com_delete                                    | 388                 |

| Com_delete_multi                              | 0                   |

| Com_do                                        | 0                   |

| Com_drop_db                                   | 4                   |

| Com_drop_event                                | 0                   |

| Com_drop_function                             | 0                   |

| Com_drop_index                                | 0                   |

| Com_drop_procedure                            | 0                   |

| Com_drop_server                               | 0                   |

| Com_drop_table                                | 235                 |

| Com_drop_trigger                              | 0                   |

| Com_drop_user                                 | 0                   |

| Com_drop_view                                 | 0                   |

| Com_empty_query                               | 0                   |

| Com_execute_sql                               | 0                   |

| Com_flush                                     | 5                   |

| Com_get_diagnostics                           | 0                   |

| Com_grant                                     | 2                   |

| Com_ha_close                                  | 0                   |

| Com_ha_open                                   | 0                   |

| Com_ha_read                                   | 0                   |

| Com_help                                      | 0                   |

| Com_insert                                    | 549789              |

| Com_insert_select                             | 0                   |

| Com_install_plugin                            | 0                   |

| Com_kill                                      | 0                   |

| Com_load                                      | 0                   |

| Com_lock_tables                               | 231                 |

| Com_optimize                                  | 0                   |

| Com_preload_keys                              | 0                   |

| Com_prepare_sql                               | 0                   |

| Com_purge                                     | 0                   |

| Com_purge_before_date                         | 0                   |

| Com_release_savepoint                         | 0                   |

| Com_rename_table                              | 0                   |

| Com_rename_user                               | 0                   |

| Com_repair                                    | 0                   |

| Com_replace                                   | 59                  |

| Com_replace_select                            | 0                   |

| Com_reset                                     | 4                   |

| Com_resignal                                  | 0                   |

| Com_revoke                                    | 0                   |

| Com_revoke_all                                | 0                   |

| Com_rollback                                  | 404                 |

| Com_rollback_to_savepoint                     | 0                   |

| Com_savepoint                                 | 0                   |

| Com_select                                    | 30597749            |

| Com_set_option                                | 18025324            |

| Com_signal                                    | 0                   |

| Com_show_binlog_events                        | 0                   |

| Com_show_binlogs                              | 0                   |

| Com_show_charsets                             | 11                  |

| Com_show_collations                           | 11                  |

| Com_show_create_db                            | 10                  |

| Com_show_create_event                         | 0                   |

| Com_show_create_func                          | 0                   |

| Com_show_create_proc                          | 0                   |

| Com_show_create_table                         | 3132                |

| Com_show_create_trigger                       | 3                   |

| Com_show_databases                            | 72                  |

| Com_show_engine_logs                          | 0                   |

| Com_show_engine_mutex                         | 0                   |

| Com_show_engine_status                        | 0                   |

| Com_show_events                               | 0                   |

| Com_show_errors                               | 0                   |

| Com_show_fields                               | 10240               |

| Com_show_function_code                        | 0                   |

| Com_show_function_status                      | 8                   |

| Com_show_grants                               | 0                   |

| Com_show_keys                                 | 199                 |

| Com_show_master_status                        | 156                 |

| Com_show_open_tables                          | 0                   |

| Com_show_plugins                              | 0                   |

| Com_show_privileges                           | 0                   |

| Com_show_procedure_code                       | 0                   |

| Com_show_procedure_status                     | 8                   |

| Com_show_processlist                          | 52                  |

| Com_show_profile                              | 0                   |

| Com_show_profiles                             | 0                   |

| Com_show_relaylog_events                      | 0                   |

| Com_show_slave_hosts                          | 0                   |

| Com_show_slave_status                         | 123                 |

| Com_show_status                               | 86                  |

| Com_show_storage_engines                      | 29                  |

| Com_show_table_status                         | 1160                |

| Com_show_tables                               | 158                 |

| Com_show_triggers                             | 920                 |

| Com_show_variables                            | 146                 |

| Com_show_warnings                             | 0                   |

| Com_slave_start                               | 4                   |

| Com_slave_stop                                | 5                   |

| Com_stmt_close                                | 25984               |

| Com_stmt_execute                              | 25984               |

| Com_stmt_fetch                                | 0                   |

| Com_stmt_prepare                              | 25984               |

| Com_stmt_reprepare                            | 0                   |

| Com_stmt_reset                                | 0                   |

| Com_stmt_send_long_data                       | 0                   |

| Com_truncate                                  | 0                   |

| Com_uninstall_plugin                          | 0                   |

| Com_unlock_tables                             | 231                 |

| Com_update                                    | 549840              |

| Com_update_multi                              | 0                   |

| Com_xa_commit                                 | 0                   |

| Com_xa_end                                    | 0                   |

| Com_xa_prepare                                | 0                   |

| Com_xa_recover                                | 0                   |

| Com_xa_rollback                               | 0                   |

| Com_xa_start                                  | 0                   |

| Compression                                   | OFF                 |

| Connection_errors_accept                      | 0                   |

| Connection_errors_internal                    | 0                   |

| Connection_errors_max_connections             | 0                   |

| Connection_errors_peer_address                | 0                   |

| Connection_errors_select                      | 0                   |

| Connection_errors_tcpwrap                     | 0                   |

| Connections                                   | 17286940            |

| Created_tmp_disk_tables                       | 21299               | //服务器执行语句时在硬盘上自动创建的临时表的数量

| Created_tmp_files                             | 4983                | //服务器执行语句时自动创建的内存中的临时表的数量,如果Created_tmp_disk_tables参数大,可能要增加tmp_table_size值,使临时表基于内存而不基于硬盘

Created_tmp_disk_tables / Created_tmp_tables * 100% <= 25% 比较好

| Created_tmp_tables                            | 146943              |

| Delayed_errors                                | 0                   |

| Delayed_insert_threads                        | 0                   |

| Delayed_writes                                | 0                   |

| Flush_commands                                | 3                   |

| Handler_commit                                | 33633280            |//内部提交语句数量

| Handler_delete                                | 450901              |

| Handler_discover                              | 0                   |

| Handler_external_lock                         | 72477269            |

| Handler_mrr_init                              | 0                   |

| Handler_prepare                               | 3052914             |

| Handler_read_first                            | 1218011             |

| Handler_read_key                              | 122750038676        |

| Handler_read_last                             | 304457              |

| Handler_read_next                             | 1836980702077       |

| Handler_read_prev                             | 54873155031         |

| Handler_read_rnd                              | 119396899834        |

| Handler_read_rnd_next                         | 55736189757         |

| Handler_rollback                              | 174                 |

| Handler_savepoint                             | 0                   |

| Handler_savepoint_rollback                    | 0                   |

| Handler_update                                | 868882084           |

| Handler_write                                 | 810135258           |

| Innodb_buffer_pool_dump_status                | not started         |

| Innodb_buffer_pool_load_status                | not started         |

| Innodb_buffer_pool_pages_data                 | 384599              |

| Innodb_buffer_pool_bytes_data                 | 6301270016          |

| Innodb_buffer_pool_pages_dirty                | 1010                |

| Innodb_buffer_pool_bytes_dirty                | 16547840            |

| Innodb_buffer_pool_pages_flushed              | 1348133             |

| Innodb_buffer_pool_pages_free                 | 3085                |

| Innodb_buffer_pool_pages_misc                 | 5530                |

| Innodb_buffer_pool_pages_total                | 393214              |

| Innodb_buffer_pool_read_ahead_rnd             | 0                   |

| Innodb_buffer_pool_read_ahead                 | 59653               |

| Innodb_buffer_pool_read_ahead_evicted         | 0                   |

| Innodb_buffer_pool_read_requests              | 522476284584        |

| Innodb_buffer_pool_reads                      | 27587               |

| Innodb_buffer_pool_wait_free                  | 0                   |//通过后台向innodb缓存池页,

如果该值大于0,需要增加innodb_buffer_pool大小

| Innodb_buffer_pool_write_requests             | 223185947           |

| Innodb_data_fsyncs                            | 1287541             |

| Innodb_data_pending_fsyncs                    | 0                   |

| Innodb_data_pending_reads                     | 0                   |

| Innodb_data_pending_writes                    | 0                   |

| Innodb_data_read                              | 1475563520          |

| Innodb_data_reads                             | 90656               |

| Innodb_data_writes                            | 2483930             |

| Innodb_data_written                           | 53829655552         |

| Innodb_dblwr_pages_written                    | 1348133             |

| Innodb_dblwr_writes                           | 52495               |

| Innodb_have_atomic_builtins                   | ON                  |

| Innodb_log_waits                              | 0                   |

//不为0,增加redo_log_buffer_size 的大小

| Innodb_log_write_requests                     | 20236030            |

| Innodb_log_writes                             | 1050665             |

| Innodb_os_log_fsyncs                          | 1061753             |

| Innodb_os_log_pending_fsyncs                  | 0                   |

| Innodb_os_log_pending_writes                  | 0                   |

| Innodb_os_log_written                         | 9647985152          |

| Innodb_page_size                              | 16384               |

| Innodb_pages_created                          | 402005              |

| Innodb_pages_read                             | 90056               |

| Innodb_pages_written                          | 1348133             |

| Innodb_row_lock_current_waits                 | 0                   |

| Innodb_row_lock_time                          | 508                 |

| Innodb_row_lock_time_avg                      | 127                 |

| Innodb_row_lock_time_max                      | 220                 |

| Innodb_row_lock_waits                         | 4                   |

//当前等待行锁的数量

| Innodb_rows_deleted                           | 450897              |

| Innodb_rows_inserted                          | 47670586            |

| Innodb_rows_read                              | 2067494266811       |

| Innodb_rows_updated                           | 559293              |

| Innodb_num_open_files                         | 262                 |

| Innodb_truncated_status_writes                | 0                   |

| Innodb_available_undo_logs                    | 128                 |

| Key_blocks_not_flushed                        | 0                   |

| Key_blocks_unused                             | 0                   |

| Key_blocks_used                               | 6698                |

| Key_read_requests                             | 1125072100          |

| Key_reads                                     | 196951              |

| Key_write_requests                            | 294293748           |

| Key_writes                                    | 1272202             |

| Last_query_cost                               | 0.000000            |

| Last_query_partial_plans                      | 0                   |

| Max_used_connections                          | 115                 |

| Not_flushed_delayed_rows                      | 0                   |

| Open_files                                    | 1310                |

| Open_streams                                  | 0                   |

| Open_table_definitions                        | 922                 |

| Open_tables                                   | 1084                | //当前打开表数量

| Opened_files                                  | 106007              |

| Opened_table_definitions                      | 2362                |

| Opened_tables                                 | 2326                |//已经打开表的数量,数值非常大,table_open_cache值太小,

| Performance_schema_accounts_lost              | 0                   |

| Performance_schema_cond_classes_lost          | 0                   |

| Performance_schema_cond_instances_lost        | 0                   |

| Performance_schema_digest_lost                | 0                   |

| Performance_schema_file_classes_lost          | 0                   |

| Performance_schema_file_handles_lost          | 0                   |

| Performance_schema_file_instances_lost        | 0                   |

| Performance_schema_hosts_lost                 | 0                   |

| Performance_schema_locker_lost                | 0                   |

| Performance_schema_mutex_classes_lost         | 0                   |

| Performance_schema_mutex_instances_lost       | 0                   |

| Performance_schema_rwlock_classes_lost        | 0                   |

| Performance_schema_rwlock_instances_lost      | 0                   |

| Performance_schema_session_connect_attrs_lost | 0                   |

| Performance_schema_socket_classes_lost        | 0                   |

| Performance_schema_socket_instances_lost      | 0                   |

| Performance_schema_stage_classes_lost         | 0                   |

| Performance_schema_statement_classes_lost     | 0                   |

| Performance_schema_table_handles_lost         | 0                   |

| Performance_schema_table_instances_lost       | 0                   |

| Performance_schema_thread_classes_lost        | 0                   |

| Performance_schema_thread_instances_lost      | 0                   |

| Performance_schema_users_lost                 | 0                   |

| Prepared_stmt_count                           | 0                   |

| Qcache_free_blocks                            | 1                   |

| Qcache_free_memory                            | 1031352             |

| Qcache_hits                                   | 0                   |

| Qcache_inserts                                | 0                   |

| Qcache_lowmem_prunes                          | 0                   |

| Qcache_not_cached                             | 30592784            |

| Qcache_queries_in_cache                       | 0                   |

| Qcache_total_blocks                           | 1                   |

| Queries                                       | 68742245            |

| Questions                                     | 67444341            |

| Rpl_semi_sync_master_clients                  | 2                   |

| Rpl_semi_sync_master_net_avg_wait_time        | 16666               |

| Rpl_semi_sync_master_net_wait_time            | 16396467002         |

| Rpl_semi_sync_master_net_waits                | 983773              |

| Rpl_semi_sync_master_no_times                 | 1                   |

| Rpl_semi_sync_master_no_tx                    | 72385               |

| Rpl_semi_sync_master_status                   | ON                  |

| Rpl_semi_sync_master_timefunc_failures        | 0                   |

| Rpl_semi_sync_master_tx_avg_wait_time         | 971                 |

| Rpl_semi_sync_master_tx_wait_time             | 516125598           |

| Rpl_semi_sync_master_tx_waits                 | 531060              |

| Rpl_semi_sync_master_wait_pos_backtraverse    | 0                   |

| Rpl_semi_sync_master_wait_sessions            | 0                   |

| Rpl_semi_sync_master_yes_tx                   | 531163              |

| Select_full_join                              | 4643                |

| Select_full_range_join                        | 1531                |

| Select_range                                  | 5638901             |

| Select_range_check                            | 0                   |

| Select_scan                                   | 1530785             |

| Slave_heartbeat_period                        | 1800.000            |

| Slave_last_heartbeat                          |                     |

| Slave_open_temp_tables                        | 0                   |

| Slave_received_heartbeats                     | 0                   |

| Slave_retried_transactions                    | 0                   |

| Slave_running                                 | OFF                 |

| Slow_launch_threads                           | 0                   |

| Slow_queries                                  | 1521693             |

| Sort_merge_passes                             | 2356                |

| Sort_range                                    | 906907              |

| Sort_rows                                     | 819291987           |

| Sort_scan                                     | 382409              |

| Ssl_accept_renegotiates                       | 0                   |

| Ssl_accepts                                   | 0                   |

| Ssl_callback_cache_hits                       | 0                   |

| Ssl_cipher                                    |                     |

| Ssl_cipher_list                               |                     |

| Ssl_client_connects                           | 0                   |

| Ssl_connect_renegotiates                      | 0                   |

| Ssl_ctx_verify_depth                          | 0                   |

| Ssl_ctx_verify_mode                           | 0                   |

| Ssl_default_timeout                           | 0                   |

| Ssl_finished_accepts                          | 0                   |

| Ssl_finished_connects                         | 0                   |

| Ssl_server_not_after                          |                     |

| Ssl_server_not_before                         |                     |

| Ssl_session_cache_hits                        | 0                   |

| Ssl_session_cache_misses                      | 0                   |

| Ssl_session_cache_mode                        | NONE                |

| Ssl_session_cache_overflows                   | 0                   |

| Ssl_session_cache_size                        | 0                   |

| Ssl_session_cache_timeouts                    | 0                   |

| Ssl_sessions_reused                           | 0                   |

| Ssl_used_session_cache_entries                | 0                   |

| Ssl_verify_depth                              | 0                   |

| Ssl_verify_mode                               | 0                   |

| Ssl_version                                   |                     |

| Table_locks_immediate                         | 32383730            |

| Table_locks_waited                            | 0                   |

| Table_open_cache_hits                         | 32427338            |

| Table_open_cache_misses                       | 2325                |

| Table_open_cache_overflows                    | 0                   |

| Tc_log_max_pages_used                         | 0                   |

| Tc_log_page_size                              | 0                   |

| Tc_log_page_waits                             | 0                   |

| Threads_cached                                | 12                  | //线程缓存内的线程的数量

| Threads_connected                             | 9                   |//当前打开连接的数量

| Threads_created                               | 258                 |//创建用来处理连接的线程数,threads_created较大,可能要整加thread_cache_size值

| Threads_running                               | 6                   |

| Uptime                                        | 686746              |

| Uptime_since_flush_status                     | 686746              |

| validate_password_dictionary_file_last_parsed | 2018-08-06 18:19:30 |

| validate_password_dictionary_file_words_count | 0                   |

+-----------------------------------------------+---------------------+

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值