sersync主配置文件:/usr/local/sersync/sersync25/confxml.xml
mkdir /usr/local/sersync
tar zvxf sersync2.5_64bit_binary_stable_final.tar.gz
mv GNU-Linux-x86 /usr/local/sersync/sersync25
- <?xml version="1.0" encoding="ISO-8859-1"?>
- <head version="2.5">
- <host hostip="192.168.100.188" port="8008"></host> #本地IP,端口
- <debug start="true"/>
- <fileSystem xfs="false"/>
- <filter start="true">
- <exclude expression="(.*)\.zip"></exclude>
- <exclude expression="^home\*"></exclude>
- <exclude expression="^p_w_picpaths/*"></exclude>
- <exclude expression="^statics/*"></exclude>
- </filter>
- <inotify>
- <delete start="true"/>
- <createFolder start="true"/>
- <createFile start="false"/>
- <closeWrite start="true"/>
- <moveFrom start="true"/>
- <moveTo start="true"/>
- <attrib start="false"/>
- <modify start="false"/>
- </inotify>
- <sersync>
- <localpath watch="/data/httpd/b2c"> #本地同步的文件路径
- <remote ip="192.168.100.187" name="test187"/> #远程IP,模块名
- <!--<remote ip="192.168.100.188" name="test188"/>-->
- <!--<remote ip="192.168.8.40" name="tongbu"/>-->
- </localpath>
- <rsync>
- <commonParams params="-artuz"/> #改为-artuzp,同步目录权限
- <auth start="false" users="root" passwordfile="/etc/rsync.pas"/>
- <userDefinedPort start="false" port="874"/><!-- port=874 -->
- <timeout start="false" time="100"/><!-- timeout=100 -->
- <ssh start="false"/>
- </rsync>
- <failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
- <crontab start="false" schedule="600"><!--600mins-->
- <crontabfilter start="false">
- <exclude expression="*.php"></exclude>
- <exclude expression="info/*"></exclude>
- </crontabfilter>
- </crontab>
- <plugin start="false" name="command"/>
- </sersync>
- <plugin name="command">
- <param prefix="/bin/sh" suffix="" ignoreError="true"/> <!--prefix /opt/tongbu/mmm.sh suffix-->
- <filter start="false">
- <include expression="(.*)\.php"/>
- <include expression="(.*)\.sh"/>
- </filter>
- </plugin>
- <plugin name="socket">
- <localpath watch="/opt/tongbu">
- <deshost ip="192.168.138.20" port="8009"/>
- </localpath>
- </plugin>
- <plugin name="refreshCDN">
- <localpath watch="/data0/htdocs/cms.xoyo.com/site/">
- <cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/>
- <sendurl base="http://pic.xoyo.com/cms"/>
- <regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/p_w_picpaths"/>
- </localpath>
- </plugin>
- </head>
启用sersync /usr/local/sersync/sersync25/sersync2 -o /usr/local/sersync/sersync25/confxml.xml -d
-o 指定配置文件
-d 进入后台运行
最后将启动命令加入到启动脚本中/etc/rc.local,内容如下: /usr/local/sersync/sersync25/sersync2 -o /usr/local/sersync/sersync25/confxml.xml -d
一、安装rsync3.0.7
1、 卸载rsync(系统一般会默认安装rsync)
# rpm -qa |grep rsync
#rpm -e rsync-2.6.8-3.1
2、 安装新版rsync
# tar -zxvf rsync-3.0.7
# cd rsync-3.0.7
# ./configure
# make
# make install
二、配置rsync
1、 建立相关配置文件
# mkdir /usr/local/rsync
# touch /usr/local/rsync/rsync.conf ←rsync主配置文件
# touch /usr/local/rsync/rsync.pwd ←密码配置文件
# touch /usr/local/rsync/rsync.motd ←登录欢迎信息文件
2、 设置配置文件权限(必须)
# chmod 600 /usr/local/rsync –R
3、 设置主配置文件
# vim /usr/local/rsync/rsync.conf
pid file = /var/run/rsyncd.pid
port = 873
address = 192.168.100.186 #本机IP
uid = root
#服务器端传输文件时,要发哪个用户和用户组来执行
gid = root
#服务器端传输文件时,要发哪个用户组来执行
use chroot = yes
read only = yes
#只读选择,不允许写入数据
hosts allow=192.168.100.0/255.255.255.0 #允许网段
#hosts deny=*
max connections = 10 #允许最大连接数
motd file = /usr/local/rsync/rsync.motd
#motd file 是定义客户端登录服务器是看到的登录欢迎信息
log file = /var/log/rsync.log
transfer logging = yes
log format = %t %a %m %f %b
syslog facility = local3
timeout = 300
[web00]
#模块定义
path = /data/httpd/b2c
list=yes
ignore errors=yes
#忽略IO错误
read only = no
write only = no
secrets file = /usr/local/rsync/rsync.pwd
#密码存在哪个文件
comment = www backup
4、 设置用户密码认证文件
vi /usr/local/rsync/rsync.pwd
在里面加入:
xiaofei:123456
#密码配置文件的格式“用户名:密码”
保存退出:wq
5、 配置登录欢迎信息文件
vi /usr/local/rsync/rsync.motd
加入如下信息:
+++++++++++++++++++++++++++
+ rsync +
+++++++++++++++++++++++++++
保存退出:wq
三、启动rsync
/usr/local/bin/rsync --daemon --config=/usr/local/rsync/rsync.conf
echo "/usr/local/bin/rsync --daemon --config=/usr/local/rsync/rsync.conf" >> /etc/rc.d/rc.local
注:
安装好rsync后,执行/usr/local/rsync/bin/rsync --daemon启动rsync时报错:
rsync: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
解决办法:在/etc/ld.so.conf中加一行/usr/local/lib,运行ldconfig。再运行/usr/local/rsync/bin/rsync --daemon,就可以了。报错的原因可能之前更新过iconv库.
如果你不是root,ldconfig也运行不了的,解决的方法就是,设置环境变量 LDFLAGS=-L/usr/local/lib