您好,登錄后才能下訂單哦!
這篇文章主要介紹“OpenStack環(huán)境出現(xiàn)MySQL ‘Too many connections’ 怎么辦”,在日常操作中,相信很多人在OpenStack環(huán)境出現(xiàn)MySQL ‘Too many connections’ 怎么辦問(wèn)題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”O(jiān)penStack環(huán)境出現(xiàn)MySQL ‘Too many connections’ 怎么辦”的疑惑有所幫助!接下來(lái),請(qǐng)跟著小編一起來(lái)學(xué)習(xí)吧!
之前在虛擬機(jī)環(huán)境搭建過(guò)幾次openstack環(huán)境,除了因?yàn)榫W(wǎng)絡(luò)策略導(dǎo)致除網(wǎng)絡(luò)節(jié)點(diǎn)能與實(shí)例連通之外,其他一切正常,所以我們申請(qǐng)了交換機(jī)和三臺(tái)物理機(jī)來(lái)搭建Openstack,避免現(xiàn)有網(wǎng)絡(luò)策略的影響。
經(jīng)過(guò)分組件搭建完成后,在創(chuàng)建實(shí)例這一步,dashboard出現(xiàn)大量異常提示,經(jīng)過(guò)查看nova日志,發(fā)現(xiàn)mysql報(bào)出 ‘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中查看當(dāng)前連接,發(fā)現(xiàn)有大量來(lái)自controller節(jié)點(diǎn)的連接,由于當(dāng)時(shí)急于將整套環(huán)境部署OK,就將mysql的連接數(shù)改大并重啟。
重啟后dashboard正常,創(chuàng)建實(shí)例正常。但查看mysql的連接,發(fā)現(xiàn)當(dāng)前有1000多個(gè)連接,太不正常了。
后面經(jīng)過(guò)一系列的分析,發(fā)現(xiàn)controller節(jié)點(diǎn)的nova-api進(jìn)程有98個(gè),neutron進(jìn)程53,nova相關(guān)進(jìn)程有151個(gè)。
通過(guò)查看,發(fā)現(xiàn)幾乎所有組件的進(jìn)程都有很多,這也能解釋為啥mysql連接數(shù)那么高了。
通過(guò)查看nova.conf,發(fā)現(xiàn)nova進(jìn)程和cpu核數(shù)有關(guān),以前是4核的虛擬機(jī)上跑,現(xiàn)在是在48核的物理機(jī)上跑,所以出現(xiàn)了這個(gè)問(wèn)題。
[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";還是沒(méi)有變化,則需要修改centos7的限制:
解決辦法:修改mariadb服務(wù)的配置,增加下面兩行后重啟服務(wù)配置就生效了。
[root@controller ~]# less /usr/lib/systemd/system/mariadb.service [Service] Type=simple User=mysql Group=mysql LimitNOFILE=65535 (增加在service標(biāo)簽下) LimitNPROC=65535 (增加在service標(biāo)簽下)
到此,關(guān)于“OpenStack環(huán)境出現(xiàn)MySQL ‘Too many connections’ 怎么辦”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。