您的位置:首页 > 其它

rsync + inotify-tools 文件同步

2012-07-01 21:14 218 查看
##################################### rsync + inotify-tools ####################################################################

#debain
apt-get install rsync
apt-get install inotify-tools

# centos
yum install -y rsync
yum install -y inotify-tools

cd /tool
wget https://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

#启动
rsync --daemon --port=873 --config=/etc/rsyncd.conf

# rsyncd里面配置passwd是
# username:password 这样的格式
# 客户端使用的时候,不能用这种格式,文件里面只能有password

###服务端用户名密码 156 ,157
chmod 0600 /etc/rsync_pass.pas
root:123456

###客户端密码 112
chmod 0600 /etc/rsync_client.pas
123456

#客户端
rsync -vzrtog --delete --exclude "Logs/" --exclude "logs/" --exclude "Cache/" --exclude "Temp/" --password-file=/etc/rsync_client.pas /usr/local/webserver/htdocs/ads/Uploads/ root@122.72.0.156::www

rsync -vzrtog --delete --exclude "Logs/" --exclude "logs/" --exclude "Cache/" --exclude "Temp/" --password-file=/etc/rsync_client.pas /usr/local/webserver/htdocs/ads/Uploads/ root@122.72.0.157::www

####### 所有代码文件推送 ,推送洛阳机房要用联通ip地址才行 #############################
rsync -vzrtog --delete --exclude "Logs/" --exclude "config.php" --exclude "logs/" --exclude "Cache/" --exclude "Temp/" --password-file=/etc/rsync_client.pas /usr/local/webserver/htdocs/ root@222.88.76.180::www

rsync -vzrtog --delete --exclude "Logs/" --exclude "config.php" --exclude "logs/" --exclude "Cache/" --exclude "Temp/" --password-file=/etc/rsync_client.pas /usr/local/webserver/htdocs/ root@122.72.0.157::www

# 服务端命令 不去不用
rsync -vzrtog --delete --exclude "Logs/" --exclude "logs/" --exclude "Cache/" --exclude "Temp/" --password-file=/etc/rsync_client.pas /usr/local/webserver/htdocs/ads/Uploads root@222.88.93.112::www

rsync -vzrtog --password-file=/etc/rsync_client.pas /usr/local/webserver/htdocs/ads/Uploads/ root@122.72.0.156::www

## 数据库备份后远程传输
rsync -vzrtog --password-file=/etc/rsync_client.pas /usr/local/webserver/mongo/bak/2012-04-22/ root@61.158.132.240::www > /temp/rsync.log &

rsync -vzrtog --password-file=/etc/rsync_client.pas /usr/local/webserver/mongo/bak/2012-04-22/ root@61.54.28.22::www > /temp/rsync2.log &

rsync -vzrtog --password-file=/etc/rsync_client.pas /usr/local/webserver/mongo/bak root@61.158.132.240::www &

chmod +w /usr/local/webserver/htdocs/ads/Uploads
chown -R www:www /usr/local/webserver/htdocs/ads/Uploads

如果出现这个错误“/usr/local/bin/inotifywait: error while loading shared libraries: libinotifytools.so.0”可以采用以下办法解决:
ln -sv /usr/local/lib/libinotify* /usr/lib/
ln -s /usr/local/lib/libinotifytools.so.0 /usr/lib64/libinotifytools.so.0
cp /usr/lib/libinotifytools.so.0 /usr/local/lib/

############### /etc/rsyncd.conf ###############

[root@localhost shell]# cat /etc/rsyncd.conf
uid = root
gid = root
use chroot = no
max connections = 50
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[www]
path = /usr/local/webserver/htdocs/
ignore errors
read only = no
list = false
hosts allow = 122.72.0.156,122.72.0.157,222.88.93.112,61.54.28.22,222.88.76.180,61.158.132.240
hosts deny = *
auth users = root
secrets file = /etc/rsync_pass.pas

#######

#rsync
#rsync --daemon --port=873 --config=/etc/rsyncd.conf

本文出自 “MPU的专栏” 博客,请务必保留此出处http://linjin101.blog.51cto.com/2601349/915356
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: