复制代码代码如下: cd /data/software wget https://rsync.samba.org/ftp/rsync/rsync-3.0.9.tar.gz tar zxvf rsync-3.0.9.tar.gz cd rsync-3.0.9 ./configure make make install
*安装完成后显示信息
复制代码代码如下: mkdir -p /usr/local/bin /usr/bin/install -c -m 755 rsync /usr/local/bin mkdir -p /usr/local/share/man/man1 mkdir -p /usr/local/share/man/man5 if test -f rsync.1; then /usr/bin/install -c -m 644 rsync.1 /usr/local/share/man/man1; fi if test -f rsyncd.conf.5; then /usr/bin/install -c -m 644 rsyncd.conf.5 /usr/local/share/man/man5; fi
*配置rsync *#vi /etc/rsync.conf 加入如下内容
复制代码代码如下: uid = root gid = root use chroot = no max connections = 20 strict modes = yes log file = /data/logs/rsyncd/rsyncd.log pid file = /data/logs/rsyncd/rsyncd.pid lock file = /data/logs/rsyncd/rsync.lock log format = %t %a %m %f %b [web] path = /data/vhosts/it121net/ auth users = username read only = no hosts allow = 192.168.1.0/24 #可以是IP段,也可以是IP地址 list = no uid = root gid = root secrets file = /etc/rsync.passwd ignore errors = yes
复制代码代码如下: cd /data/software wget https://rsync.samba.org/ftp/rsync/rsync-3.0.9.tar.gz tar zxvf rsync-3.0.9.tar.gz cd rsync-3.0.9 ./configure make make install
复制代码代码如下: cd /data/software wget http://cloud.github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz tar zxvf inotify-tools-3.14.tar.gz cd inotify-tools-3.14 ./configure make make install
*创建启动脚本 *#vi /etc/rsync-web.sh 加入如下内容
复制代码代码如下: #!/bin/sh SRC=/data/vhosts/it121net/ DES=web WEB2=192.168.1.102 WEB3=192.168.1.103 WEB4=192.168.1.104 USER=username /usr/local/bin/inotifywait -mrq -e create,move,delete,modify $SRC | while read D E F do rsync -ahqzt --password-file=/etc/rsync-client.passwd --delete $SRC $USER@$WEB2::$DES rsync -ahqzt --password-file=/etc/rsync-client.passwd --delete $SRC $USER@$WEB3::$DES rsync -ahqzt --password-file=/etc/rsync-client.passwd --delete $SRC $USER@$WEB4::$DES done #注意:网络上面大部分都是显示一个中杠,可能是编码的事情,实际是应该是两个杠。