我正在尝试更改默认的data
和logs
目录,作为新的MongoDB安装的一部分。首先,这就是我安装MongoDB的方式:
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
$ echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
$ sudo apt-get update
$ sudo apt-get install -y mongodb-org
$ echo "mongodb-org hold" | sudo dpkg --set-selections
$ echo "mongodb-org-server hold" | sudo dpkg --set-selections
$ echo "mongodb-org-shell hold" | sudo dpkg --set-selections
$ echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
$ echo "mongodb-org-tools hold" | sudo dpkg --set-selections
$ sudo service mongod start
$ tail /var/log/mongodb/mongod.log
然后,我尝试了一下MongoDB:
$ mongo
> use mydb;
> use mydb2;
> db;
> db.employeedetails.insert({"first" : "XYZ1" , "last" : "XYZ2"});
> db.employeedetails.find();
最后我尝试更改两个相应的路径,但是MongoDB严重失败:(
$ sudo service mongod stop
$ mkdir -p $XZY_PATH/mongodb
$ sudo nano /etc/mongod.conf
# update this:
dbPath: $XZY_PATH/mongodb
# as well as this:
path: $XZY_PATH/mongod.log
$ sudo service mongod start
修改
$ sudo service mongod start
返回mongod start/running, process 10777
,但我知道$ mongo
,我得到:
MongoDB shell version: 3.0.7
connecting to: test
2015-11-24T15:38:28.775+0200 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-11-24T15:38:28.778+0200 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed
我有什么遗漏的吗?