我试图在我的Ubuntu 16.04上将mongo的文件存储在USB驱动器上(/ media / bernardo / 87cf7663-0f73-4b56-9539-a00d4574d110 / corinda_experiments / mongodb /)。
在/etc/mongodb.conf中,我已经设置了
dbpath=/media/bernardo/87cf7663-0f73-4b56-9539-a00d4574d110/corinda_experiments/mongodb/
这是目录的权限如下:
bernardo@bernardo-UX51VZA:~$ ls -ld /media/bernardo/87cf7663-0f73-4b56-9539-a00d4574d110/corinda_experiments/mongodb/
drwxrwxr-x+ 3 mongodb bernardo 4096 Out 1 11:57 /media/bernardo/87cf7663-0f73-4b56-9539-a00d4574d110/corinda_experiments/mongodb/
当我尝试连接到mongo时,这就是我得到的:
bernardo@bernardo-UX51VZA:~$ sudo service mongodb restart
bernardo@bernardo-UX51VZA:~$ mongo
MongoDB shell version: 2.6.10
connecting to: test
2017-10-01T12:54:52.583-0300 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2017-10-01T12:54:52.583-0300 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
这是我的日志文件(/var/log/mongodb/mongodb.log)的结尾:
2017-10-01T12:56:53.474-0300 [initandlisten] allocator: tcmalloc
2017-10-01T12:56:53.474-0300 [initandlisten] options: { config: "/etc/mongodb.conf", net: { bindIp: "127.0.0.1" }, storage: { dbPath: "/media/bernardo/87cf7663-0f73-4b56-9539-a00d4574d110/corinda_experiments/mongodb/", journal: { enabled: true }}, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongodb.log" }}
2017-10-01T12:56:53.474-0300 [initandlisten] exception in initAndListen std::exception: boost::filesystem::status: Permission denied: "/media/bernardo/87cf7663-0f73-4b56-9539-a00d4574d110/corinda_experiments/mongodb/", terminating
2017-10-01T12:56:53.474-0300 [initandlisten] dbexit:
2017-10-01T12:56:53.474-0300 [initandlisten] shutdown: going to close listening sockets...
2017-10-01T12:56:53.474-0300 [initandlisten] shutdown: going to flush diaglog...
2017-10-01T12:56:53.474-0300 [initandlisten] shutdown: going to close sockets...
2017-10-01T12:56:53.475-0300 [initandlisten] shutdown: waiting for fs preallocator...
2017-10-01T12:56:53.475-0300 [initandlisten] shutdown: lock for final commit...
2017-10-01T12:56:53.475-0300 [initandlisten] shutdown: final commit...
2017-10-01T12:56:53.475-0300 [initandlisten] shutdown: closing all files...
2017-10-01T12:56:53.475-0300 [initandlisten] closeAllFiles() finished
2017-10-01T12:56:53.475-0300 [initandlisten] dbexit: really exiting now
所以这似乎是一个许可问题,但我真的不知道解决它的问题。 任何提示?