lsync 사용하기

· 14년 전 · 614
요구환경 
 
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,050
14년 전 조회 846
14년 전 조회 1,351
14년 전 조회 972
14년 전 조회 820
14년 전 조회 3,376
14년 전 조회 2,376
14년 전 조회 1,966
14년 전 조회 1,890
14년 전 조회 657
14년 전 조회 1,417
14년 전 조회 670
14년 전 조회 580
14년 전 조회 607
14년 전 조회 1,018
14년 전 조회 1,054
14년 전 조회 1,639
14년 전 조회 804
14년 전 조회 1,013
14년 전 조회 1,179
14년 전 조회 1,175
14년 전 조회 531
14년 전 조회 1,711
14년 전 조회 886
14년 전 조회 1,186
14년 전 조회 964
14년 전 조회 1,288
14년 전 조회 1,404
14년 전 조회 824
14년 전 조회 1,048
14년 전 조회 1,328
14년 전 조회 1,400
14년 전 조회 775
14년 전 조회 921
14년 전 조회 1,635
14년 전 조회 2,735
14년 전 조회 1,991
14년 전 조회 2,050
14년 전 조회 1,453
14년 전 조회 1,262
14년 전 조회 1,163
14년 전 조회 941
14년 전 조회 413
14년 전 조회 1,324
14년 전 조회 4,430
14년 전 조회 1,299
14년 전 조회 1,064
14년 전 조회 562
14년 전 조회 787
14년 전 조회 615
14년 전 조회 499
14년 전 조회 577
14년 전 조회 561
14년 전 조회 499
14년 전 조회 1,373
14년 전 조회 695
14년 전 조회 550
14년 전 조회 524
14년 전 조회 582
14년 전 조회 876
14년 전 조회 784
14년 전 조회 1,370
14년 전 조회 987
14년 전 조회 3,449
14년 전 조회 666
14년 전 조회 1,220
14년 전 조회 955
14년 전 조회 2,690
14년 전 조회 2,304
14년 전 조회 510
14년 전 조회 1,571
14년 전 조회 517
14년 전 조회 2,316
14년 전 조회 1,861
14년 전 조회 475
14년 전 조회 5,558
14년 전 조회 829
14년 전 조회 1,334
14년 전 조회 1,153
14년 전 조회 1,199
14년 전 조회 1,073
14년 전 조회 1,079
14년 전 조회 909
14년 전 조회 1,257
14년 전 조회 1,648
14년 전 조회 672
14년 전 조회 1,045
14년 전 조회 2,086
14년 전 조회 1,935
14년 전 조회 887
14년 전 조회 1,383
14년 전 조회 3,874
14년 전 조회 608
14년 전 조회 2,596
14년 전 조회 1,371
14년 전 조회 1,802
14년 전 조회 1,019
14년 전 조회 792
14년 전 조회 789
14년 전 조회 929
🐛 버그신고