开启mongodb 的web

开启mongodb 的web

2017年12月04日 11:50:59 yisun123456 阅读数:3245

 

MongoDB 3.6 removes the deprecated HTTP interface and REST API to MongoDB

 

老版本修改配置文件, 新版本 命令行启动

老版本:

修改/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命令

 

 

 

新版本

MongoDB 3.4版本小技巧之如何开启http service

原创 NoSQL 作者:chenfeng 时间:2018-02-06 16:45:52  1525  0

Mongodb3.0开始在配置文件里废弃了参数httpinterface=true,如果用该参数启动会报如下错误:

Unrecognized option: httpinterface=true
try './mongod --help' for more information

新的版本可以用如下方式启动http服务
# ./mongod -f /data/mongodb/mongod.conf --httpinterface 
about to fork child process, waiting until server is ready for connections.
forked process: 13741
child process started successfully, parent exiting



mongodb的http service端口为28017
# ss -lnt |grep 28017
LISTEN     0      128                       *:28017                    *:*   


查看web页面

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15498/viewspace-2150900/,如需转载,请注明出处,否则将追究法律责任。

posted @ 2019-05-19 10:10  grj001  阅读(401)  评论(0编辑  收藏  举报