ERROR Topshelf.Hosts.ConsoleRunHost.Run 1 An exception occurred System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector
錯誤緣由是和轉義字符有關。鏈接字符串使用的URL格式,因此其中的密碼中的% 須要轉義。html
知識擴展:node
鏈接mongo使用URI有特殊字符 '@' 或者":"或者‘%’, 鏈接會報錯,須要進行轉義。mongodb
解決方法:數據庫
把 @ 換成 %40 app
把 : 換成 %3A性能
把 % 換成 %25測試
例如,明看到集合中指定時間段內有數據,可是Count結果仍是顯示爲0。優化
最先的一筆數據是20170816,可是使用如下語句查詢2017-08-14 到 2018-08-18時間段內的文檔數據爲0.ui
問題在哪兒哪? spa
查看發現query.time字段類型是 string.
咱們將查詢語句的條件格式轉換爲字段的存儲格式,就OK了。
因此,在設計集合模式時,要特別注意存儲日期時間的字段的類型,建議爲Date。另外,查詢時也要當心,防止數據異常。
錯誤信息:
{ "ok" : 0, "errmsg" : "Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: 172.XXX.XXX.XXX:27017; the following nodes did not respond affirmatively: 172.XXX.XXX.XX:27017 failed with No route to host", "code" : 74, "codeName" : "NodeNotFound" }
錯誤緣由是:防火牆沒關閉 致使
db.runCommand({"convertToCapped": "集合名字", size: XXXXXX,"max":XXXXX});
設置爲固定集合後,原來的索引都丟失了,須要謹記 。
(曾經的一個轉換性能測試,及轉爲固定集合的耗時:1001 W數據,16.8 G 約耗時 6分鐘)
MongoDB will not create an index on a collection if the index entry for an existing document exceeds the index key limit (1024 bytes). You can however create a hashed index or text index instead:
除了上面的介紹外,還能夠修改啓動配置參數 ailIndexKeyTooLong。
錯誤信息以下:
在config文件中,添加 shardsvr=true 便可。
重啓服務,再次啓動啓動分片,執行OK.
查看實例的運行log,報錯信息以下:
2019-06-16T04:54:54.830+0800 E STORAGE [thread2] WiredTiger error (28) [1560632094:830160][160893:0x7f2b30e80700], file:WiredTiger.wt, WT_SESSION.checkpoint: /data/mongodb/XXXXXXXXXXX/data/db/WiredTiger.turtle.set: handle-write: pwrite: failed to write 1015 bytes at offset 0: No space left on device 2019-06-16T04:54:54.830+0800 E STORAGE [thread2] WiredTiger error (28) [1560632094:830727][160893:0x7f2b30e80700], file:WiredTiger.wt, WT_SESSION.checkpoint: /data/mongodb/XXXXXXXXXXX/data/db/WiredTiger.turtle.set: handle-write: pwrite: failed to write 1015 bytes at offset 0: No space left on device 2019-06-16T04:54:54.830+0800 E STORAGE [thread2] WiredTiger error (0) [1560632094:830818][160893:0x7f2b30e80700], file:WiredTiger.wt, WT_SESSION.checkpoint: WiredTiger.turtle: encountered an illegal file format or internal value 2019-06-16T04:54:54.830+0800 E STORAGE [thread2] WiredTiger error (-31804) [1560632094:830848][160893:0x7f2b30e80700], file:WiredTiger.wt, WT_SESSION.checkpoint: the process must exit and restart: WT_PANIC: WiredTiger library panic 2019-06-16T04:54:54.830+0800 I - [thread2] Fatal Assertion 28558 at src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp 361 2019-06-16T04:54:54.830+0800 I - [thread2] ***aborting after fassert() failure 2019-06-16T04:54:54.875+0800 F - [thread2] Got signal: 6 (Aborted). 0x56500f890ee1 0x56500f88ffd9 0x56500f8904bd 0x7f2b378945e0 0x7f2b374f71f7 0x7f2b374f88e8 0x56500eb24d79 0x56500f59e366 0x56500eb2f329 0x56500eb2f545 0x56500eb2f79d 0x565010234400 0x565010232516 0x565010230e9f 0x5650102315df 0x56501027ee54 0x56501027fbd6 0x565010280f5b 0x565010281219 0x56501026e661 0x5650101e646d 0x7f2b3788ce25 0x7f2b375ba34d ----- BEGIN BACKTRACE ----- {"backtrace":[{"b":"56500E313000","o":"157DEE1","s":"_ZN5mongo15printStackTraceERSo"},{"b":"56500E313000","o":"157CFD9"},{"b":"56500E313000","o":"157D4BD"},{"b":"7F2B37885000","o":"F5E0"},{"b":"7F2B374C2000","o":"351F7","s":"gsignal"},{"b":"7F2B374C2000","o":"368E8","s":"abort"},{"b":"56500E313000","o":"811D79","s":"_ZN5mongo32fassertFailedNoTraceWithLocationEiPKcj"},{"b":"56500E313000","o":"128B366"},{"b":"56500E313000","o":"81C329"},{"b":"56500E313000","o":"81C545","s":"__wt_err"},{"b":"56500E313000","o":"81C79D","s":"__wt_panic"},{"b":"56500E313000"
看到這個錯,有些發怵;不過有些信息仍是頗有用的,No space left on device。提示咱們 是空間不足。
經過Zabbix 查看相應時間段內的可用空間(%)
確實在 04:54 左右可用空間耗盡。至此,問題已定位。
進一步考慮,爲何空間會短期耗盡呢? 分析發現,這個時間段咱們正在作完整備份,而且是先備份後壓縮的方式,佔用空間比較大。
優化方案調整爲:MongoDB 實現備份壓縮(http://www.javashuo.com/article/p-pkdctvvm-w.html)。
附註:
MongoDB是一種非關係型數據庫(NoSql),很好的實現了面向對象的思想(OO思想),在Mongo DB中 每一條記錄都是一個Document對象。Mongo DB最大的優點在於全部的數據持久操做都無需開發人員手動編寫SQL語句,直接調用方法就能夠輕鬆的實現CRUD操做。