lsync 사용하기

· 14년 전 · 637
요구환경 
 
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,084
14년 전 조회 875
14년 전 조회 1,391
14년 전 조회 1,005
14년 전 조회 865
14년 전 조회 3,407
14년 전 조회 2,405
14년 전 조회 2,003
14년 전 조회 1,914
14년 전 조회 700
14년 전 조회 1,453
14년 전 조회 700
14년 전 조회 598
14년 전 조회 633
14년 전 조회 1,056
14년 전 조회 1,091
14년 전 조회 1,670
14년 전 조회 835
14년 전 조회 1,050
14년 전 조회 1,213
14년 전 조회 1,217
14년 전 조회 559
14년 전 조회 1,739
14년 전 조회 919
14년 전 조회 1,219
14년 전 조회 993
14년 전 조회 1,322
14년 전 조회 1,429
14년 전 조회 861
14년 전 조회 1,081
14년 전 조회 1,368
14년 전 조회 1,427
14년 전 조회 802
14년 전 조회 952
14년 전 조회 1,666
14년 전 조회 2,765
14년 전 조회 2,022
14년 전 조회 2,082
14년 전 조회 1,479
14년 전 조회 1,301
14년 전 조회 1,188
14년 전 조회 975
14년 전 조회 439
14년 전 조회 1,356
14년 전 조회 4,459
14년 전 조회 1,330
14년 전 조회 1,100
14년 전 조회 593
14년 전 조회 822
14년 전 조회 638
14년 전 조회 528
14년 전 조회 609
14년 전 조회 587
14년 전 조회 525
14년 전 조회 1,403
14년 전 조회 731
14년 전 조회 582
14년 전 조회 556
14년 전 조회 606
14년 전 조회 910
14년 전 조회 807
14년 전 조회 1,402
14년 전 조회 1,023
14년 전 조회 3,475
14년 전 조회 702
14년 전 조회 1,261
14년 전 조회 988
14년 전 조회 2,730
14년 전 조회 2,330
14년 전 조회 539
14년 전 조회 1,595
14년 전 조회 542
14년 전 조회 2,348
14년 전 조회 1,892
14년 전 조회 504
14년 전 조회 5,592
14년 전 조회 854
14년 전 조회 1,360
14년 전 조회 1,183
14년 전 조회 1,222
14년 전 조회 1,103
14년 전 조회 1,104
14년 전 조회 936
14년 전 조회 1,288
14년 전 조회 1,682
14년 전 조회 702
14년 전 조회 1,073
14년 전 조회 2,110
14년 전 조회 1,962
14년 전 조회 917
14년 전 조회 1,414
14년 전 조회 3,902
14년 전 조회 635
14년 전 조회 2,621
14년 전 조회 1,389
14년 전 조회 1,830
14년 전 조회 1,041
14년 전 조회 817
14년 전 조회 818
14년 전 조회 957
🐛 버그신고