是mongodb运行吗? [英] Is mongodb running?
问题描述
我已经在我的unix服务器上安装了mongodb和php驱动程序。
我的问题是如何知道mongodb是否正在运行?有没有简单的命令行查询来检查状态?如果我从shell启动一次它将继续运行,如果我退出shell(这似乎不是这样)。如何使服务器重新启动时mongodb连接持久化并自动启动?
我可以运行:
-bash-3.2 $ su
密码:
[root @ xxx]#cd / var / lib
[root @ xxx ]#./mongodb-linux-i686-1.6.5/bin/mongod
./mongodb-linux-i686-1.6.5/bin/mongod --help以获取帮助和启动选项
Wed Feb 23 08:06:54 MongoDB starting:pid = 7271 port = 27017 dbpath = / data / db / 32-bit
当使用MongoDB 32位时,您限制为约2 GB数据
**请参阅 http://blog.mongodb.org/post/137788967/32-bit-limitations
**警告:您正在OpenVZ中运行。这已知是破碎!
Wed Feb 23 08:06:54 db version v1.6.5,pdfile版本4.5
Wed Feb 23 08:06:54 git version: 0eb017e9b2828155a67c5612183337b89e12e291
Wed Feb 23 08:06:54 sys信息:Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen#1 SMP Fri
Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION = 1_37
Wed Feb 23 08:06:54 [initandlisten]等待端口27017上的连接
Wed Feb 23 08: 06:54 [webvr] web管理界面侦听端口28017
如果我打开一个独立的shell,然后可以连接到mongodb:
-bash-3.2 $ cd / var / lib
-bash-3.2 $ ./mongodb-linux- i686-1.6.5 / bin / mongo
MongoDB shell版本:1.6.5
连接到:测试
db.foo.find()
{_id:ObjectId(4d63d7d3eb95985ab19c8feb),a:1}
最初的shell无法连接:
-bash-3.2 $ cd / var / lib
-bash -3.2 $ ./mongodb-linux-i686-1.6.5/bin/mongo
MongoDB shell版本:1.6.5
连接到:测试
Wed Feb 23 08:25:10错误:无法连接到服务器127.0.0.1(anon):1154
异常:连接失败
$ b $
ps -edaf | grep mongo | grep -v grep#ps标志在您的操作系统上可能不同
或
/etc/init.d/mongod status
b $ b
或
服务mongod status
查看mongod是否正在运行(您需要是root才能执行此操作,或者使用 sudo
p>
检查日志文件/var/log/mongo/mongo.log,看看是否有任何报告的问题
I have installed mongodb and the php drivers on my unix server.
My question is how can I tell if mongodb is running? Is there a simple command line query to check status? If I start it once from the shell will it keep running if I exit the shell (this doesn't seem to be the case). How can I make the mongodb connection persistent and auto start on server reboot?
I can run:
-bash-3.2$ su
Password:
[root@xxx]# cd /var/lib
[root@xxx]# ./mongodb-linux-i686-1.6.5/bin/mongod
./mongodb-linux-i686-1.6.5/bin/mongod --help for help and startup options
Wed Feb 23 08:06:54 MongoDB starting : pid=7271 port=27017 dbpath=/data/db/ 32-bit** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
** see http://blog.mongodb.org/post/137788967/32-bit-limitations** WARNING: You are running in OpenVZ. This is known to be broken!!!
Wed Feb 23 08:06:54 db version v1.6.5, pdfile version 4.5
Wed Feb 23 08:06:54 git version: 0eb017e9b2828155a67c5612183337b89e12e291
Wed Feb 23 08:06:54 sys info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri
Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_37
Wed Feb 23 08:06:54 [initandlisten] waiting for connections on port 27017
Wed Feb 23 08:06:54 [websvr] web admin interface listening on port 28017
If I open a seperate shell I can then then connect to mongodb:
-bash-3.2$ cd /var/lib
-bash-3.2$ ./mongodb-linux-i686-1.6.5/bin/mongo
MongoDB shell version: 1.6.5
connecting to: test
db.foo.find()
{ "_id" : ObjectId("4d63d7d3eb95985ab19c8feb"), "a" : 1 }
However if I close the initial shell I can't connect:
-bash-3.2$ cd /var/lib
-bash-3.2$ ./mongodb-linux-i686-1.6.5/bin/mongo
MongoDB shell version: 1.6.5
connecting to: test
Wed Feb 23 08:25:10 Error: couldn't connect to server 127.0.0.1 (anon):1154
exception: connect failed
check with either:
ps -edaf | grep mongo | grep -v grep # "ps" flags may differ on your OS
or
/etc/init.d/mongod status
or
service mongod status
to see if mongod is running (you need to be root to do this, or prefix everything with sudo
)
check the log file /var/log/mongo/mongo.log to see if there are any problems reported
这篇关于是mongodb运行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!