您好,登錄后才能下訂單哦!
這篇文章主要介紹“OpenStack環境出現MySQL ‘Too many connections’ 怎么辦”,在日常操作中,相信很多人在OpenStack環境出現MySQL ‘Too many connections’ 怎么辦問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”OpenStack環境出現MySQL ‘Too many connections’ 怎么辦”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
之前在虛擬機環境搭建過幾次openstack環境,除了因為網絡策略導致除網絡節點能與實例連通之外,其他一切正常,所以我們申請了交換機和三臺物理機來搭建Openstack,避免現有網絡策略的影響。
經過分組件搭建完成后,在創建實例這一步,dashboard出現大量異常提示,經過查看nova日志,發現mysql報出 ‘Too many connections’
2017-02-22 11:30:10.764 24509 INFO nova.osapi_compute.wsgi.server [req-7d5b04d4-8b4a-4953-94f2-4b3d284e5301 c2dda1f21faa49ef9ff589b98f6b5fd3 166a0459c60f4953b5597974b5b2e3d7 - 5fafae76caaa43aaa2290f24ad147411 5fafae76caaa43aaa2290f24ad147411] 10.60.30.53 "GET /v2.1/166a0459c60f4953b5597974b5b2e3d7/os-services HTTP/1.1" status: 200 len: 1174 time: 0.0233388 ine 385, in connect 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions return self.dbapi.connect(*cargs, **cparams) 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/pymysql/__init__.py", line 90, in Connect 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions return Connection(*args, **kwargs) 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 694, in __init__ 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions self.connect() 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 916, in connect 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions self._request_authentication() 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 1124 , in _request_authentication 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions auth_packet = self._read_packet() 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 991, in _read_packet 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions packet.check_error() 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 393, in check_error 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions err.raise_mysql_exception(self._data) 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions File "/usr/lib/python2.7/site-packages/pymysql/err.py", line 107, in rais e_mysql_exception 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions raise errorclass(errno, errval) 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions OperationalError: (pymysql.err.OperationalError) (1040, u'Too many connecti ons') 2017-02-21 19:25:17.245 24542 ERROR nova.api.openstack.extensions
在mysql中查看當前連接,發現有大量來自controller節點的連接,由于當時急于將整套環境部署OK,就將mysql的連接數改大并重啟。
重啟后dashboard正常,創建實例正常。但查看mysql的連接,發現當前有1000多個連接,太不正常了。
后面經過一系列的分析,發現controller節點的nova-api進程有98個,neutron進程53,nova相關進程有151個。
通過查看,發現幾乎所有組件的進程都有很多,這也能解釋為啥mysql連接數那么高了。
通過查看nova.conf,發現nova進程和cpu核數有關,以前是4核的虛擬機上跑,現在是在48核的物理機上跑,所以出現了這個問題。
[DEFAULT] # Number of workers for metadata service. The default will be the number of CPUs # available. (integer value) #metadata_workers=<None> # Number of workers for OpenStack API service. The default will be the number of # CPUs available. (integer value) #osapi_compute_workers=<None> [conductor] # # Number of workers for OpenStack Conductor service. The default will be the # number of CPUs available. # (integer value) #workers=<None>
如果 show variables like "max_connections";還是沒有變化,則需要修改centos7的限制:
解決辦法:修改mariadb服務的配置,增加下面兩行后重啟服務配置就生效了。
[root@controller ~]# less /usr/lib/systemd/system/mariadb.service [Service] Type=simple User=mysql Group=mysql LimitNOFILE=65535 (增加在service標簽下) LimitNPROC=65535 (增加在service標簽下)
到此,關于“OpenStack環境出現MySQL ‘Too many connections’ 怎么辦”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。