리눅스서버

xinetd을 이용한 rsync데몬

비개인오후 2017. 5. 4. 01:30

데몬없이 하는 경우 ssh 계정하고 패스하고 입력해주면서 해야하는데

데몬으로 하면 그런거 없다. (iptables에서 포트제한하는 경우라면 873포트를 열어줘야 한다)

예) 서버 CentOS 6.8 / 서버ip - 123.456.789.012 의 Gallery 디렉토리(원본)를 내 서버(타켓)로 동기화 하려고 한다.


==== xinetd 설치

]# yum -y install xinetd


==== /etc/xinetd.d/rsync 파일편집

]# vi /etc/xinetd.d/rsync

disable = no 로 변경해주고 저장.


==== /etc/rsyncd.conf 를 맹글어준다.

]# vi /etc/rsyncd.conf

[daehans]

path = /home/daehan/Gallery

comment = myGallery

uid = nobody

gid = nobody

use chroot = yes

read only = yes

# hosts allow = all host

max connections = 10

timeout 600

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

[섹션이름]

path = 섹션의 경로


==== SELinux 사용시라면 퍼미션 오류나므로

참고 : http://webinformation.tistory.com/30 

]# getsebool -a | grep rsync

postgresql_can_rsync --> off

rsync_anon_write --> off

rsync_client --> off

rsync_export_all_ro --> off

rsync_full_access --> off


확인 후 rsync_export_all_ro 를 on 으로 변경

]# setsebool -P rsync_export_all_ro 1

-P 옵션은 서버를 재 시작해도 on 시키겠다는 의미.


==== xinetd 재시작 및 chkconfig 등록

]# service xinetd restart

]# chkconfig xinetd on


===== 123.456.789.012 서버의 설정끝.




===== 내서버에서 rsync로 실행하면 된다.

rsync -avr 원본서버도메인이나IP주소::섹션이름 내서버의경로

]# rsync -avr --delete 123.456.789.012::daehans /home/Gal_backup


원본 123.456.789.012 서버의 :daehans 섹션의 경로의 파일들을 가지고
(/home/daehan/Gallery 디렉토리 안의 모든 파일들을)
타켓인 내서버의 /home/Gal_backup 디렉토리와 동기화시킨다.


설정한지 꽤되어 기억으로 정리할려니 빼먹은거 있을지도...