【问题标题】:no permission to write on mongodb data rsync没有权限写入 mongodb 数据 rsync
【发布时间】:2017-09-28 00:43:28
【问题描述】:

运行这个命令:

oc rsync local/path/to/mongodump <mongodb_pod_name>:/var/lib/mongodb/data

得到这个输出:

sent 31,825,902 bytes  received 273 bytes  1,720,333.78 bytes/sec
total size is 31,817,949  speedup is 1.00
rsync: failed to set permissions on "/var/lib/mongodb/data/." (in root): 
Operation not permitted (1)
rsync: failed to modify permissions on "/var/lib/mongodb/data/." (in root): 
Operation not permitted (1)
rsync error: some files/attrs were not transferred (see previous errors) 
(code 23) at main.c(1165) [sender=3.1.1]
error: exit status 23

当我尝试跑步时

$ oc rsh <mongodb_pod> $ cd /var/lib/mongodb/data/mongodump

我的权限被拒绝

【问题讨论】:

    标签: mongodb openshift


    【解决方案1】:

    试试:

    oc rsync --no-perms
    

    请参阅有关将文件传入和传出容器的示例教程:

    它提到在某些情况下需要该选项。

    由于它是一个转储文件,我假设您将加载到 mongodb,最好将其复制到/tmp,然后从那里加载 mongodb。然后你不需要在完成后删除它,因为重新启动容器会看到 /tmp 中的文件被丢弃。

    【讨论】:

    • 感谢您的帮助。我尝试了您的解决方案,但没有成功。出现错误:Forwarding from 127.0.0.1:49420 -&gt; 48223 Forwarding from [::1]:49420 -&gt; 48223 Handling connection for 49420 sending incremental file list rsync: change_dir#1 "/var/lib/mongodb/data/temp" (in root) failed: Permission denied (13) rsync error: errors selecting input/output files, dirs (code 3) at main.c(544) [Receiver=3.0.9] rsync: connection unexpectedly closed (194 bytes received so far) [sender] rsync error: error in rsync protocol data stream (code 12) at io.c(235) [sender=3.1.1] error: exit status 12
    • 你是如何部署mongodb的?您是否在 Docker Hub 上使用所谓的官方 mongodb 映像。 Docker Hub 上的映像通常无法正常工作,因为他们希望您以 root 的身份运行容器。当您选择 Add to Project 时,您应该使用 OpenShift Web 控制台目录中的 mongodb-persistent 模板。
    • 我选择了 mongo-persistent 选项,是否需要更改模板上的某些内容?
    • 您是否尝试过将其复制到/tmp 而不是/var/lib/mongodb/data 下的建议?你能从/tmp恢复它吗?
    • 对不起,我尝试了 /tmp 和 --no-perms 但它仍然不起作用。我将 bolao 目录发送到 /tmp 并且它可以工作,但是当我尝试访问 .tar.gz 文件时它不起作用。我也厌倦了将提取文件夹直接复制到 /temp 并且当我尝试恢复 bolao 文件夹时权限被拒绝并且 mongorestore 失败
    猜你喜欢
    • 2014-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-04
    • 1970-01-01
    • 1970-01-01
    • 2013-04-21
    • 2015-05-23
    相关资源
    最近更新 更多