背景
之前,使用2.x版本的
MongoDB
时,选择了Robomongo
可视化管理工具,一切都是挺美好的,无论是在windows上还是Mac系统,用着都很方便。最近把MongoDB 版本升级到 v3.4.0,发现了一个问题:Robomongo无法查看MongoDB 3.x的Collections内容了, 原因何在呢?
查看 mongodb版本的方法:
在终端窗口,输入以下指令,即可得到当前使用的 mongodb 的版本号。
mongo -version
使用Robomongo连接数据库
首先,需要另起一个终端窗口,使用 mongod 指令启动 mongoDB。 正常情况下。以 mac 系统为例:
sudo mongod
2018-02-24T01:02:03.001+0800 I CONTROL [initandlisten] MongoDB starting : pid=1224 port=27017 dbpath=/data/db 64-bit host=leopardmac.local
2018-02-24T01:02:03.001+0800 I CONTROL [initandlisten] db version v3.4.0
2018-02-24T01:02:03.001+0800 I CONTROL [initandlisten] git version: f4240c60f005be757399042dc12f6addbc3170c1
2018-02-24T01:02:03.001+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2m 2 Nov 2017
2018-02-24T01:02:03.001+0800 I CONTROL [initandlisten] allocator: system
2018-02-24T01:02:03.001+0800 I CONTROL [initandlisten] modules: none
2018-02-24T01:02:03.001+0800 I CONTROL [initandlisten] build environment:
2018-02-24T01:02:03.001+0800 I CONTROL [initandlisten] distarch: x86_64
2018-02-24T01:02:03.001+0800 I CONTROL [initandlisten] target_arch: x86_64
2018-02-24T01:02:03.001+0800 I CONTROL [initandlisten] options: {}
2018-02-24T01:02:03.002+0800 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-02-24T01:02:03.002+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=7680M,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2018-02-24T01:02:03.798+0800 I CONTROL [initandlisten]
2018-02-24T01:02:03.798+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-02-24T01:02:03.798+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-02-24T01:02:03.798+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-02-24T01:02:03.798+0800 I CONTROL [initandlisten]
2018-02-24T01:02:03.798+0800 I CONTROL [initandlisten]
2018-02-24T01:02:03.798+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2018-02-24T01:02:03.850+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2018-02-24T01:02:03.851+0800 I NETWORK [thread1] waiting for connections on port 27017
启动 Robomongo连接后,发现无法查看Collections目录下面的内容或者是创建新的Collection也无法查看。
查询了才发现mongodb 3.x是运行在 wiredTiger 引擎,而Robomongo目前的版本只支持 MMAPv1 引擎,所以Robomongo
对mongodb 3.x并不支持。所以,我们只能换一个可视化工具了,网上推荐用MongoChef
下载地址是:http://3t.io/
安装完毕后,发现使用方法其实跟Robomongo也很相近,可以正常查看数据库的内容:
小结
从对mongodb的操作方式来看, Studio 3T 与 Robomongo 是类似的。
参考书: 《 全栈开发之道:MongoDB+Express+AngularJS+Node.js 》
更多全栈技术,请关注微信公众号: “全栈工程师的早读课”,每天早8:00 准时推送技术文章。