国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

MySQL 8.0新特性 — 管理端口的使用簡介

瀏覽:22日期:2023-10-04 18:14:28
前言

下面這個報錯,相信大多數(shù)童鞋都遇見過;那么碰到這個問題,我們應該怎么辦呢?在MySQL 5.7及之前版本,出現(xiàn)“too many connection”報錯,超級用戶root也無法登錄上去,除了重啟實例,沒有其他更好的解決辦法;不過在MySQL 8.0版本中,是對連接管理做了一些優(yōu)化,下面我們就來看一下。

ERROR 1040 (HY000): Too many connections連接管理

在MySQL 8.0版本中,對連接管理這一塊,是先后做了兩個比較大的改變:一個是允許額外連接,另一個是專用的管理端口。

額外連接

在MySQL 8.0版本中,在當前連接數(shù)達到最大連接數(shù)時,服務端允許1個額外連接,可以讓具有CONNECTION_ADMIN權限的用戶連接進來,下面簡單測試一下。

(1)為了方便測試,先調整最大連接數(shù)

mysql> set global max_connections=3;Query OK, 0 rows affected (0.00 sec)

(2)多開幾個會話,以達到最大連接數(shù)

mysql> show processlist;+----+-----------------+-----------------+------+---------+--------+------------------------+------------------+| Id | User | Host | db | Command | Time | State | Info |+----+-----------------+-----------------+------+---------+--------+------------------------+------------------+| 15 | event_scheduler | localhost | NULL | Daemon | 154190 | Waiting on empty queue | NULL || 54 | root | localhost | NULL | Query | 0 | starting | show processlist || 55 | test | 127.0.0.1:59120 | NULL | Sleep | 19 | | NULL || 56 | test | 127.0.0.1:59136 | NULL | Sleep | 9 | | NULL |+----+-----------------+-----------------+------+---------+--------+------------------------+------------------+4 rows in set (0.00 sec)mysql> show global status like ’threads_connected’;+-------------------+-------+| Variable_name | Value |+-------------------+-------+| Threads_connected | 3 |+-------------------+-------+4 rows in set (0.01 sec)

(3)普通用戶test嘗試連接,報錯too many connections

$ mysql -utest -p -h127.0.0.1 -P10080Enter password: ERROR 1040 (08004): Too many connections

(4)超級用戶root嘗試連接成功

$ mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 60Server version: 8.0.20 MySQL Community Server - GPLCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ’help;’ or ’h’ for help. Type ’c’ to clear the current input statement.mysql>

(5)再次查看當前連接數(shù),為max_connections+1

+----+-----------------+-----------------+------+---------+--------+------------------------+------------------+| Id | User | Host | db | Command | Time | State | Info |+----+-----------------+-----------------+------+---------+--------+------------------------+------------------+| 15 | event_scheduler | localhost | NULL | Daemon | 155064 | Waiting on empty queue | NULL || 54 | root | localhost | NULL | Query | 0 | starting | show processlist || 55 | test | 127.0.0.1:59120 | NULL | Sleep | 893 | | NULL || 56 | test | 127.0.0.1:59136 | NULL | Sleep | 883 | | NULL || 60 | root | localhost | NULL | Sleep | 141 | | NULL |+----+-----------------+-----------------+------+---------+--------+------------------------+------------------+5 rows in set (0.00 sec)mysql> show global status like ’threads_connected’;+-------------------+-------+| Variable_name | Value |+-------------------+-------+| Threads_connected | 4 |+-------------------+-------+4 rows in set (0.00 sec)

(6)超級用戶root再次嘗試連接,也報錯too many connections

$ mysql -uroot -pEnter password: ERROR 1040 (HY000): Too many connections

通過上面測試可知,在MySQL 8.0中,允許的連接數(shù)為max_connections+1,其中這1個額外連接,只允許具有CONNECTION_ADMIN權限的用戶使用。通過這1個額外連接,DBA可以使用超級用戶root連接,進行kill會話等管理操作,以避免直接重啟實例,降低成本,提高效率。

管理端口

額外連接,在一定程度上,提供了出現(xiàn)too many connection問題時的臨時解決手段,但額外數(shù)量只有1個,難免會有一些意外,出現(xiàn)類似'連接被搶用'、“終端異常掉線”等情況。因此,在MySQL 8.0.14版本中,又推出了一個非常重要的新特性——管理端口;它允許具有SERVICE_CONNECTION_ADMIN權限的用戶,通過特定的IP和PORT連接上來,且沒有連接數(shù)限制。

(1)先介紹下相關參數(shù)

admin_address:監(jiān)聽IP地址admin_port:監(jiān)聽端口create_admin_listener_thread:是否創(chuàng)建一個單獨的線程來監(jiān)聽管理連接

(2)通過配置上述參數(shù),即可啟用管理端口

mysql> show global variables like ’admin%’;+---------------+-----------+| Variable_name | Value |+---------------+-----------+| admin_address | 127.0.0.1 || admin_port | 33062 |+---------------+-----------+2 rows in set (0.00 sec)# netstat -lntp | grep 33062tcp 0 0 127.0.0.1:33062 0.0.0.0:* LISTEN 20042/mysqld

(3)接下來進行測試

