ubuntu上安装rsync+sersync

服务器:数据从19--->12 和14

172.16.1.12(rsync_server)

172.16.1.14(rsync_server)

172.16.1.19(rsync_client、sersync)

172.16.1.12服务器:

安装rsync server,rsync以xinetd方式运行

#安装命令

apt-get install rsync xinetd

#创建存放文件目录,命令如下:

mkdir /data/res

#修改rsync启动方式

vim /etc/default/rsync

#修改下面这行

RSYNC_ENABLE=inetd

#rsync启动方式的配置文件

vim /etc/xinetd.d/rsync

#加入下面内容

service rsync
{
        disable         = no
        wait            = no
        socket_type     = stream
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure += USERID
}

#rsync的配置文件

vim /etc/rsyncd.conf

#加入下面内容

max connections = 65535
log file = /var/log/rsync.log
timeout = 300
[res]
path = /data/res
read only = no
list = yes
uid = nobody
gid = nogroup
auth users = res
secrets file = /etc/rsyncd.secrets

#创建rsync传输过程中的认证文件

vim /etc/rsyncd.secrets

#内容如下,格式:用户名:密码

res:Gaw1sDnl!v$xZgg3

#此处密码修改成普通字母数字的,特殊符号不认

#将认证文件权限修改成600

chmod 600 /etc/rsyncd.secrets

重启xinetd

/etc/init.d/xinetd restart

查看rsyncserver是否启动

netstat -ntpl|grep 873
tcp        0      0 0.0.0.0:873             0.0.0.0:*               LISTEN      24651/xinetd

测试:在19机器上执行

[email protected]:~# rsync [email protected]::res
Password: 
drwxr-xr-x        4096 2014/08/15 10:23:14 .
-rw-r--r--           0 2014/08/15 10:23:14 test

172.16.1.14服务器的配置与172.16.1.12相同

172.16.1.19服务器

sersync下载地址

https://sersync.googlecode.com/files/sersync2.5.4_64bit_binary_stable_final.tar.gz

解压:

tar -zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz

#二进制文件直接放在/usr/local/sersync/目录下

mkdir -p /usr/local/sersync/{etc,bin,log}
mv GNU-Linux-x86/sersync2 /usr/local/sersync/bin
mv GNU-Linux-x86/confxml.xml /usr/local/sersync/etc

#修改sersync的配置文件

vim confxml.xml

---------------------------

<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
 <!--##设置hostip和port,这个是针对插件保留的字段,对同步功能没有任何作用,默认即可-->
    <host hostip="localhost" port="8008"></host>
<!--##debug模式 默认:关闭,开启debug模式,会在sersync正在运行的控制台,打印inotify事件与rsync同步命令-->
    <debug start="false"/>
<!--##文件系统xfs 默认:关闭-->
    <fileSystem xfs="false"/>
<!--##同步时忽略推送的文件即文件过滤功能(正则表达式),默认:关闭-->
    <filter start="false">
        <exclude expression="(.*)\.svn"></exclude>
        <exclude expression="(.*)\.gz"></exclude>
        <exclude expression="^info/*"></exclude>
        <exclude expression="^static/*"></exclude>
    </filter>
<!--##设置监控事件参数-->
<!--对于大多数应用,可以尝试把createFile(监控文件事件选项)设置为false来提高性能,减少 rsync通讯。因为拷贝文件到监控目录会产生create事件与close_write事件,所以如果关闭create事件,只监控文件拷贝结束时的事 件close_write,同样可以实现文件完整同步。
注意:必须将createFolder保持为true,如果将createFolder设为false,则不会对产生的目录进行监控,该目录下的子文件与子目录也不会被监控。所以除非特殊需要,请开启。默认情况下对创建文件(目录)事件与删除文件(目录)事件都进行监控,如果项目中不需要删除远程目标服务器的文件(目录),则可以将delete 参数设置为false,则不对删除事件进行监控-->
    <inotify>
        <delete start="true"/>
        <createFolder start="true"/>
        <createFile start="false"/>
        <closeWrite start="true"/>
        <moveFrom start="true"/>
        <moveTo start="true"/>
        <attrib start="true"/>
        <modify start="true"/>
    </inotify>
    <sersync>
<!--##设置本地的同步路径-->
        <localpath watch="/data/res.jinhui365.com">
<!--##远程ip和模块名称-->
            <remote ip="172.16.1.12" name="res"/>
            <remote ip="172.16.1.14" name="res"/>
            <!--<remote ip="192.168.8.40" name="tongbu"/>-->
        </localpath>
        <rsync>
<!--##rsync同步参数-->
            <commonParams params="-auvPz"/>
<!--##rsync同步认证-->
            <auth start="true" users="res" passwordfile="/etc/password.rsync"/>
<!--##设置rsync远程服务端口,远程非默认端口需打开自定义-->
            <userDefinedPort start="false" port="874"/><!-- port=874 -->
<!--##设置超时时间-->
            <timeout start="true" time="100"/><!-- timeout=100 -->
<!--##设置rsync+ssh加密传输模式 默认:关闭 ,开启需要设置SSH加密证书-->
            <ssh start="false"/>
        </rsync>
<!--##执行失败的语句存放在/tmp/rsync_fail_log.sh中,隔60分钟后会再次执行同步失败的语句-->
        <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">
