2、在源系统上部署Sersync
下载最新的S e r s y n c,s e r s y n c 2 .5beta1_32bit_binary.tar.gz,解压缩以后生成三个文件confxml.xml、rsync_fail_log.sh、sersync2,其中confxml.xml为Sersync的配置文件,rsync_fail_log.sh为执行失败的命令记录,sersync2为Sersync的二进制可执行文件。
目前Sersync不支持在同一个配置文件中添加多个目录,所以需要配置三个文件,来镜像此文件夹。
cp confxml.xml confxml.awstats.xml
cp confxml.xml confxml.web.xml
cp confxml.xml confxml.data.xml
配置文件中只需要改动<sersync></sersync>内的部分。
<sersync>
<localpath watch="/etc/awstats" debug="false">这部分是指定监视的文件夹
<remote ip="211.86.56.228" name="mirrorAwstats"/>这部分是指定镜像服务器的IP地址和同步的模块名称
</localpath>
<rsync>
<auth start="true" users="logsync" passwordfile="/etc/
rsync.pas"/>这部分是指定同步的时候是否需要验证登录,如果要验证登录,设置start="true",用户名users="",密码文件passwordfile="" 。
</rsync>
<crontab start="true" schedule="30">这个部分指定是否开启crontab,定时进行同步
<crontabfilterstart="false">
<excludeexpression="*.php"></exclude>
<excludeexpression="info/*"></exclude>
</crontabfilter>
</crontab>
<plugin start="false" name="refreshCDN"/>
</sersync>
注意:密码文件的权限是600,而且属主是运行sersync进程的用户。
编辑confxml.awstats.xml文件,下面列出的为和源文件字段不同的部分。
<localpath watch="/etc/awstats" debug="false">
<remote ip="211.86.56.228" name="mirrorAwstats"/>
<!--<remote ip="192.168.8.40" name="tongbu"/>-->
</localpath>
<rsync>
<auth start="true" users="logsync" passwordfile="/
etc/rsync.pas"/>
</rsync>
<crontab start="true" schedule="30">
<crontabfilter start="false">
<exclude expression="*.php"></exclude>
<exclude expression="info/*"></exclude>
</crontabfilter>
</crontab>
编辑confxml.web.xml文件。
<localpath watch="/var/www" debug="false">
<remote ip="211.86.56.228" name="mirrorWeb"/>
<!--<remote ip="192.168.8.40" name="tongbu"/>-->
</localpath>
编辑confxml.data.xml文件。
<localpath watch="/home/anylizer" debug="false">
<remote ip="211.86.56.228" name="mirror229"/>
<!--<remote ip="192.168.8.40" name="tongbu"/>-->
</localpath>
如此,即写好了sersync的配置文件。执行如下命令:
./sersync2 -d -r -o confxml.awstats.xml&
./sersync2 -d -r -o confxml.web.xml&
./sersync2 -d -r -o confxml.data.xml&
这样就建立好了同步服务器。
Linux主机进行镜像服务,一般使用的是价格比较昂贵的镜像软件或者硬件,对于低成本、低安全度的镜像服务,sersync2是一个非常好的选择,对于网络管理员、系统管理员来说是一个有效的手段。
(作者单位:1 为山东大学国际教育学院,2 为山东大学网络与信息中心)
特别声明:本站注明稿件来源为其他媒体的文/图等稿件均为转载稿,本站转载出于非商业性的教育和科研之目的,并不意味着赞同其观点或证实其内容的真实性。如转载稿涉及版权等问题,请作者在两周内速来电或来函联系。