lsync 사용하기

· 14년 전 · 754
요구환경 
 
kernel 2.6.13 이상 버전
rsync package
libxml2 package
libxml2-devel package
lsync 사용법

lsyncd [OPTION]... [SOURCE] [TARGET 1] [TARGET 2] ...
[SOURCE] => 동기화시 원본이 존제하는 위치 /home/test/
[TARGET X] => 동기화가 필요한 서버 192.168.0.3::HOME/test
[OPTION]
--binary FILE rsync 실행 파일 위치
--conf FILE 실행시 로드할 설정 파일명 (DEFAULT: /etc/lsyncd.conf.xml)
--debug 디버그를 위한 로그
--exclude-from FILE 동기화시 제외시킬 패턴의 옵섭
--logfile FILE 로그 파일위치
--no-daemon 포그라운드로 실행 시킴
--pidfile FILE pid 파일 생성위치


설정방법

슬레이브 서버

rsyncd를 서비스에 추가시켜 rsync접속이 가능하도록 한다

/etc/rsyncd.conf -->

[HOME]
path = /home/test
uid = root
gid = root
use chroot = yes
read only = no                      # 마스터에서 배포시 쓰기가 가능해야 한다
max connections = 4
hosts allow = 192.168.0.1         # 마스터 서버에서만 접속이 가능하도록 설정


위와 같이 마스터서버에서만 rsync 데몬만 이용할수있도록 하며 마스터에서 파일을 슬레이브로 쓰는 형태이므로 쓰기원한을 주어야한다

세팅후 rsync 데몬을 시작한다 .


마스터 서버

데몬 직접 띄우기
# lsyncd /home/test/ 192.168.0.3::HOME/test

설정파일을 이용하여 실행시키기
/etc/lsyncd.conf.xml 파일을 생성하여

<lsyncd version="1">
  <settings>
    <logfile      filename="/var/log/lsyncd"/>
    <binary       filename="/usr/bin/rsync"/>
    <callopts>
      <option text="-az%r"/>
      <option text="--delete"/>
    </callopts>
  </settings>
  <directory>
    <source path="/home/test/"/>
    <target path="192.168.0.2::HOME/"/>
  </directory>
</lsyncd>

설정 파일을 작성하고

/etc/rc.d/init.d/lsyncd 파일을 생성하여

#!/bin/bash
# description: lsyncd auto start script

start() {
  pid=`pidof lsyncd`
  if [ $? -eq 0 ]; then
    echo "lsyncd (pid $pid) is running..."
    echo " "
  else
    echo "Starting lsyncd..."
    echo " "
    /usr/bin/lsyncd
  fi
}


stop() {
  echo "Stopping lsyncd..."
  echo " "

   /bin/kill -9 `/sbin/pidof lsyncd`
   until [ -z $(/sbin/pidof lsyncd) ]; do :; done
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    stop
    start
    ;;
  status)
    pid=`pidof lsyncd`
    if [ $? -eq 0 ]; then
      echo "lsyncd (pid $pid) is running..."
      echo " "
    else
      echo "lsyncd is not running"
      echo " "
    fi
  ;;
  *)
  echo "Usage: lsyncd {start|stop|restart|status}"
  exit 1
esac

exit $?


/etc/rc.d/init.d/lsyncd start를 하게 되면 실행된다
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
14년 전 조회 3,206
14년 전 조회 993
14년 전 조회 1,506
14년 전 조회 1,131
14년 전 조회 981
14년 전 조회 3,529
14년 전 조회 2,516
14년 전 조회 2,121
14년 전 조회 2,032
14년 전 조회 803
14년 전 조회 1,564
14년 전 조회 803
14년 전 조회 719
14년 전 조회 748
14년 전 조회 1,170
14년 전 조회 1,193
14년 전 조회 1,778
14년 전 조회 928
14년 전 조회 1,157
14년 전 조회 1,331
14년 전 조회 1,326
14년 전 조회 676
14년 전 조회 1,857
14년 전 조회 1,029
14년 전 조회 1,331
14년 전 조회 1,106
14년 전 조회 1,428
14년 전 조회 1,544
14년 전 조회 974
14년 전 조회 1,202
14년 전 조회 1,466
14년 전 조회 1,545
14년 전 조회 925
14년 전 조회 1,077
14년 전 조회 1,783
14년 전 조회 2,876
14년 전 조회 2,116
14년 전 조회 2,179
14년 전 조회 1,612
14년 전 조회 1,412
14년 전 조회 1,315
14년 전 조회 1,090
14년 전 조회 555
14년 전 조회 1,475
14년 전 조회 4,562
14년 전 조회 1,438
14년 전 조회 1,206
14년 전 조회 714
14년 전 조회 950
14년 전 조회 755
14년 전 조회 636
14년 전 조회 710
14년 전 조회 707
14년 전 조회 654
14년 전 조회 1,528
14년 전 조회 828
14년 전 조회 700
14년 전 조회 651
14년 전 조회 722
14년 전 조회 1,014
14년 전 조회 913
14년 전 조회 1,507
14년 전 조회 1,128
14년 전 조회 3,588
14년 전 조회 807
14년 전 조회 1,361
14년 전 조회 1,111
14년 전 조회 2,837
14년 전 조회 2,446
14년 전 조회 654
14년 전 조회 1,696
14년 전 조회 672
14년 전 조회 2,460
14년 전 조회 2,008
14년 전 조회 620
14년 전 조회 5,713
14년 전 조회 966
14년 전 조회 1,489
14년 전 조회 1,302
14년 전 조회 1,329
14년 전 조회 1,222
14년 전 조회 1,222
14년 전 조회 1,039
14년 전 조회 1,405
14년 전 조회 1,797
14년 전 조회 818
14년 전 조회 1,195
14년 전 조회 2,226
14년 전 조회 2,069
14년 전 조회 1,043
14년 전 조회 1,513
14년 전 조회 4,022
14년 전 조회 742
14년 전 조회 2,734
14년 전 조회 1,497
14년 전 조회 1,955
14년 전 조회 1,159
14년 전 조회 921
14년 전 조회 939
14년 전 조회 1,071