숀패밀리

lsync 사용하기

· 14년 전 · 1377
요구환경 
 
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,644
14년 전 조회 1,487
14년 전 조회 1,972
14년 전 조회 1,593
14년 전 조회 1,441
14년 전 조회 3,933
14년 전 조회 2,933
14년 전 조회 2,523
14년 전 조회 2,451
14년 전 조회 1,221
14년 전 조회 1,985
14년 전 조회 1,225
14년 전 조회 1,247
14년 전 조회 1,289
14년 전 조회 1,722
14년 전 조회 1,732
14년 전 조회 2,365
14년 전 조회 1,535
14년 전 조회 1,754
14년 전 조회 1,929
14년 전 조회 1,925
14년 전 조회 1,297
14년 전 조회 2,474
14년 전 조회 1,654
14년 전 조회 1,945
14년 전 조회 1,715
14년 전 조회 2,060
14년 전 조회 2,161
14년 전 조회 1,592
14년 전 조회 1,822
14년 전 조회 2,074
14년 전 조회 2,179
14년 전 조회 1,529
14년 전 조회 1,710
14년 전 조회 2,366
14년 전 조회 3,484
14년 전 조회 2,708
14년 전 조회 2,791
14년 전 조회 2,229
14년 전 조회 2,018
14년 전 조회 1,912
14년 전 조회 1,695
14년 전 조회 1,160
14년 전 조회 2,117
14년 전 조회 5,189
14년 전 조회 2,092
14년 전 조회 1,868
14년 전 조회 1,350
14년 전 조회 1,586
14년 전 조회 1,378
14년 전 조회 1,275
14년 전 조회 1,349
14년 전 조회 1,353
14년 전 조회 1,320
14년 전 조회 2,171
14년 전 조회 1,484
14년 전 조회 1,343
14년 전 조회 1,283
14년 전 조회 1,328
14년 전 조회 1,661
14년 전 조회 1,566
14년 전 조회 2,170
14년 전 조회 1,783
14년 전 조회 4,232
14년 전 조회 1,451
14년 전 조회 2,043
14년 전 조회 1,769
14년 전 조회 3,512
14년 전 조회 3,114
14년 전 조회 1,319
14년 전 조회 2,321
14년 전 조회 1,331
14년 전 조회 3,100
14년 전 조회 2,675
14년 전 조회 1,253
14년 전 조회 6,389
14년 전 조회 1,666
14년 전 조회 2,173
14년 전 조회 1,962
14년 전 조회 1,899
14년 전 조회 1,881
14년 전 조회 1,882
14년 전 조회 1,694
14년 전 조회 2,065
14년 전 조회 2,463
14년 전 조회 1,490
14년 전 조회 1,889
14년 전 조회 2,859
14년 전 조회 2,714
14년 전 조회 1,705
14년 전 조회 2,173
14년 전 조회 4,671
14년 전 조회 1,421
14년 전 조회 3,378
14년 전 조회 2,143
14년 전 조회 2,601
14년 전 조회 1,813
14년 전 조회 1,570
14년 전 조회 1,586
14년 전 조회 1,702