簡介
本檔案介紹如何在CloudCenter Orchestrator(CCO)上疑難排解「MongoDB無法啟動」錯誤。
必要條件
需求
思科建議您瞭解以下主題:
採用元件
本檔案中的資訊基於CloudCenter 4.7.x/4.8.x版。
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路正在作用,請確保您已瞭解任何指令可能造成的影響。
問題:遇到錯誤「MongoDB無法啟動」
為CCO配置MongoDB後,當它無法與MongoDB正確連線時,它可能會失敗。出現此問題的原因有多種。然而,上述場景是CCO上沒有足夠的硬碟空間用於啟動MongoDB。
要解決此問題,建議檢視日誌檔案並檢查錯誤的實際原因。
從CCO滲透壓日誌中可以發現此錯誤。
INFO policy.GatewayPolicyServiceImpl Inject Context id org.springframework.web.context.WebApplicationContext: ,name Root WebApplicationContext
2017-05-22 06:58:17,077 ERROR context.ContextLoader [localhost-startStop-1] - Context initialization failed
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector
. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception=
{com.mongodb.MongoSocketOpenException: Exception opening socket}
嘗試啟動MongoDB服務後,將引發此錯誤。
service mongod start
錯誤是
Job for mongod.service failed. See "systemctl status mongod.service" and "journalctl -xe" for details.
現在,當您運行:
sudo systemctl status mongod.service
您可能會收到以下錯誤:
[root@localhost ~]# systemctl status mongod.service
● mongod.service - SYSV: Mongo is a scalable, document-oriented database.
Loaded: loaded (/etc/rc.d/init.d/mongod; bad; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2017-06-23 06:07:56 UTC; 19h ago
Docs: man:systemd-sysv-generator(8)
Process: 2547 ExecStop=/etc/rc.d/init.d/mongod stop (code=exited, status=0/SUCCESS)
Process: 2588 ExecStart=/etc/rc.d/init.d/mongod start (code=exited, status=1/FAILURE)
Main PID: 2350 (code=exited, status=0/SUCCESS)
Jun 23 06:07:56 localhost.localdomain systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
Jun 23 06:07:56 localhost.localdomain runuser[2597]: pam_unix(runuser:session): session opened for user mongod by (uid=0)
Jun 23 06:07:56 localhost.localdomain mongod[2588]: Starting mongod: [FAILED]
Jun 23 06:07:56 localhost.localdomain systemd[1]: mongod.service: control process exited, code=exited status=1
Jun 23 06:07:56 localhost.localdomain systemd[1]: Failed to start SYSV: Mongo is a scalable, document-oriented database..
Jun 23 06:07:56 localhost.localdomain systemd[1]: Unit mongod.service entered failed state.
Jun 23 06:07:56 localhost.localdomain systemd[1]: mongod.service failed.
解決方案
嘗試啟動MongoDB服務並檢查MongoDB日誌,您可能會在日誌/var/log/mongodb/mongod.log中找到這些錯誤。
2017-06-23T06:07:56.763+0000 [initandlisten] recover : no journal files present, no recovery needed
2017-06-23T06:07:56.763+0000 [initandlisten]
2017-06-23T06:07:56.763+0000 [initandlisten] ERROR: Insufficient free space for journal files
2017-06-23T06:07:56.764+0000 [initandlisten] Please make at least 3379MB available in /var/lib/mongo/journal or use --smallfiles
2017-06-23T06:07:56.764+0000 [initandlisten]
2017-06-23T06:07:56.809+0000 [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
2017-06-23T06:07:56.809+0000 [initandlisten] dbexit:
2017-06-23T06:07:56.809+0000 [initandlisten] shutdown: going to close listening sockets...
Mongo需要3gb硬碟可用空間才能開始使用。在啟動例項之前必須確保硬碟有足夠的空間,並且MongoDB需要重新啟動系統?自動啟動。