숀패밀리

lsync 사용하기

· 14년 전 · 1280
요구환경 
 
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,581
14년 전 조회 1,404
14년 전 조회 1,891
14년 전 조회 1,516
14년 전 조회 1,360
14년 전 조회 3,863
14년 전 조회 2,857
14년 전 조회 2,459
14년 전 조회 2,375
14년 전 조회 1,163
14년 전 조회 1,932
14년 전 조회 1,144
14년 전 조회 1,146
14년 전 조회 1,197
14년 전 조회 1,612
14년 전 조회 1,645
14년 전 조회 2,273
14년 전 조회 1,434
14년 전 조회 1,670
14년 전 조회 1,833
14년 전 조회 1,817
14년 전 조회 1,213
14년 전 조회 2,374
14년 전 조회 1,531
14년 전 조회 1,862
14년 전 조회 1,615
14년 전 조회 1,948
14년 전 조회 2,059
14년 전 조회 1,480
14년 전 조회 1,721
14년 전 조회 1,965
14년 전 조회 2,070
14년 전 조회 1,412
14년 전 조회 1,603
14년 전 조회 2,262
14년 전 조회 3,402
14년 전 조회 2,635
14년 전 조회 2,691
14년 전 조회 2,127
14년 전 조회 1,911
14년 전 조회 1,828
14년 전 조회 1,586
14년 전 조회 1,063
14년 전 조회 2,009
14년 전 조회 5,080
14년 전 조회 1,987
14년 전 조회 1,759
14년 전 조회 1,257
14년 전 조회 1,484
14년 전 조회 1,281
14년 전 조회 1,174
14년 전 조회 1,239
14년 전 조회 1,254
14년 전 조회 1,205
14년 전 조회 2,055
14년 전 조회 1,381
14년 전 조회 1,236
14년 전 조회 1,173
14년 전 조회 1,233
14년 전 조회 1,561
14년 전 조회 1,453
14년 전 조회 2,096
14년 전 조회 1,673
14년 전 조회 4,129
14년 전 조회 1,348
14년 전 조회 1,944
14년 전 조회 1,642
14년 전 조회 3,428
14년 전 조회 3,042
14년 전 조회 1,203
14년 전 조회 2,209
14년 전 조회 1,234
14년 전 조회 2,990
14년 전 조회 2,595
14년 전 조회 1,143
14년 전 조회 6,309
14년 전 조회 1,527
14년 전 조회 2,098
14년 전 조회 1,864
14년 전 조회 1,766
14년 전 조회 1,756
14년 전 조회 1,765
14년 전 조회 1,564
14년 전 조회 1,953
14년 전 조회 2,348
14년 전 조회 1,386
14년 전 조회 1,770
14년 전 조회 2,753
14년 전 조회 2,607
14년 전 조회 1,573
14년 전 조회 2,065
14년 전 조회 4,574
14년 전 조회 1,302
14년 전 조회 3,265
14년 전 조회 2,070
14년 전 조회 2,500
14년 전 조회 1,701
14년 전 조회 1,470
14년 전 조회 1,465
14년 전 조회 1,590