2008-07-01
rsyncd.confを使ってみる
複数のウェブサーバ間で簡単にデータを同期したかったのでrsyncを使ってみた。
普通にrsyncを使うとパスワードの入力とかが面倒くさいのでxinetd使って設定した。
xinetdのインストール
% sudo yum -y install xinetd
rsyncd.confの作成
/etc/rsyncd.confが存在しないので、作成する。
% sudo vim /etc/rsyncd.conf
uid = root gid = root read only = no hosts allow = 192.168.0.1/24 hosts deny = * exclude = .svn [sample] path = /home/hamaco/web/sampleweb
.svnディレクトリは邪魔なだけなのでexcludeしてある。
hosts allowに許可したいネットワークを指定してやればパスワードなしで転送が出来る。
起動設定
% sudo vim /etc/xinetd.d/rsync - disable = yes + disable = no
起動
xinetdの起動をするだけ。
% sudo /etc/init.d/xinetd start
試す
xinetdを起動したのと別のマシンからrsyncで転送してみる。
% rsync -auv --delete ./testdir/ 192.168.0.51::sample building file list ... done ./ sample.html sample.php sample.pl sample.py sample.rb sample.txt sent 396 bytes received 154 bytes 1100.00 bytes/sec total size is 0 speedup is 0.00
確認
ちゃんと転送できたか確認する。
% ls ~/web/sampleweb/ sample.html sample.php sample.pl sample.py sample.rb sample.txt
まとめ
設定も簡単でrsyncの面倒なexcludeとかパスワード入力をしなくていいので便利。
やってから思ったけど、別に公開鍵用意してexclude部分はシェルスクリプトかなにか書けばいいだけの様な気がする。
なにかもっと便利な使い方があるのかなぁ……
トラックバック - http://d.hatena.ne.jp/hamaco/20080701/1214911298
リンク元
- 8 http://www.google.co.jp/search?q=rsyncd.conf&lr=lang_ja&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ja:official&client=firefox-a
- 7 http://www.google.co.jp/search?sourceid=navclient&hl=ja&ie=UTF-8&rlz=1T4GGLJ_jaJP215JP215&q=rsyncd.conf+exclude
- 6 http://www.google.com/search?hl=ja&lr=lang_ja&ie=UTF-8&oe=UTF-8&q=rsyncd+xinetd&num=50
- 5 http://www.google.co.jp/search?hl=ja&q=rsyncd.conf&btnG=Google+検索&lr=
- 4 http://www.google.co.jp/search?hl=ja&q=rsyncd&lr=
- 4 http://www.google.co.jp/search?q=rsyncd.conf&sourceid=navclient-ff&ie=UTF-8&rlz=1B3GGGL_jaJP270JP271
- 4 http://www.google.com/search?hl=ja&rls=com.microsoft:ja:IE-SearchBox&rlz=1I7IBMA&q=rsyncd.conf install&lr=
- 3 http://twitter.com/hamaco
- 3 http://www.google.co.jp/search?hl=ja&client=firefox-a&rls=org.mozilla:ja:official&hs=rVP&q=imagick+createimage&btnG=検索&lr=lang_ja
- 3 http://www.google.co.jp/search?q=rsyncd&lr=lang_ja&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ja:official&client=firefox-a