mysql> show processlist;+----+-----------------+-----------------+------+---------+--------+------------------------+------------------+| Id | User | Host | db | Command | Time | State | Info |+----+-----------------+-----------------+------+---------+--------+------------------------+------------------+| 15 | event_scheduler | localhost | NULL | Daemon | 168750 | Waiting on empty queue | NULL || 54 | root | localhost | NULL | Query | 0 | starting | show processlist || 55 | test | 127.0.0.1:59120 | NULL | Sleep | 14579 | | NULL || 56 | test | 127.0.0.1:59136 | NULL | Sleep | 14569 | | NULL |+----+-----------------+-----------------+------+---------+--------+------------------------+------------------+4 rows in set (0.00 sec)mysql> show global status like ’threads_connected’;+-------------------+-------+| Variable_name | Value |+-------------------+-------+| Threads_connected | 3 |+-------------------+-------+1 row in set (0.00 sec)

(4)普通用戶test嘗試連接,報錯too many connections

$ mysql -utest -p -h127.0.0.1 -P10080Enter password: ERROR 1040 (08004): Too many connections

(5)超級用戶root嘗試通過管理端口連接成功

$ mysql -uroot -p -h127.0.0.1 -P33062Enter password: Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 62Server version: 8.0.20 MySQL Community Server - GPLCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ’help;’ or ’h’ for help. Type ’c’ to clear the current input statement.mysql>

(6)繼續(xù)多開幾個會話,使用超級用戶root,通過管理端口連接成功,不受最大連接數(shù)max_connections限制

mysql> show processlist;+----+-----------------+-----------------+------+---------+--------+------------------------+------------------+| Id | User | Host | db | Command | Time | State | Info |+----+-----------------+-----------------+------+---------+--------+------------------------+------------------+| 15 | event_scheduler | localhost | NULL | Daemon | 169035 | Waiting on empty queue | NULL || 54 | root | localhost | NULL | Query | 0 | starting | show processlist || 55 | test | 127.0.0.1:59120 | NULL | Sleep | 14864 | | NULL || 56 | test | 127.0.0.1:59136 | NULL | Sleep | 14854 | | NULL || 62 | root | 127.0.0.1:47660 | NULL | Sleep | 151 | | NULL || 63 | root | 127.0.0.1:47760 | NULL | Sleep | 52 | | NULL || 64 | root | 127.0.0.1:47768 | NULL | Sleep | 43 | | NULL || 65 | root | 127.0.0.1:47780 | NULL | Sleep | 35 | | NULL || 66 | root | 127.0.0.1:47790 | NULL | Sleep | 24 | | NULL || 67 | root | 127.0.0.1:47800 | NULL | Sleep | 16 | | NULL || 68 | root | 127.0.0.1:47808 | NULL | Sleep | 8 | | NULL |+----+-----------------+-----------------+------+---------+--------+------------------------+------------------+11 rows in set (0.00 sec)mysql> show global status like ’threads_connected’;+-------------------+-------+| Variable_name | Value |+-------------------+-------+| Threads_connected | 10 |+-------------------+-------+1 row in set (0.00 sec)

可以說,有了管理端口這個新功能,DBA再也不用擔心too many connections的問題。

總結

在MySQL 8.0版本中,為了應對too many connections的場景,先后推出了額外連接和管理端口兩個新功能,可以讓DBA方便、快速地解決問題;不過,這始終是一個臨時應急手段,最根本的原因還是要排查應用端的配置(并發(fā)限流、SQL性能、連接池配置等等),以徹底規(guī)避此類問題。

以上就是MySQL 8.0新特性 — 管理端口的使用簡介的詳細內容,更多關于MySQL 8.0新特性 — 管理端口的資料請關注好吧啦網(wǎng)其它相關文章!

相關文章:
主站蜘蛛池模板: 日韩国产在线观看 | 久久久久久久性潮 | 日本一视频一区视频二区 | 在线观看日韩www视频免费 | 国产主播福利精品一区二区 | 91pao强力打造免费高清 | 欧美一级毛片免费看视频 | 欧美成年黄网站色视频 | 成人免费高清视频网址 | 91亚洲最新精品 | 亚洲精品98久久久久久中文字幕 | 亚洲高清国产拍精品影院 | 91在线永久 | 久久综合给会久久狠狠狠 | 成人毛片免费视频播放 | 私人午夜影院 | 欧美日韩精品国产一区在线 | 女人张开腿让男人桶视频 | 久久久久免费精品国产 | 午夜影院免费体验 | 欧美日本一区亚洲欧美一区 | 大陆老头xxxxxhd | 女人毛片a毛片久久人人 | 亚洲成人免费在线 | 久久a热6 | 免费观看成人毛片 | 日本一区二区高清不卡 | 国产成人精品久久二区二区 | 成人久久18免费网站 | 亚洲视频一区在线观看 | 6080伦理久久亚洲精品 | 热久久在线观看 | 一级做a爰片性色毛片中国 一级做a爰性色毛片 | 国内自拍欧美 | 一级色黄| 欧美日韩亚洲视频 | 男女男在线精品网站免费观看 | 精品国产一区二区三区不卡蜜臂 | 久久99精品久久久久久久野外 | 亚洲综合色自拍一区 | 亚洲高清一区二区三区久久 |