sentos 7 ,systemctl start mongod 报错 ‘"attr":{"error":"IllegalOperation: Attempted to create a lock file on a read-only directory: /data/mongo"}’
解决路径:
1. 查看 /data/mongod 权限是否只读,所有组是否为mongod。
drwxrwxrwx. 2 mongod mongod 6 May 16 11:05 mongo(这是现在的权限,但是还是启动失败)
2. 检查文件系统挂载选项:确保/data
目录没有以只读模式挂载。使用mount
命令检查文件系统挂载情况,确保没有使用ro
(只读)选项挂载/data
目录。
3. 检查磁盘空间:确保/data
目录所在的文件系统具有足够的可用空间。使用df -h
命令检查磁盘使用情况。
4. 检查SELinux设置:如果你的系统启用了SELinux,它可能会限制MongoDB在指定目录上创建文件。你可以使用ls -Z
命令检查目录的SELinux上下文,然后使用chcon
命令为目录设置适当的上下文,以允许MongoDB创建文件。
sudo chcon -Rv --type=mongod_var_lib_t /data/mongo
最后再运行一次 systemctl start mongod