- blogs:
- cles::blog
lsyncd ディレクトリのリアルタイムミラーリング
FTPでポツポツと転送されてくるファイルをWindowsのファイルサーバーになるべくリアルタイムにコピーする必要があったのですが、ファイルシステムのリアルタイムミラーリングというとHA用の大艦巨砲なものが多いので、もうちょっとお手軽な感じのソフトはないかなと思って探してみたところ、lsyncdというソフトを見つけました。
Lsyncd uses rsync to synchronize local directories with a remote machine running rsyncd. Lsyncd watches multiple directories trees through inotify. The first step after adding the watches is to rsync all directories with the remote host, and then sync single file by collecting the inotify events. So lsyncd is a light-weight live mirror solution that should be easy to install and use while blending well with your system. See lsyncd --help for detailed command line options.
lsyncdはinotifyを使ってディレクトリを監視し、ディレクトリに変化が合った場合にはrsyncを使ってディレクトリを同期するという動作を行うようです。ファイル転送があると、いちいちrsyncするのでちょっと重いかもしれませんが、ファイルの転送はそんなに頻度が高いわけでもないし、そこまでの信頼性も必要ないので今回はこれで行くことにしました。
インストール自体は下記のコマンドで特に問題なくインストールできました。
make
make install
アーカイブにはinitスクリプトが入っていないのでそのあたりは「リアルタイムミラーリングツール導入(lsyncd rsyncd) - Fedoraで自宅サーバー構築」を参考にしました。設定についてはアーカイブに入っているlsyncd.conf.xmlを/etc/lsyncd.conf.xmlにコピーしたのでその部分については書き換えています。
後は/etc/init.d/lsyncd startでデーモンを起動して、ファイルを送信元に放り込んでみると、リアルタイムに送信先にファイルが同期されます。
† 設定のサンプルなど
/etc/lsyncd.conf.xml
<settings>
<callopts>
<option text="-lt%r" />
<option text="--delete" />
<exclude-file />
<source />
<destination />
</callopts>
</settings>
<directory>
<source path="/path/to/src/" />
<target path="/path/to/dest" />
</directory>
</lsyncd>
/etc/init.d/lsyncd
#
# lsyncd
#
# chkconfig: - 99 20
# description: lsyncd auto start script
start() {
/usr/local/bin/lsyncd
}
stop() {
/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..."
else
echo "lsyncd is not running"
fi
;;
*)
echo "Usage: lsyncd {start|stop|restart|status}"
exit 1
esac
exit $?
このエントリへのTrackbackにはこのURLが必要です→http://blog.cles.jp/item/2944
古いエントリについてはコメント制御しているため、即時に反映されないことがあります。
コメントは承認後の表示となります。
OpenIDでログインすると、即時に公開されます。
OpenID を使ってログインすることができます。
sp-20100319042714644595551@cles.net
- lsyncd windows
- Google - 10/03/17 15:32:26
- lsyncd.conf.xml
- Google - 10/03/15 21:56:47
- lsyncd 設定
- Google - 10/03/15 01:15:44
- lsyncd inotify
- Google - 10/03/09 11:51:24
- lsyncd.conf.xml
- Google - 10/03/08 20:53:13
- lsyncd.conf.xml
- Google - 10/03/08 12:52:16
- lsyncd.conf.xml
- Google - 10/03/06 14:26:58
- lsyncd xml
- Google - 10/03/03 12:53:49
- lsyncd.conf.xml
- Google - 10/03/02 18:17:28
- lsyncd
- Google - 10/02/24 16:28:26
- lsyncd
- Yahoo! - 10/02/23 15:18:44
- lsyncd.conf.xml
- Google - 10/02/23 14:38:12
- lsyncd windows リアルタイム
- Yahoo! - 10/02/23 09:30:47
- lsyncd inotify
- Google - 10/02/17 15:03:40
- lsyncd 設定
- Google - 10/02/17 13:54:07
- おめでとうございます (4)
- 知恵の輪 サターン編 (3)
- SourceForge.JPのSubversion... (3)
- サーバセットアップ (3)
- Thanks ! 10000 Hit ! (3)
- 和食 小錦 (3)
- 散髪しました (3)
- .inはインドのccTLDなのか (3)
- やっと髪をきりました (3)
- 大雪でした (3)
2 . やっぱりあった!パクれる読書感想文! [7572x]
3 . Echofon for Firefox [6347x]
4 . 急性胃腸炎 [5705x]
5 . OpenIDで自分のサイトのURLを使う [5702x]
- CD-ROM起動で、HDDを完全消去
- NP_Moblog v1.16
- pinzoro 01/15
- hsur 12/29
- and more...
- 耳がおかしいと思ったら突発..
- baca 01/13
- hsur 01/13
- and more...
★はてな認証APIをつかってログインすることができます。