<!--当文件同步完成后,会调用command插件,如同步文件是test.php,则test.php文件在改动之后,调用rsync同步到远程服务器后,调用command插件,执行/bin/sh test.php  suffix >/dev/null 2>&1  如果suffix设置了,则会放在inotify事件test.php之后,如果ignoreError为true,则会添加>/dev/null 2>&1当然还可以设置command的filter,当filter为ture,include可以只对正则匹配到的文件,调用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">
<!-- “refreshCDN”,就在同步过程中将文件发送到目的服务器后刷新cdn接口。如果不想使用,则将start属性设为false即可。如果需要使用其他插件,则查看其他plugin标签,将插件名称改为xml中其它插件的名称即可。该模块根据chinaCDN的协议,进行设计,当有文件产生的时候,就向cdn接口发送需要刷新的路径位置
其中 localpath watch 是需要监控的目录。
cdnifo标签制定了cdn接口的域名,端口号,以及用户名与密码。
sendurl标签是需要刷新的url的前缀。
regexurl标签中的,regex属性为true时候,使用match属性的正则语句匹配inotify返回的路径信息,并将正则匹配到的部分作为url一部分,-->
<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/images"/>
        </localpath>
    </plugin>
</head>

---------------------------

ubuntu上安装rsync+sersync

时间: 2024-08-08 04:57:17

ubuntu上安装rsync+sersync的相关文章

64位ubuntu上安装 hadoop-2.4.0

完全参考:http://blog.csdn.net/cruise_h/article/details/18709969 这上面的安装教程 伪分布配置: http://my.oschina.net/mynote/blog/93735 64位ubuntu上安装 hadoop-2.4.0,布布扣,bubuko.com

[异常解决] ubuntu上安装JLink驱动遇到的坑及给后来者的建议

一.前言 最近将整个电脑格式化,改成了linux操作系统 希望这样能让自己在一个新的世界探索技术.提升自己吧- win上的工具用多了,就不想变化了- 继上一篇<ubuntu上安装虚拟机遇到的问题(vmware坑了,virtual-box简单安装,在virtual-box中安装精简版win7)> link:http://www.cnblogs.com/zjutlitao/p/5061917.html 遇到的在ubuntu上装虚拟机坑之后,接下来又遇到了一个新的问题—— 如何在在ubuntu上安装

在ubuntu上安装maven

下载maven http://maven.apache.org/download.cgi 解压 用压缩管理器打开,解压至home目录下 配置环境变量 sudo gedit /etc/profile 添加 export M2_HOME=<span style="color:#ff0000;">/home/weibo/apache-maven-3.0.5(视自己的情况而定)</span> export M2=$M2_HOME/bin export PATH=$M2:

Ubuntu上安装QQ

作者:邹祁峰 邮箱:[email protected] 博客:http://blog.csdn.net/qifengzou 日期:2014.06.12 转载请注明来自"祁峰"的CSDN博客 自从腾讯QQ发布Linux QQ后,其他第三方均纷纷退出Linux版本QQ的开发和维护,而后腾讯QQ也停止了Linux QQ的开发和维护,致使目前Ubuntu上只能使用网页QQ. 而直接登陆网页QQ又使用户不能及时方便的获知对方的回复,目前可使用PIDGIN登陆QQ,能很好的解决网页QQ的这个缺点.

如何在ubuntu上安装flash_player

一.如何在ubuntu上安装Flash Player 相信很多玩ubuntu的都会遇到这样一个问题,当你在网上看视频时,屏幕总会弹出你没用安装 Flash Player,然后就有一个选项叫你下载Flash Player. 遇到这种情况时,我们先下载下来,选择linux tar.gz版本,下载,然后解压到当前目录. 接着点开解压后的文件,你会看到libflashplayer.so文件,打开终端,输入以下命令就行了. sudo cp libflashplayer.so /usr/lib/mozill

在64位ubuntu上安装alienbrain客户端

一.首先从Alienbrain_EN_10.5.zip安装包(网上可搜索下载)里提取出linux版安装文件:Installations/Clients/Linux/NoVM/install.bin并chmod+x使之可执行 二.如果直接运行,可能会出现大把问题,逐步解决如下: 1.首先是报libc.so.6找不到:strings: '/lib/libc.so.6': No such file.这里只要做个链接:/lib/libc.so.6 -> /lib/x86_64-linux-gnu/lib

Ubuntu上安装MongoDB(译)

add by zhj:直接从第四步开始就可以了,而且安装好MongoDB后会自动启动的,不必自己去执行启动命令 原文:https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ 一. 概述 通过这个教程,我们可以用.deb包在LTS Ubuntu上安装MongoDB社区版.虽然Ubuntu自己也有MongoDB包,但是官方的MongoDB社区版通常要更新一些. 注:平台支持 MongoDB只为64位 LTS Ubuntu

通过ppa在ubuntu上安装atom编辑器

在终端中执行以下命令即可,很方便. sudo add-apt-repository ppa:webupd8team/atom sudo apt-get update sudo apt-get install atom 支持Ubuntu 14.10, 14.04, 13.10 和 12.04 通过ppa在ubuntu上安装atom编辑器,布布扣,bubuko.com

ubuntu上安装nodejs

目录: 1. nodejs的下载 2. 解压和安装 3. 安装过程中出现过的问题 4. 总结 1. nodejs的下载 我刚开始没有linux系统,于是安装了nodejs的windows版本进行学习.这两天把ubuntu鼓捣好了,也就想着在ubuntu上装上nodejs. nodejs的官网(http://nodejs.org/)点击install进行下载,而且下载的就是当前的最新版本:不过在windows默认下载的是.msi文件,在linux下默认下载的是.tar.gz!ubuntu下载默认的