rsync+sersync2实现服务器文件镜像

快速搭建镜像服务器,用于cms发布,服务器资料备份等,采用国人开发的开源serrsync比以前繁琐的inotify+rsync的配置简单很多,当然serrsync也是采用的inotify+rsync

一.在镜像目标服务器部署rsync服务

目标服务器ip:192.168.113.132
1.1

新建/etc/rsyncd.conf 内容如下:
uid=root
gid=root
max connections=4
use chroot=no
strict modes=yes
port=873
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock
[backup]
path=/home/backup/
comment=testrsync
read only=no
list=no
auth users=root
secrets file=/etc/rsync.pas
hosts allow = 192.168.113.132,192.168.113.131,127.0.0.1
1.2
建立密码文件
echo "root:abc" >/etc/rsync.pas 此处的密码abc与root用户的系统密码无关
chmod 600 /etc/rsync.pas
1.3
启动rsync
rsync --daemon

 

二:源服务器配置:

服务器地址:192.168.113.131

2.0
配置rsync客户端
echo "abc" > /etc/rsync.pas
chmod 600 /etc/rsync.pas
注意此处的rsync.pas格式与rsync服务端的格式不同,本人最初在此处耗费了很多时间。
另外一种方式,不用建立密码文件,export RSYNC_PASSWORD=abc
2.1

安装serrsync2
下载最新版serrsync2 http://code.google.com/p/sersync/downloads/detail?name=sersync2.5_32bit_binary_stable_final.tar.gz
2.2
tar -zxvf sersync2.5_32bit_binary_stable_final.tar.gz
cd GNU-Linux-x86
cp confxml.xml a.xml
vi a.xml,录入以下内容
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
    <host hostip="localhost" port="8008"></host>
    <debug start="true"/>
    <fileSystem xfs="false"/>
    <filter start="false">
        <exclude expression="(.*)\.svn"></exclude>
        <exclude expression="(.*)\.gz"></exclude>
        <exclude expression="^info/*"></exclude>
        <exclude expression="^static/*"></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="/home/backup">
            <remote ip="192.168.113.132" name="backup"/>
            <!--<remote ip="192.168.8.39" name="tongbu"/>-->
            <!--<remote ip="192.168.8.40" name="tongbu"/>-->
        </localpath>
        <rsync>
            <commonParams params="-artuz"/>
            <auth start="true" 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/images"/>
        </localpath>
    </plugin>
</head>

2.3 启动监听服务器 ./sersync2 -o a.xml -r -d

 

注:有可能需要配置防火墙,打开指定ip访问873端口的限制

iptables -A INPUT  -s 192.168.113.131 -p tcp -m state --state NEW -m tcp --dport 873 -j ACCEPT

iptables -A INPUT  -s 192.168.113.131 -p udp -m state --state NEW -m udp --dport 873 -j ACCEPT

 

测试环境

rsync服务器:centerOS5.4,rsync客户端:RedHatAS5

参考

rsync资料:http://www.linuxsir.org/main/?q=node/256
serrsync资料:http://hi.baidu.com/johntech/blog/category/%BF%AA%D4%B4%CF%EE%C4%BFsersync

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
图像识别技术在病虫害检测中的应用是一个快速发展的领域,它结合了计算机视觉和机器学习算法来自动识别和分类植物上的病虫害。以下是这一技术的一些关键步骤和组成部分: 1. **数据收集**:首先需要收集大量的植物图像数据,这些数据包括健康植物的图像以及受不同病虫害影响的植物图像。 2. **图像预处理**:对收集到的图像进行处理,以提高后续分析的准确性。这可能包括调整亮度、对比度、去噪、裁剪、缩放等。 3. **特征提取**:从图像中提取有助于识别病虫害的特征。这些特征可能包括颜色、纹理、形状、边缘等。 4. **模型训练**:使用机器学习算法(如支持向量机、随机森林、卷积神经网络等)来训练模型。训练过程中,算法会学习如何根据提取的特征来识别不同的病虫害。 5. **模型验证和测试**:在独立的测试集上验证模型的性能,以确保其准确性和泛化能力。 6. **部署和应用**:将训练好的模型部署到实际的病虫害检测系统中,可以是移动应用、网页服务或集成到智能农业设备中。 7. **实时监测**:在实际应用中,系统可以实时接收植物图像,并快速给出病虫害的检测结果。 8. **持续学习**:随着时间的推移,系统可以不断学习新的病虫害样本,以提高其识别能力。 9. **用户界面**:为了方便用户使用,通常会有一个用户友好的界面,显示检测结果,并提供进一步的指导或建议。 这项技术的优势在于它可以快速、准确地识别出病虫害,甚至在早期阶段就能发现问题,从而及时采取措施。此外,它还可以减少对化学农药的依赖,支持可持续农业发展。随着技术的不断进步,图像识别在病虫害检测中的应用将越来越广泛。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值