Mongodb MongDB无法在OpenShift v3.11上启动,因为即使可以从终端读取文件,也无法读取WiredTiger.wt
我在OpenShift v3.11上运行了一个MongoDBMongodb MongDB无法在OpenShift v3.11上启动,因为即使可以从终端读取文件,也无法读取WiredTiger.wt,mongodb,openshift,Mongodb,Openshift,我在OpenShift v3.11上运行了一个MongoDBStatefulSet。PersistentVolume正在使用NFSv4 在我们的环境中,我进行了设置,使NFS服务器中的目录归nfsnobody:nfsnobody所有SELinux也已设置为“允许”。所有内部目录和文件也被授予chmod ug+rwx,o-rwx 这样做是为了在运行时,当Pod使用具有组root(gid=0)的用户访问共享路径时,由于默认情况下NFS将用户和组root挤压到nfsnobody,Pod将能够读取和写入
StatefulSet
。PersistentVolume
正在使用NFSv4
在我们的环境中,我进行了设置,使NFS服务器中的目录归nfsnobody:nfsnobody
所有SELinux也已设置为“允许”。所有内部目录和文件也被授予chmod ug+rwx,o-rwx
这样做是为了在运行时,当Pod使用具有组root(gid=0)
的用户访问共享路径时,由于默认情况下NFS将用户和组root
挤压到nfsnobody
,Pod将能够读取和写入共享路径
$> ls -halZ /srv/share/openshift/mongo/
drwxrwx---. nfsnobody nfsnobody unconfined_u:object_r:default_t:s0 data
这个设置已经运行了几个月。但随后它开始失败
但是,当我部署Pod时,它无法启动,出现以下错误:
021-01-26T16:12:48.163+0000 W STORAGE [initandlisten] Detected unclean shutdown - /var/lib/mongodb/data/mongod.lock is not empty.
2021-01-26T16:12:48.163+0000 I STORAGE [initandlisten] Detected data files in /var/lib/mongodb/data created by the 'wiredTiger' storage engine, so setting theactive storage engine to 'wiredTiger'.
2021-01-26T16:12:48.163+0000 W STORAGE [initandlisten] Recovering data from the last clean checkpoint.
2021-01-26T16:12:48.164+0000 I STORAGE [initandlisten] wiredtiger_open config:create,cache_size=31220M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2021-01-26T16:12:48.688+0000 E STORAGE [initandlisten] WiredTiger error (1) [1611677568:688148][457:0x7f9b59cc1ca8], file:WiredTiger.wt, connection: __posix_open_file, 715: /var/lib/mongodb/data/WiredTiger.wt: handle-open: open: Operationnot permitted Raw: [1611677568:688148][457:0x7f9b59cc1ca8], file:WiredTiger.wt,connection: __posix_open_file, 715: /var/lib/mongodb/data/WiredTiger.wt: handle-open: open: Operation not permitted
2021-01-26T16:12:48.708+0000 E STORAGE [initandlisten] WiredTiger error (1) [1611677568:708810][457:0x7f9b59cc1ca8], file:WiredTiger.wt, connection: __posix_open_file, 715: /var/lib/mongodb/data/WiredTiger.wt: handle-open: open: Operationnot permitted Raw: [1611677568:708810][457:0x7f9b59cc1ca8], file:WiredTiger.wt,connection: __posix_open_file, 715: /var/lib/mongodb/data/WiredTiger.wt: handle-open: open: Operation not permitted
2021-01-26T16:12:48.728+0000 E STORAGE [initandlisten] WiredTiger error (1) [1611677568:728860][457:0x7f9b59cc1ca8], file:WiredTiger.wt, connection: __posix_open_file, 715: /var/lib/mongodb/data/WiredTiger.wt: handle-open: open: Operationnot permitted Raw: [1611677568:728860][457:0x7f9b59cc1ca8], file:WiredTiger.wt,connection: __posix_open_file, 715: /var/lib/mongodb/data/WiredTiger.wt: handle-open: open: Operation not permitted
2021-01-26T16:12:48.744+0000 W STORAGE [initandlisten] Failed to start up WiredTiger under any compatibility version.
2021-01-26T16:12:48.744+0000 F STORAGE [initandlisten] Reason: 1: Operation not permitted
2021-01-26T16:12:48.744+0000 F - [initandlisten] Fatal Assertion 28595 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 638
2021-01-26T16:12:48.744+0000 F - [initandlisten]
乍一看,有人可能会说“可能是mongod进程没有读取该文件的权限”。但是,当我在调试模式下运行以访问终端时,我可以完全访问路径/var/lib/mongo/data
$> id
id=1000230000 gid=0(root) groups=0(root),1000230000
$> cd /var/lib/mongodb/data
/var/lib/mongodb/data$> echo "This is a test" >new_file
/var/lib/mongodb/data$> rm new_file
/var/lib/mongodb/data$> cat WiredTiger.wt | wc -l
23
/var/lib/mongodb/data$> mongod --dbpath $(pwd)
....failed...
上面的命令显示,我可以读取/var/lib/mongod/data/WiredTiger.wt
来计算行数,但是mongod
进程不能
除非我这样做
# 1000230000 is the random UID and GID granted by OpenShift for the Pod.
$> chown -R 1000230000:nfsnobody /srv/share/openshift/mongo/
…Pod能够读取文件
我还需要检查什么来解决这个问题吗
更新:
- MongoDB版本是4.0.5
- 添加更多日志,以查明错误发生的位置。这个
mongod
尝试读取WiredTiger.wt
(或任何其他文件)时,它会尝试不更新文件的上次访问时间(inode中的st_time
)。这样做的原因是。在引擎盖下,它使用带标志的系统调用open()
根据:
只有在下列情况之一时,才能使用此标志
条件是正确的:
- 进程的有效UID与所有者UID匹配 文件的一部分
- 调用进程在中具有CAP_FOWNER功能 其用户命名空间和文件的所有者UID具有 命名空间中的映射
EPERM The O_NOATIME flag was specified, but the effective user
ID of the caller did not match the owner of the file and
the caller was not privileged.
在我的例子中,文件的所有者是nfsnobody
,而不是当前UID,因此出现了错误。这只能通过执行chown$UID:nfsnobody
来解释问题的原因
一些进一步的细节
错误源于它试图打开文件时。在,如果使用
WT\u FS\u open\u file\u TYPE\u DATA
调用\u posix\u open\u文件
,检查.lock文件的权限可能存在的问题重复:@Alex Blex themongo.lock
具有与WiredTiger.WT
相同的权限,则设置标志NO\ATIME>。即使我删除了mongo.lock
也不会改变结果,将再次创建mongo.lock
。@R2D2:我检查了另一个答案,但它没有提供可以解决我的问题的解决方案。公平地说,仔细查看后,“WiredTiger.wt”本身的错误来自这里。可能会有所帮助,尤其是使用补充组
。。。