숀패밀리

lsync 사용하기

· 14년 전 · 1588
요구환경 
 
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,835
14년 전 조회 1,656
14년 전 조회 2,148
14년 전 조회 1,785
14년 전 조회 1,608
14년 전 조회 4,102
14년 전 조회 3,101
14년 전 조회 2,688
14년 전 조회 2,613
14년 전 조회 1,389
14년 전 조회 2,155
14년 전 조회 1,402
14년 전 조회 1,417
14년 전 조회 1,466
14년 전 조회 1,887
14년 전 조회 1,889
14년 전 조회 2,539
14년 전 조회 1,691
14년 전 조회 1,940
14년 전 조회 2,125
14년 전 조회 2,104
14년 전 조회 1,490
14년 전 조회 2,645
14년 전 조회 1,824
14년 전 조회 2,121
14년 전 조회 1,900
14년 전 조회 2,248
14년 전 조회 2,357
14년 전 조회 1,778
14년 전 조회 1,998
14년 전 조회 2,245
14년 전 조회 2,369
14년 전 조회 1,713
14년 전 조회 1,865
14년 전 조회 2,562
14년 전 조회 3,655
14년 전 조회 2,911
14년 전 조회 2,974
14년 전 조회 2,430
14년 전 조회 2,223
14년 전 조회 2,107
14년 전 조회 1,866
14년 전 조회 1,384
14년 전 조회 2,280
14년 전 조회 5,381
14년 전 조회 2,253
14년 전 조회 2,037
14년 전 조회 1,523
14년 전 조회 1,769
14년 전 조회 1,589
14년 전 조회 1,454
14년 전 조회 1,557
14년 전 조회 1,526
14년 전 조회 1,494
14년 전 조회 2,331
14년 전 조회 1,671
14년 전 조회 1,548
14년 전 조회 1,470
14년 전 조회 1,553
14년 전 조회 1,853
14년 전 조회 1,767
14년 전 조회 2,363
14년 전 조회 1,950
14년 전 조회 4,421
14년 전 조회 1,664
14년 전 조회 2,219
14년 전 조회 1,942
14년 전 조회 3,675
14년 전 조회 3,304
14년 전 조회 1,459
14년 전 조회 2,528
14년 전 조회 1,496
14년 전 조회 3,311
14년 전 조회 2,868
14년 전 조회 1,457
14년 전 조회 6,578
14년 전 조회 1,827
14년 전 조회 2,374
14년 전 조회 2,149
14년 전 조회 2,065
14년 전 조회 2,063
14년 전 조회 2,073
14년 전 조회 1,908
14년 전 조회 2,258
14년 전 조회 2,636
14년 전 조회 1,661
14년 전 조회 2,058
14년 전 조회 3,064
14년 전 조회 2,918
14년 전 조회 1,904
14년 전 조회 2,374
14년 전 조회 4,868
14년 전 조회 1,586
14년 전 조회 3,581
14년 전 조회 2,322
14년 전 조회 2,792
14년 전 조회 2,003
14년 전 조회 1,774
14년 전 조회 1,768
14년 전 조회 1,908