Linux服务器中的Mongodb [英] Mongodb in linux server
问题描述
使用SSH,我通过以下步骤在Linux服务器中安装了Mongodb.
Using SSH I installed Mongodb in linux server by the following steps.
-
下载最新的Mongodb版本并将其解压缩到serer中的
/bin
文件夹
编辑.bash_profile
并添加
PATH = $ PATH:$ HOME/bin/mongodb-linux-x86_64-2.6.0/bin
PATH=$PATH:$HOME/bin/mongodb-linux-x86_64-2.6.0/bin
export PATH
使用mkdir -p /data/db
运行mongo命令后,它显示如下错误:
After running mongo command, it shows the error like this :
MongoDB shell version: 2.6.0
connecting to: test
2014-04-24T10:07:58.831+0530 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2014-04-24T10:07:58.832+0530 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
如何解决?
推荐答案
首先,确保您的dbpath存在.
First of all, make sure your dbpath exists.
mkdir -p ~/data/db
然后从以下位置开始mongod:
Then start mongod with:
mongod --dbpath ~/data/db
最后:
mongo
编辑:我看到有人对此答案投了赞成票.为了明确起见,此解决方案是您使用命令行启动mongod的.大多数情况下,如果您从源代码安装MongoDB软件包,则可以使用以下命令启动守护进程:
EDIT: I saw some people vote this answer up. To make it clear, this solution is for you to start mongod with command line. Most of the time if you installed MongoDB package from source, you can just start the daemon with:
sudo systemctl start mongodb # Arch linux
sudo service mongod start # CentOS/Redhat
配置文件位于:
vim /etc/mongod.conf
如果您希望守护程序从启动中自动启动,
And if you want daemon to be auto started from boot,
sudo systemctl enable mongodb # Arch Linux
sudo chkconfig mongod on # CentOS/Redhat
这篇关于Linux服务器中的Mongodb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!