숀패밀리

lsync 사용하기

· 14년 전 · 1665
요구환경 
 
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,920
14년 전 조회 1,737
14년 전 조회 2,231
14년 전 조회 1,853
14년 전 조회 1,674
14년 전 조회 4,192
14년 전 조회 3,176
14년 전 조회 2,763
14년 전 조회 2,702
14년 전 조회 1,465
14년 전 조회 2,235
14년 전 조회 1,468
14년 전 조회 1,506
14년 전 조회 1,544
14년 전 조회 1,980
14년 전 조회 1,983
14년 전 조회 2,619
14년 전 조회 1,773
14년 전 조회 2,017
14년 전 조회 2,204
14년 전 조회 2,195
14년 전 조회 1,567
14년 전 조회 2,726
14년 전 조회 1,919
14년 전 조회 2,178
14년 전 조회 1,987
14년 전 조회 2,314
14년 전 조회 2,423
14년 전 조회 1,855
14년 전 조회 2,075
14년 전 조회 2,326
14년 전 조회 2,435
14년 전 조회 1,792
14년 전 조회 1,949
14년 전 조회 2,636
14년 전 조회 3,736
14년 전 조회 2,990
14년 전 조회 3,060
14년 전 조회 2,501
14년 전 조회 2,291
14년 전 조회 2,181
14년 전 조회 1,945
14년 전 조회 1,449
14년 전 조회 2,359
14년 전 조회 5,471
14년 전 조회 2,344
14년 전 조회 2,109
14년 전 조회 1,597
14년 전 조회 1,831
14년 전 조회 1,666
14년 전 조회 1,524
14년 전 조회 1,633
14년 전 조회 1,603
14년 전 조회 1,553
14년 전 조회 2,419
14년 전 조회 1,743
14년 전 조회 1,618
14년 전 조회 1,543
14년 전 조회 1,622
14년 전 조회 1,927
14년 전 조회 1,834
14년 전 조회 2,433
14년 전 조회 2,039
14년 전 조회 4,501
14년 전 조회 1,735
14년 전 조회 2,299
14년 전 조회 2,010
14년 전 조회 3,743
14년 전 조회 3,386
14년 전 조회 1,540
14년 전 조회 2,604
14년 전 조회 1,576
14년 전 조회 3,390
14년 전 조회 2,927
14년 전 조회 1,542
14년 전 조회 6,648
14년 전 조회 1,900
14년 전 조회 2,442
14년 전 조회 2,227
14년 전 조회 2,106
14년 전 조회 2,133
14년 전 조회 2,142
14년 전 조회 2,001
14년 전 조회 2,337
14년 전 조회 2,717
14년 전 조회 1,741
14년 전 조회 2,129
14년 전 조회 3,146
14년 전 조회 3,018
14년 전 조회 1,997
14년 전 조회 2,458
14년 전 조회 4,951
14년 전 조회 1,695
14년 전 조회 3,670
14년 전 조회 2,407
14년 전 조회 2,883
14년 전 조회 2,095
14년 전 조회 1,861
14년 전 조회 1,872
14년 전 조회 2,010