中福在线平台搭建论坛:haozbbs.com Q1446595067 安装rsync
#yum install -y xinetd
#yum install -y rsync
#vim /etc/xinetd.d/rsync
启动XINETD
#service xinetd start
Starting xinetd: [ OK ]
#chkconfig xinetd on
#netstat -tlunp |grep 873 查看端口
tcp 0 0 :::873 :::* LISTEN 8831/xinetd
配置密码文件:rsync被同步端配置
A主机上配置 再B上同步
vim /etc/rsyncd.conf
uid=root
gid=root
use chroot=no
max connections=10
log file=/home/logs/rsync/rsyncd.log
pid file=/home/logs/rsync/rsyncd.pid
lock file= /var/run/rsync.lock
[family]
path=/home/mengc
comment=prd
ignore errors
hosts allow = 你要同步到的主机地址
read only=yes
list= no
#vi ~/.ssh/known_hosts 解决ssh 无法登陆的问题
#getenforce(查看selinux状态)
#setenforce 0(修改为允许模式)
最后记得修改配置文件/etc/sysconfig/selinux,要不然下次重启会回退。https://blog.csdn.net/baiwz/article/details/32339049
[[email protected] mengc]# /usr/local/bin/inotifywait -mrp -- timefmt --timefmt ‘%Y/%m/%d-%H:%M:%S‘ --format ‘%T %w %f‘ -e modify,create,delete,attrib /home/mengc
/usr/local/bin/inotifywait: error while loading shared libraries: libinotifytools.so.0: cannot open shared object file: No such file or directory
有很多的so会存放在/usr/local/lib这个目录底下,去这个目录底下找,果然发现自己所需要的.so文件。
所以,在/etc/ld.so.conf中加入/usr/local/lib这一行,保存之后,再运行:/sbin/ldconfig –v更新一下配置即可。
11主机上配置
uid=root
gid=root
use chroot=yes
max connections=10
log file=/home/logs/rsync/rsyncd.log
pid file=/home/logs/rsync/rsyncd.pid
lock file=/var/run/rsync.lock
[family11]
path=/home/work/local/webapps/webapp-family/
comment=family11
ignore errors
hosts allow = IP
read only=false
list=no
在12主机上同步 /usr/bin/rsync -avptgo --delete --progress /home/work/local/webapps/webapp-family [email protected]::family11
配置inotify
[[email protected] software]# cd inotify-tools-3.13
[[email protected] inotify-tools-3.13]# ls
aclocal.m4 AUTHORS ChangeLog config.guess config.h.in config.sub configure configure.ac COPYING depcomp INSTALL install-sh libinotifytools ltmain.sh Makefile.am Makefile.in man missing NEWS README src
[[email protected] inotify-tools-3.13]# ./configure
[[email protected] inotify-tools-3.13]# make && make install
#!/bin/sh
/usr/local/bin/inotifywait -mrq --timefmt ‘%Y/%m/%d-%H:%M:%S‘ --format ‘%T %w%f%e‘ -e modify,create,delete,attrib /home/work/local/webapps/webapp-family | while read date time dir file;do
/usr/bin/rsync -avptgo --delete --progress /home/work/local/webapps/webapp-family [email protected]::family12
done
nohup sh /home/work/local/webapps/inotify.sh &
--使用nohup挂起到后台执行,终端关闭,这个进程也不会被关闭
原文地址:http://blog.51cto.com/13856963/2137565