Chinaunix首页 | 论坛 | 博客
  • 博客访问: 671137
  • 博文数量: 63
  • 博客积分: 1327
  • 博客等级: 中尉
  • 技术积分: 2022
  • 用 户 组: 普通用户
  • 注册时间: 2012-05-19 18:39
文章分类

全部博文(63)

文章存档

2013年(3)

2012年(60)

分类: 数据库开发技术

2012-05-30 21:53:13

停止数据库

MongoDB提供的停止数据库命令也非常丰富,如果Control-C、发送shutdownServer()指令及发送Unix系统中断信号等

如果处理连接状态,那么直接可以通过Control-C的方式去停止MongoDB实例,具体如下:

[root@localhost ~]#  /Apps/mongo/bin/mongo --port 28013

MongoDB shell version: 1.8.1

connecting to: 127.0.0.1:28013/test

> use test

switched to db test

> ^C[root@localhost ~]#

指令

如果处理连接状态,那么直接可以通过在admin库中发送db.shutdownServer()指令去停止MongoDB实例,具体如下:

[root@localhost ~]#  /Apps/mongo/bin/mongo --port 28013

MongoDB shell version: 1.8.1

connecting to: 127.0.0.1:28013/test

> use admin

switched to db admin

> db.shutdownServer()

Thu May 31 23:22:00 DBClientCursor::init call() failed

Thu May 31 23:22:00 query failed : admin.$cmd { shutdown: 1.0 } to: 127.0.0.1:28013

server should be down...

Thu May 31 23:22:00 trying reconnect to 127.0.0.1:28013

Thu May 31 23:22:00 reconnect 127.0.0.1:28013 failed couldn't connect to server 127.0.0.1:28013

Thu May 31 23:22:00 Error: error doing query: unknown shell/collection.js:150

> 

系统指令

在找到实例的进程后,可能通过发送kill -2 PIDkill -15 PID来停止进程

[root@localhost ~]# ps aux|grep mongod

root 19269  0.3  1.3  76008  3108 Sl   23:24   0:00 /Apps/mongo/bin/mongod --fork --port 28013

[root@localhost ~]# kill -2 19269

 

注意:

不要用kill -9 PID来杀死MongoDB进程,这样可以会导致MongoDB的数据损坏

 

阅读(3120) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~