숀패밀리

lsync 사용하기

· 14년 전 · 1303
요구환경 
 
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,599
14년 전 조회 1,418
14년 전 조회 1,909
14년 전 조회 1,536
14년 전 조회 1,375
14년 전 조회 3,877
14년 전 조회 2,874
14년 전 조회 2,473
14년 전 조회 2,387
14년 전 조회 1,177
14년 전 조회 1,947
14년 전 조회 1,166
14년 전 조회 1,168
14년 전 조회 1,224
14년 전 조회 1,636
14년 전 조회 1,667
14년 전 조회 2,299
14년 전 조회 1,462
14년 전 조회 1,691
14년 전 조회 1,856
14년 전 조회 1,844
14년 전 조회 1,234
14년 전 조회 2,408
14년 전 조회 1,573
14년 전 조회 1,882
14년 전 조회 1,641
14년 전 조회 1,975
14년 전 조회 2,083
14년 전 조회 1,502
14년 전 조회 1,748
14년 전 조회 1,990
14년 전 조회 2,102
14년 전 조회 1,450
14년 전 조회 1,626
14년 전 조회 2,286
14년 전 조회 3,425
14년 전 조회 2,657
14년 전 조회 2,720
14년 전 조회 2,158
14년 전 조회 1,935
14년 전 조회 1,851
14년 전 조회 1,616
14년 전 조회 1,087
14년 전 조회 2,033
14년 전 조회 5,104
14년 전 조회 2,014
14년 전 조회 1,796
14년 전 조회 1,283
14년 전 조회 1,511
14년 전 조회 1,304
14년 전 조회 1,197
14년 전 조회 1,268
14년 전 조회 1,283
14년 전 조회 1,243
14년 전 조회 2,084
14년 전 조회 1,411
14년 전 조회 1,273
14년 전 조회 1,198
14년 전 조회 1,257
14년 전 조회 1,591
14년 전 조회 1,489
14년 전 조회 2,110
14년 전 조회 1,704
14년 전 조회 4,160
14년 전 조회 1,375
14년 전 조회 1,974
14년 전 조회 1,678
14년 전 조회 3,452
14년 전 조회 3,058
14년 전 조회 1,223
14년 전 조회 2,237
14년 전 조회 1,260
14년 전 조회 3,019
14년 전 조회 2,609
14년 전 조회 1,172
14년 전 조회 6,328
14년 전 조회 1,557
14년 전 조회 2,107
14년 전 조회 1,895
14년 전 조회 1,783
14년 전 조회 1,788
14년 전 조회 1,793
14년 전 조회 1,601
14년 전 조회 1,977
14년 전 조회 2,387
14년 전 조회 1,417
14년 전 조회 1,803
14년 전 조회 2,779
14년 전 조회 2,631
14년 전 조회 1,617
14년 전 조회 2,091
14년 전 조회 4,598
14년 전 조회 1,334
14년 전 조회 3,308
14년 전 조회 2,084
14년 전 조회 2,525
14년 전 조회 1,736
14년 전 조회 1,502
14년 전 조회 1,494
14년 전 조회 1,626