숀패밀리

lsync 사용하기

· 14년 전 · 1731
요구환경 
 
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,983
14년 전 조회 1,789
14년 전 조회 2,298
14년 전 조회 1,909
14년 전 조회 1,743
14년 전 조회 4,245
14년 전 조회 3,238
14년 전 조회 2,827
14년 전 조회 2,771
14년 전 조회 1,520
14년 전 조회 2,295
14년 전 조회 1,525
14년 전 조회 1,567
14년 전 조회 1,593
14년 전 조회 2,031
14년 전 조회 2,053
14년 전 조회 2,694
14년 전 조회 1,832
14년 전 조회 2,078
14년 전 조회 2,268
14년 전 조회 2,246
14년 전 조회 1,625
14년 전 조회 2,795
14년 전 조회 1,977
14년 전 조회 2,244
14년 전 조회 2,044
14년 전 조회 2,387
14년 전 조회 2,502
14년 전 조회 1,909
14년 전 조회 2,129
14년 전 조회 2,384
14년 전 조회 2,496
14년 전 조회 1,854
14년 전 조회 2,012
14년 전 조회 2,702
14년 전 조회 3,811
14년 전 조회 3,052
14년 전 조회 3,128
14년 전 조회 2,566
14년 전 조회 2,348
14년 전 조회 2,249
14년 전 조회 2,005
14년 전 조회 1,504
14년 전 조회 2,422
14년 전 조회 5,537
14년 전 조회 2,413
14년 전 조회 2,170
14년 전 조회 1,669
14년 전 조회 1,895
14년 전 조회 1,732
14년 전 조회 1,589
14년 전 조회 1,683
14년 전 조회 1,662
14년 전 조회 1,623
14년 전 조회 2,470
14년 전 조회 1,811
14년 전 조회 1,692
14년 전 조회 1,600
14년 전 조회 1,662
14년 전 조회 1,983
14년 전 조회 1,890
14년 전 조회 2,503
14년 전 조회 2,101
14년 전 조회 4,579
14년 전 조회 1,811
14년 전 조회 2,357
14년 전 조회 2,075
14년 전 조회 3,810
14년 전 조회 3,447
14년 전 조회 1,610
14년 전 조회 2,676
14년 전 조회 1,653
14년 전 조회 3,468
14년 전 조회 2,999
14년 전 조회 1,611
14년 전 조회 6,709
14년 전 조회 1,973
14년 전 조회 2,511
14년 전 조회 2,306
14년 전 조회 2,131
14년 전 조회 2,209
14년 전 조회 2,218
14년 전 조회 2,089
14년 전 조회 2,399
14년 전 조회 2,791
14년 전 조회 1,826
14년 전 조회 2,208
14년 전 조회 3,227
14년 전 조회 3,103
14년 전 조회 2,064
14년 전 조회 2,548
14년 전 조회 5,036
14년 전 조회 1,767
14년 전 조회 3,756
14년 전 조회 2,483
14년 전 조회 2,956
14년 전 조회 2,156
14년 전 조회 1,920
14년 전 조회 1,939
14년 전 조회 2,082