mongoBD学习(二)客户端的连接
admin
2023-04-12 05:42:27
0

mongo客户端由bin/mongo启动

0、帮助

root@adela-vm:/opt/mongodb_simple# ./bin/mongo --help
MongoDB shell version: 2.6.9
usage: ./bin/mongo [options] [db address] [file names (ending in .js)]

1、启动mongoDB 客户端进程

root@adela-vm:/opt/mongodb_simple# ./bin/mongo 127.0.0.1:12345/test
MongoDB shell version: 2.6.9
connecting to: 127.0.0.1:12345/test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        http://docs.mongodb.org/
Questions? Try the support group
        http://groups.google.com/group/mongodb-user
>

2、关闭mongoDB 客户端进程
方法1:
>db.shutdownServer()
> db.shutdownServer()
shutdown command only works with the admin database; try 'use admin'
必须要admin才能使用shutdown命令

> use admin
switched to db admin
> db.shutdownServer()
2015-03-27T11:33:49.502+0800 DBClientCursor::init call() failed
server should be down...
2015-03-27T11:33:49.506+0800 trying reconnect to 127.0.0.1:12345 (127.0.0.1) failed
2015-03-27T11:33:49.506+0800 warning: Failed to connect to 127.0.0.1:12345, reason: errno:111 Connection refused
2015-03-27T11:33:49.506+0800 reconnect 127.0.0.1:12345 (127.0.0.1) failed failed couldn't connect to server 127.0.0.1:12345 (127.0.0.1), connection attempt failed
>
方法2:kill -15 进程号或者kill (不加参数)进程号
除非在特殊情况下,避免使用kill -9 进程号

3、重新启动mongo
numactl --interleave=all bin/mongod -f conf/mongod.conf
The program 'numactl' is currently not installed. You can install it by typing:
apt-get install numactl

安装numactl
apt-get install numactl
root@adela-vm:/opt/mongodb_simple/log# apt-get install numactl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  numactl
0 upgraded, 1 newly installed, 0 to remove and 348 not upgraded.
Need to get 30.1 kB of archives.
After this operation, 135 kB of additional disk space will be used.
Get:1 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/universe numactl amd64 2.0.9~rc5-1ubuntu3 [30.1 kB]
Fetched 30.1 kB in 0s (62.3 kB/s)
Selecting previously unselected package numactl.
(Reading database ... 170689 files and directories currently installed.)
Preparing to unpack .../numactl_2.0.9~rc5-1ubuntu3_amd64.deb ...
Unpacking numactl (2.0.9~rc5-1ubuntu3) ...
Processing triggers for man-db (2.6.7.1-1) ...
Setting up numactl (2.0.9~rc5-1ubuntu3) ...

重启服务端
root@adela-vm:/opt/mongodb_simple# numactl --interleave=all bin/mongod -f conf/mongod.conf
about to fork child process, waiting until server is ready for connections.
forked process: 4223
child process started successfully, parent exiting

4、查看日志
tail mongod.log
2015-03-27T11:42:38.343+0800 [initandlisten] waiting for connections on port 12345


5、启动客户端

root@adela-vm:/opt/mongodb_simple# ./bin/mongo 127.0.0.1:12345/test
MongoDB shell version: 2.6.9
connecting to: 127.0.0.1:12345/test
>

相关内容

热门资讯

热搜爆了!腾讯张军: 不会开发... 5月11日晚,“微信状态 访客记录”爆上热搜第一。 今天(5月12日),微信员工@客村小蒋发文回应:...
“人工胚胎”,首次进入太空! 来源:市场资讯 (来源:环球网资讯) 来源:央视新闻微信公众号 11日,我国天舟十号成功发射。“人工...
巨婴孙杨,屡教不改 内娱,终于等来了自己的综艺鬼才。体育冠军孙杨,人送外号“高需求宝宝”;艺术体操运动员张豆豆,被网友戏...
微纳米七级分散乳化机选型指南:... 导语:在医药制剂、化工新材料、食品加工等行业中,微纳米级分散乳化机的性能直接影响产品稳定性与生产效率...
全国率先!湖北人形机器人开始登... 当前,我国人形机器人产业爆发,各品牌机器人层出不穷。然而,不同品牌机器人由于技术路径不同,采用的零部...
国标出台,人工智能终端分级工作... 人工智能终端是人工智能技术规模化落地、体系化发展的关键载体。近年来,我国人工智能产业蓬勃发展,人工智...
OPPO「母亲节」交学费,另一... 「核心提示」 母亲节文案翻车背后:OPPO的营销,为何总在“雷区”蹦迪? 作者 | 李白 编...
今天,这场内阁会议或将决定斯塔... 英国工党日前在地方选举中大败,首相斯塔默地位岌岌可危,党内逼宫浪潮高涨。斯塔默将于5月12日召开一场...
定做衣柜要多少钱索菲亚定做衣柜... 回答1: 定做衣柜都是按平米计算的 索菲亚衣柜在全国有连锁店,价格也是统一的,一般一线城市跟...