rsync 하기 2

리눅스/Network|2015. 1. 27. 09:08
반응형

[원본 서버에서 / 192.168.10.2]

 

1) 설치
[root@sysdocu ~]# yum -y install rsync

 


2) 설정
[root@sysdocu ~]vi /etc/rsyncd.conf

 

rsyncd.conf 파일을 생성하여 아래 내용을 입력해줍니다.

log file = /var/log/rsyncd.log        <-- 로그 쌓이게 하려면 적어줍니다.
 
[mirror]
path = /
uid = root
gid = root
use chroot = yes
read only = yes                          <- 2차서버에서 읽어가기만 하려면 yes, 수정까지 가능하게 하려면 no
hosts allow = 192.168.10.3       <- 접속 허용할 IP (보안 효과)
max connections = 2
timeout = 1000

 

아래 파일을 수정하여 rsync 를 허용합니다.

[root@sysdocu ~]vi /etc/xinetd.d/rsync

 

disable = no

 

* CentOS 7 에서는 xinetd 없이 systemctl start rsyncd 하면 됩니다.

   (부팅시 자동 구동 : systemctl enable rsyncd)

* CentOS 8 에서는 데몬 형식으로 실행해주거나 별도로 패키지를 더 설치해야 합니다.

   # dnf install rsync

   # dnf install rsync-daemon

   # systemctl start rsyncd

   or

   # rsync --daemon --config=/etc/rsyncd.conf

 


3) 적용
xinetd 를 재시작하여 rsyncd 를 구동합니다.

[root@sysdocu ~]/etc/init.d/xinetd restart


※ iptables 사용중이라면 873 포트를 오픈시켜줍니다.

 

 

[2차 서버에서 / 192.168.10.3]

 

아래 명령어 처럼 사용하면 됩니다.
아래는 sysdocu 사용자의 public_html 폴더를 가져오는 형태입니다. (변경된, 생성된 파일만)

 

[root@sysdocu ~]rsync -avzPog --bwlimit=1024 --delete 192.168.10.2::mirror/home/sysdocu/public_html /home/sysdocu/

 

※ 옵션 설명
--delete : 원본 서버에 없는 파일은 2차 서버에서도 지울것

--bwlimit : 데이터 전송속도 KBps (1024 = 초당 1MB)

 

반응형

댓글()