中易网

如何启动MongoDB的WEB界面

答案:2  悬赏:60  
解决时间 2021-01-18 07:54
  • 提问者网友:不要迷恋哥
  • 2021-01-18 01:17
如何启动MongoDB的WEB界面
最佳答案
  • 二级知识专家网友:躲不过心动
  • 2021-01-18 02:31
1:log一定要指定一个xxx.log文件(文件不存在也要这么写,会自动创建,写成这样是不可以的--logpath d:\mongodb\logs)
2:serviceName的N字母要大写

注意:这条命令要到MongoDB的bin目录下运行,刚开始的时候,我就直接在D:\下运行,结果服务的可执行目录为【"D:\mongod" --logpath "D:\MongoDB\logs\MongoDB.log" --logappend --dbpath "D:\MongoDB\data" --directoryperdb --service 】,肯定是不对的。

该命令行指定了日志文件:E:\APMServ5.2.6\MongoDb\logs\MongoDB.log,日志是以追加的方式输出的;
数据文件目录:E:\APMServ5.2.6\MongoDb\data,并且参数--directoryperdb说明每个DB都会新建一个目录;

Windows服务的名称:MongoDB;
以上的三个参数都是可以根据自己的情况而定的,呵呵。
最后是安装参数:--install,与之相对的是--remove

启动MongoDB:net start MongoDB
停止MongoDB:net stop MongoDB
删除MongoDB:sc delete MongoDB

运行→regedit→注册表编辑器→HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services 下面显示的就是所安装的服务项,删除相应的就好
mongod --logpath E:\APMServ5.2.6\MongoDb\logs\MongoDB.log --logappend --dbpath E:\APMServ5.2.6\MongoDb\data --directoryperdb --serviceName MongoDB --install
全部回答
  • 1楼网友:琴狂剑也妄
  • 2021-01-18 03:40
修改/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命令
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息