简体   繁体   中英

Mongodb 2.6.11 won't start after changing dbpath (centos 7)

So I attached a disk with data on it to /mnt/snapshot

I've create a softlink like so: ln -s /mnt/snapshot/var/lib/mongo /var/lib/mongo

When I try now to run mongo as a service (service mongod start) this is the output I get:

2016-02-25T14:08:44.196+0000 ***** SERVER RESTARTED *****
2016-02-25T14:08:44.200+0000 [initandlisten] MongoDB starting : pid=10906 port=27017 dbpath=/var/lib/mongo 64-bit host=ip-10-0-0-149.localdomain
2016-02-25T14:08:44.200+0000 [initandlisten] db version v2.6.11
2016-02-25T14:08:44.200+0000 [initandlisten] git version: d00c1735675c457f75a12d530bee85421f0c5548
2016-02-25T14:08:44.200+0000 [initandlisten] build info: Linux build4.ny.cbi.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2016-02-25T14:08:44.200+0000 [initandlisten] allocator: tcmalloc
2016-02-25T14:08:44.200+0000 [initandlisten] options: { config: "/etc/mongod.conf", processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, security: { keyFile: "/srv/mongodb/keyfile" }, storage: { dbPath: "/var/lib/mongo" }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2016-02-25T14:08:44.200+0000 [initandlisten] exception in initAndListen std::exception: boost::filesystem::status: Permission denied: "/var/lib/mongo", terminating
2016-02-25T14:08:44.201+0000 [initandlisten] dbexit: 
2016-02-25T14:08:44.201+0000 [initandlisten] shutdown: going to close listening sockets...
2016-02-25T14:08:44.201+0000 [initandlisten] shutdown: going to flush diaglog...
2016-02-25T14:08:44.201+0000 [initandlisten] shutdown: going to close sockets...
2016-02-25T14:08:44.201+0000 [initandlisten] shutdown: waiting for fs preallocator...
2016-02-25T14:08:44.201+0000 [initandlisten] shutdown: lock for final commit...
2016-02-25T14:08:44.201+0000 [initandlisten] shutdown: final commit...
2016-02-25T14:08:44.201+0000 [initandlisten] shutdown: closing all files...
2016-02-25T14:08:44.201+0000 [initandlisten] closeAllFiles() finished
2016-02-25T14:08:44.201+0000 [initandlisten] dbexit: really exiting now

permissions:

[root@ip-10-0-0-149 lib]# ll /var/lib/mongo
lrwxrwxrwx. 1 mongod mongod 27 feb 25 13:54 /var/lib/mongo -> /mnt/snapshot/var/lib/mongo


[root@ip-10-0-0-149 mongo]# ll
total 37846140
drwxr-xr-x. 2 mongod mongod       4096 feb  9 16:16 admin
-rw-r-xr-x. 1 mongod mongod   67108864 feb  9 16:16 admin.0
-rw-r-xr-x. 1 mongod mongod   16777216 feb  9 16:16 admin.ns
drwxr-xr-x. 2 mongod mongod       4096 feb  9 16:28 cgs
-rw-r-xr-x. 1 mongod mongod   67108864 feb 24 16:58 cgs.0
-rw-r-xr-x. 1 mongod mongod  134217728 feb 23 12:22 cgs.1
-rw-r-xr-x. 1 mongod mongod 2146435072 feb  9 16:21 cgs.10
-rw-r-xr-x. 1 mongod mongod 2146435072 feb  9 16:21 cgs.11
-rw-r-xr-x. 1 mongod mongod 2146435072 feb  9 16:22 cgs.12
-rw-r-xr-x. 1 mongod mongod 2146435072 feb  9 16:23 cgs.13
-rw-r-xr-x. 1 mongod mongod 2146435072 feb  9 16:24 cgs.14
-rw-r-xr-x. 1 mongod mongod 2146435072 feb  9 16:24 cgs.15
-rw-r-xr-x. 1 mongod mongod 2146435072 feb  9 16:25 cgs.16
-rw-r-xr-x. 1 mongod mongod 2146435072 feb  9 16:26 cgs.17
-rw-r-xr-x. 1 mongod mongod 2146435072 feb  9 16:26 cgs.18
-rw-r-xr-x. 1 mongod mongod 2146435072 feb  9 16:27 cgs.19
-rw-r-xr-x. 1 mongod mongod  268435456 feb  9 16:55 cgs.2
-rw-r-xr-x. 1 mongod mongod 2146435072 feb 10 12:17 cgs.20
-rw-r-xr-x. 1 mongod mongod 2146435072 feb 23 12:22 cgs.21
-rw-r-xr-x. 1 mongod mongod  536870912 feb 24 16:58 cgs.3
-rw-r-xr-x. 1 mongod mongod 1073741824 feb 25 09:48 cgs.4
-rw-r-xr-x. 1 mongod mongod 2146435072 feb  9 16:18 cgs.5
-rw-r-xr-x. 1 mongod mongod 2146435072 feb  9 16:18 cgs.6
-rw-r-xr-x. 1 mongod mongod 2146435072 feb  9 16:18 cgs.7
-rw-r-xr-x. 1 mongod mongod 2146435072 feb 25 09:48 cgs.8
-rw-r-xr-x. 1 mongod mongod 2146435072 feb  9 16:20 cgs.9
-rw-r-xr-x. 1 mongod mongod   16777216 v 25 09:48 cgs.ns
drwxr-xr-x. 2 mongod mongod       4096 feb 25 10:00 journal
drwxr-xr-x. 2 mongod mongod       4096 feb  9 16:16 local
-rw-r-xr-x. 1 mongod mongod   67108864 feb 25 09:46 local.0
-rw-r-xr-x. 1 mongod mongod   16777216 feb 25 09:46 local.ns
-rwxr-xr-x. 1 mongod mongod          0 feb 25 10:00 mongod.lock
-rw-r-xr-x. 1 mongod mongod         69 dec 16 13:48 storage.bson

Any help will be much appreciated!

Okay so I found that the SElinux was the issue, for some reason it didn't let mongo read from the mounted drive.

all I had to do is:

setenforce 0

and boom, no more problem.

I hope this helps anyone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM