8月
05
シェルアカウント無しでサーバのコンテンツを同期更新するための手段の一つ。サーバ側はchrootで運用でき任意のディレクトリをトラバースされることもなくftpなどでアカウント発行して運用を行うよりも安心。rsyncはssh経由で暗号化も可能だが、ここでは割愛。
1)サーバ側の設定
rsyncをデーモンとして起動するための設定ファイルを作成する。
- # vi /etc/rsyncd.conf
- uid = root
- gid = wheel
- use chroot = yes
- max connections = 4
- log file = /var/log/rsyncd.log
- pid file = /var/run/rsyncd.pid
- dont compress = *.gz *.tgz *.zip *.pdf *.sit *.sitx *.lzh *.bz2 *.jpg *.gif *.png
- [hostdata01]
- comment = hostdata 01
- hosts allow = xxx.xxx.xxx.xxx/32
- hosts deny = *
- path = /var/www/host01/
- auth users = user01
- secrets file = /etc/rsyncd.secrets
- read only = no
- [hostdata02]
- comment = hostdata 02
- hosts allow = xxx.xxx.xxx.xxx/32
- hosts deny = *
- path = /var/www/host02/
- auth users = user02
- secrets file = /etc/rsyncd.secrets
- read only = no
認証のためのパスワードファイルを作成する。
- # vi /etc/rsyncd.secrets
- user01:password01
- user02:password02
パーミッションを変更する
- # chmod 0600 /etc/rsyncd.secrets
デーモンモードで起動する(できるだけportは変更しておく)
- # rsync --daemon --config=/etc/rsyncd.conf --port=10873
iptablesの設定を変更する
- # vi /etc/sysconfig/iptables
- -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 10873 -j ACCEPT
iptablesを再起動する
- # service iptables restart
2)クライアント側の設定
- # rsync --port=10873 -avz ./hostcontens/ rsync://user01@serveraddress/hostdata01/
これでhostcontents以下の内容がサーバの/var/www/host02/に同期される。
差分更新になるので一度目は時間がかかるが2回目以降は短時間で完了する。
no comment untill now