sersync2.5+rsync3.0.7的配置

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

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <head version="2.5">
  3. <host hostip="192.168.100.188" port="8008"></host> #本地IP,端口 
  4. <debug start="true"/>
  5. <fileSystem xfs="false"/>
  6. <filter start="true">
  7. <exclude expression="(.*)\.zip"></exclude>
  8. <exclude expression="^home\*"></exclude>
  9. <exclude expression="^images/*"></exclude>
  10. <exclude expression="^statics/*"></exclude>
  11. </filter>
  12. <inotify>
  13. <delete start="true"/>
  14. <createFolder start="true"/>
  15. <createFile start="false"/>
  16. <closeWrite start="true"/>
  17. <moveFrom start="true"/>
  18. <moveTo start="true"/>
  19. <attrib start="false"/>
  20. <modify start="false"/>
  21. </inotify>
  22. <sersync>
  23. <localpath watch="/data/httpd/b2c"> #本地同步的文件路径 
  24. <remote ip="192.168.100.187" name="test187"/> #远程IP,模块名 
  25. <!--&lt;remote ip="192.168.100.188" name="test188"/>--&gt;
  26. <!--&lt;remote ip="192.168.8.40" name="tongbu"/>--&gt;
  27. </localpath>
  28. <rsync>
  29. <commonParams params="-artuz"/> #改为-artuzp,同步目录权限 
  30. <auth start="false" users="root" passwordfile="/etc/rsync.pas"/>
  31. <userDefinedPort start="false" port="874"/><!-- port=874 -->
  32. <timeout start="false" time="100"/><!-- timeout=100 -->
  33. <ssh start="false"/>
  34. </rsync>
  35. <failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
  36. <crontab start="false" schedule="600"><!--600mins-->
  37. <crontabfilter start="false">
  38. <exclude expression="*.php"></exclude>
  39. <exclude expression="info/*"></exclude>
  40. </crontabfilter>
  41. </crontab>
  42. <plugin start="false" name="command"/>
  43. </sersync>
  44. <plugin name="command">
  45. <param prefix="/bin/sh" suffix="" ignoreError="true"/> <!--prefix /opt/tongbu/mmm.sh suffix-->
  46. <filter start="false">
  47. <include expression="(.*)\.php"/>
  48. <include expression="(.*)\.sh"/>
  49. </filter>
  50. </plugin>  
  51. <plugin name="socket">
  52. <localpath watch="/opt/tongbu">
  53. <deshost ip="192.168.138.20" port="8009"/>
  54. </localpath>
  55. </plugin>
  56. <plugin name="refreshCDN">
  57. <localpath watch="/data0/htdocs/cms.xoyo.com/site/">
  58. <cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/>
  59. <sendurl base="http://pic.xoyo.com/cms"/>
  60. <regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>
  61. </localpath>
  62. </plugin>
  63. </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安装

一、安装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" &gt;&gt; /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

你可能感兴趣的:(职场,rsync,休闲)