티스토리 뷰

lsyncd(Live Syncing Daemon) 원리 : 리눅스 커널의 inotify로 파일시스템의 변경사항을 체크
inotify(Linux Kernel 2.6.13 이상)는 리눅스 커널에 포함된 기능으로, 파일시스템에 변경사항이 발생할 때 이벤트를 통보
변경사항은 rsync를 호출하여 상대 서버로 싱크

원본데이터 서버와 동기화 대상서버 간의 SSH rsa key 교환등의 과정은 필요하지 않음
lsyncd가 파일 변화를 모니터링할 수 있는 디렉토리 갯수는 최대 8192개


- 구조
원본 데이터 서버 : lsyncd 데몬 + rsync 클라이언트
동기화 대상 서버 : rsyncd 데몬


- 설정

::설치 
공통 : yum install -y epel-release
원본 데이터 서버 : yum install -y rsync
동기화 대상 서버 : yum install -y lsyncd

 

 

::원본데이터 서버 설정


/etc/lsyncd.conf
----------------------------------------------------------------------
# 로그 설정
settings {
        logfile = "/var/log/lsyncd/lsyncd.log",
        statusFile = "/var/log/lsyncd/lsyncd.status",
        insist = true,
        statusInterval = 10
}

# 동기화 할 디렉토리 및 옵션 지정
sync {
        default.rsync,
        # 동기화 디렉토리
        source = "/data/",
        # datasync 는 동기화 대상 서버 rsyncd의 설정 이름
        target = "<동기화 대상서버 IP>::datasync",
        # 동기화 대상에서 제외할 대상
exclude = { 'lost+found' },
rsync={
         # owner, group, perms 동기화
         archive=true,
                # 동기화 간 압축
compress = true,
         acls = true,
         verbose = true
}
}

# 또다른 동기화 디렉토리 및 옵션 지정
sync {
        default.rsync,
        source = "/home/",
        target = "<동기화 대상서버 IP>::home",
        exclude = { 'lost+found' },
        rsync={
                archive=true,
                compress = true,
                acls = true,
                verbose = true
        }
}
----------------------------------------------------------------------

 

 

::동기화 대상 서버 설정


/etc/rsyncd.conf
----------------------------------------------------------------------
[datasync]
# 동기화 dst 디렉토리
path = /data/
comment = data directory sync
uid = root
gid = root
use chroot = yes
read only = no
# 허용할 IP
hosts allow = <원본 데이터 서버 IP>
max connections = 10
timeout 600

[home]
path = /home/
comment = home directory sync
uid = root
gid = root
use chroot = yes
read only = no
hosts allow = <원본 데이터 서버 IP>
max connections = 10
timeout 600

----------------------------------------------------------------------

댓글