更改dbpath后,Mongodb 2.6.11将无法启动(centos 7)

时间:2016-02-25 14:31:18

标签: linux mongodb centos7

所以我将带有数据的磁盘附加到/mnt/snapshot

我创建了一个类似的软链接:ln -s /mnt/snapshot/var/lib/mongo /var/lib/mongo

当我现在尝试将mongo作为服务运行时(服务mongod启动) 这是我得到的输出:

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

权限:

[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

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:1)

好的,所以我发现SElinux是问题所在,出于某种原因,它并没有让mongo从安装的驱动器中读取。

我所要做的就是:

setenforce 0
繁荣,没有问题。

我希望这对任何人都有帮助。