Lsyncd 2.2.2 소유권 및 권한 문제

Lsyncd 2.2.2 소유권 및 권한 문제

대상 서버의 복제된 파일의 소유자/그룹이 항상 '1002'인 경우를 제외하고 파일이 원격 서버에 복사되는 문제가 있습니다. 소스의 권한이 존중되고 대상에 올바르게 복제됩니다. 복제된 파일의 소유자(및 그룹)를 보존하는 방법을 찾을 수 없습니다.

Lsyncd 버전: 2.2.2

내 설정은 다음과 같습니다.

settings {
    logfile = "/var/log/lsyncd/lsyncd.log",
    statusFile = "/var/log/lsyncd/lsyncd.status"
}

sync {
    default.rsyncssh,
    source="/home",
    host="1*52.*.15",
    targetdir="/home/",
    delete = "running", -- prevents deletion of files on startup (ie when a server comes back online, don't delete files that are new on the backup)
    delay = 5, -- run every 5 seconds instead of default 20
    exclude = {
        "/home/backup",
    },
    rsync = {
        archive = true, -- use the archive flag in rsync
        perms = true, -- Keep the permissions
        owner = true, -- Keep the owner
        compress = true,
        acls = true,
            xattrs = true,
        _extra = {"-a"}, -- Sometimes permissions and owners isn't copied correctly so the _extra can be used for any flag in rsync
    }
}

lsyncd 로그 오류:

Dec 15 21:42:47 server1.*.group lsyncd[21033]: sending incremental file list
Dec 15 21:42:47 server1.*.group lsyncd[21033]: rsync: failed to set times on "/home/admin/conf": Operation not permitted (1)
Dec 15 21:42:47 server1.*.group lsyncd[21033]: admin/conf/
Dec 15 21:42:47 server1.*.group lsyncd[21033]: sent 5,387 bytes  received 160 bytes  3,698.00 bytes/sec
Dec 15 21:42:47 server1.*.group lsyncd[21033]: total size is 2,849,404,839  speedup is 513,683.94
Dec 15 21:42:47 server1.*.group lsyncd[21033]: rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]

답변1

문제는 로컬 시스템에 있는 파일의 uid/gid가 대상 시스템의 uid/gid와 일치하지 않는다는 것입니다.

로컬 시스템의 사용자/그룹 ID를 확인하고 대상 시스템에 동일한 사용자/그룹을 생성합니다.

# On source system
$ ls -l /home/admin/conf
-rw-r--r--. 1 user1 user1 1.0K Jul 13  2018 /home/admin/conf

$ id user1
uid=1002(user1) gid=1002(user1) groups=1002(user1)

# On target system
$ useradd -u 1002 -g 1002 user1

답변2

RSYNC는 소유권을 보존한 상태로 파일을 전송할 때 사용자 이름/그룹 이름이 아닌 소유자의 UID 및 GID를 전송합니다.

따라서 1002에 대한 경험은 해당 UID가 대상 시스템에서 사용되지 않음을 의미합니다.

이 문제는 다음 두 가지 방법 중 하나로 해결할 수 있습니다.

  • 이전 사용자를 삭제하고 useradd의 UID 설정을 사용하여 다시 생성합니다. -- 아무것도 chown하거나 chmod할 필요가 없기 때문에 아마도 이 작업을 수행할 수 있는 가장 깔끔한 방법일 것입니다.
  • usermod를 사용하여 UID 및 GID를 업데이트합니다. -- 이렇게 하면 홈 디렉터리의 파일을 삭제해야 하며 해당 사용자가 소유한 다른 파일에 예상치 못한 부작용이 발생할 수 있습니다.

목록 항목

관련 정보