mysql5.7碰到的坑


日志輸出時區問題


輸出日志有這些信息
2016-08-16T02:23:09.831827Z 112241 [Note] Aborted connection 112241 to db: 'test' user: 'admin_logs' host: 'ip' (Got an error reading communication packets)
時區信息比系統時間晚八個小時
mysql> show global variables like '%time%';
+----------------------------------+-------------------+
| Variable_name                    | Value             |
+----------------------------------+-------------------+
| binlog_max_flush_queue_time      | 0                 |
| connect_timeout                  | 10                |
| datetime_format                  | %Y-%m-%d %H:%i:%s |
| default_password_lifetime        | 0                 |
| delayed_insert_timeout           | 300               |
| explicit_defaults_for_timestamp  | ON                |
| flush_time                       | 0                 |
| have_statement_timeout           | YES               |
| innodb_flush_log_at_timeout      | 1                 |
| innodb_lock_wait_timeout         | 3                 |
| innodb_old_blocks_time           | 1000              |
| innodb_rollback_on_timeout       | OFF               |
| interactive_timeout              | 3600              |
| lc_time_names                    | en_US             |
| lock_wait_timeout                | 31536000          |
| log_timestamps                   | UTC               |
| long_query_time                  | 2.000000          |
| max_execution_time               | 0                 |
| net_read_timeout                 | 30                |
| net_write_timeout                | 60                |
| rpl_stop_slave_timeout           | 31536000          |
| slave_net_timeout                | 60                |
| slow_launch_time                 | 2                 |
| slow_query_log_always_write_time | 10.000000         |
| system_time_zone                 | CST               |
| thread_pool_idle_timeout         | 60                |
| time_format                      | %H:%i:%s          |
| time_zone                        | SYSTEM            |
| wait_timeout                     | 3600              |
+----------------------------------+-------------------+
從上面結果可以看到log_timestamps為UTC
修改日志格式時區為system
SET GLOBAL log_timestamps = SYSTEM;

線程池idle超時問題

現象


2016-08-16T10:34:05.578546+08:00 112225 [Note] Aborted connection 112225 to db: 'admin_pandatv_logs' user: 'admin_logs' host: '10.110.19.72' (Got an error reading communication packets)
2016-08-16T10:36:32.357267+08:00 112144 [Note] Aborted connection 112144 to db: 'admin_pandatv_logs' user: 'admin_logs' host: '10.110.19.73' (Got an error reading communication packets)
2016-08-16T10:37:35.649574+08:00 112243 [Note] Aborted connection 112243 to db: 'admin_pandatv_logs' user: 'admin_logs' host: '10.110.19.72' (Got an error reading communication packets)
2016-08-16T10:41:14.044258+08:00 112091 [Note] Aborted connection 112091 to db: 'admin_pandatv_logs' user: 'admin_logs' host: '10.110.19.72' (Got an error reading communication packets)
2016-08-16T10:43:58.980932+08:00 112228 [Note] Aborted connection 112228 to db: 'admin_pandatv_logs' user: 'admin_logs' host: '10.110.19.73' (Got an error reading communication packets)

原因


thread_pool_idle_timeout 設置的是60S
當有業務訪問時,atlas會和mysql建立連接池,60S內如果持續有訪問那么會復用該連接池,如果60S內無訪問,那么mysql端就會進行回收空閑連接

# 解決

對於這種問題,個人覺得不用去刻意更改他,對於高並發業務這個錯誤不會出現,對於低並發業務重新建立一次連接本身也不會有多大性能損耗


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM