如何啟動MongoDB的WEB介面

chenfeng發表於2016-07-01
修改/etc/mongodb.conf,新增如下行:
httpinterface=true

mongodb.conf內容如下:
bash-4.2$ cat /etc/mongodb.conf 
port=27017 #埠  
dbpath= /data/mongodb #資料檔案存放目錄  
logpath= /data/mongodb/logs/mongodb.log #日誌檔案存放目錄  
logappend=true #使用追加的方式寫日誌  
fork=true #以守護程式的方式啟用,即在後臺執行  
maxConns=500 #最大同時連線數  
noauth=true #不啟用驗證  
journal=true
storageEngine=wiredTiger
httpinterface=true     #啟動http介面,埠號為28017

手動用命令啟動mongodb:
bash-4.2$ mongod --config /etc/mongodb.conf --rest  
about to fork child process, waiting until server is ready for connections.
forked process: 4203
child process started successfully, parent exiting
..............................................................................
(註釋: --rest代表turn on simple rest api)

檢視啟動日誌:
bash-4.2$ tail -f /data/mongodb/logs/mongodb.log 
2016-07-01T17:29:13.766+0800 I CONTROL  [initandlisten] 
2016-07-01T17:29:13.996+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/mongodb/diagnostic.data'
2016-07-01T17:29:13.999+0800 I NETWORK  [websvr] admin web console waiting for connections on port 28017
2016-07-01T17:29:13.999+0800 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-07-01T17:29:14.023+0800 I NETWORK  [initandlisten] waiting for connections on port 27017
2016-07-01T17:29:16.631+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:50609 #1 (1 connection now open)
2016-07-01T17:29:34.679+0800 I NETWORK  [websvr] Socket recv() errno:11 Resource temporarily unavailable 192.168.23.1:61067
2016-07-01T17:29:52.455+0800 I NETWORK  [websvr] Socket recv() errno:11 Resource temporarily unavailable 192.168.23.1:61076
2016-07-01T17:30:00.455+0800 I NETWORK  [websvr] Socket recv() errno:11 Resource temporarily unavailable 192.168.23.1:61077
2016-07-01T17:30:33.228+0800 I NETWORK  [conn1] end connection 127.0.0.1:50609 (0 connections now open)

 waiting for connections on port 27017字樣代表MongoDB已成功啟動。


檢視本地IP地址:
bash-4.2$ ifconfig -a
eno16777736: flags=4163  mtu 1500
        inet 192.168.23.131  netmask 255.255.255.0  broadcast 192.168.23.255
        inet6 fe80::20c:29ff:feb2:3e46  prefixlen 64  scopeid 0x20
        ether 00:0c:29:b2:3e:46  txqueuelen 1000  (Ethernet)
        RX packets 2273  bytes 2027304 (1.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1398  bytes 159433 (155.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


開啟本地瀏覽器,輸入以下地址:
http://192.168.23.131:28017/



透過web頁面可以看到:
1.當前Mongodb的所有連線
2.各個資料庫和Collection的訪問統計,包括:Reads, Writes, Queries, GetMores ,Inserts, Updates, Removes
3.寫鎖的狀態
4.以及日誌檔案的最後幾百行(安裝的mongodb預設的日誌檔案位於/data/mongodb/logs/mongod.log)
5.所有的MongoDB命令


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2121343/,如需轉載,請註明出處,否則將追究法律責任。

相關文章