rsync によるwwwサーバの同期(Scientific Linux release 6.6)
サーバAの/var/www/htmlとサーバBの同ディレクトリをrsyncで同期させる。
サーバAでrsyncコマンドを実行する。サーバBはrsyncサーバとする。
サーバA 192.168.1.75
***/var/www/html をアーカイブしてサーバBに転送
cd /var/www
tar cvzf html.tar.gz html
scp html.tar.gz admin@192.168.0.75:/tmp/.
サーバB 192.168.0.75
***rsyncでは差分を送るので,最初に/var/www/htmlを同じ内容にしておく。
cd /var/www
tar xvzf /tmp/html.tar.gz
サーバB 192.168.0.75
*** rsyncサーバ設定
vi /etc/rsyncd.conf
[web]
path = /var/www/
use chroot = true
hosts allow = 192.168.1.75
hosts deny = *
list = true
uid = root
gid = root
read only = false
log file = /var/log/rsyncd.log
pid file - /var/run/rsyncd.pid
vi /etc/xinetd.d/rsync
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = no
#disable = yes
flags = IPv6
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
chkconfig --add rsync
chkconfig --list rsync
rsync on
service xinetd restart
サーバA 192.168.1.75
***rsyncのテスト
rsync -avz --delete /var/www/html 192.168.0.75::web
sending incremental file list
:
sent 175819 bytes received 447 bytes 352532.00 bytes/sec
total size is 270244279 speedup is 1533.16
後は上記rsyncコマンドを cron で定期実行させればいい。
コメント 0