linux下文件共享与同步

nfs共享文件=======================
服务端
# vi /etc/exports 增加共享目录
/home/easyinfo/enterprise 192.168.0.205(rw,all_squash,anonuid=0,anongid=0)
/home/easyinfo/user 192.168.0.205(rw,all_squash,anonuid=0,anongid=0)
#/etc/rc.d/init.d/portmap start (在REDHAT中PORTMAP是默认启动的)
#/etc/rc.d/init.d/nfs start 启动NFS服务
#/etc/init.d/iptables stop
客户端
#mount -t nfs -o rw 192.168.0.203:/home/easyinfo/enterprise /home/easyinfo/masterenterprise
#mount -t nfs -o rw 192.168.0.203:/home/easyinfo/user /home/easyinfo/masteruser

rsync同步文件=====================
服务端
#rpm -i xinetd-2.3.14-10.el5.x86_64.rpm
#vi /etc/xinetd.d/rsync 将其中的 disable = yes 改成 disable = no
#vi /etc/rsyncd.conf 在里面添加如下内容
[rsyncuser]
path = /home/easyinfo/masteruser
hosts allow = 127.0.0.1
hosts deny = *
list = true
uid = root
gid = root
use chroot = no

[rsyncenterprise]
path = /home/easyinfo/masterenterprise
hosts allow = 127.0.0.1
hosts deny = *
list = true
uid = root
gid = root
use chroot = no
#/etc/init.d/xinetd start 注意:如果服务器上装有防火墙记得要打开端口,默认端口是873
#setsebool -P rsync_disable_trans on
客户端
#rsync -avz --progress 127.0.0.1::rsyncuser /home/easyinfo/user
#rsync -avz --progress 127.0.0.1::rsyncenterprise /home/easyinfo/enterprise
脚本:rsyncfile.sh
rsync -avz --ignore-existing --size-only /home/easyinfo/masteruser/ /home/easyinfo/user >> /home/easyinfo/entfilebak/rsyncuser.log
rsync -avz --ignore-existing --size-only /home/easyinfo/masterenterprise/ /home/easyinfo/enterprise >> /home/easyinfo/entfilebak/rsyncenterprise.log
rsync -avz /home/easyinfo/masterenterprise/001/000/001/workflow/ /home/easyinfo/enterprise/001/000/001/workflow >> /home/easyinfo/entfilebak/rsyncenterprise.log
rsync -avz /home/easyinfo/masterenterprise/001/000/001/information/ /home/easyinfo/enterprise/001/000/001/information >> /home/easyinfo/entfilebak/rsyncenterprise.log
rsync -avz /home/easyinfo/masterenterprise/387/000/001/workflow/ /home/easyinfo/enterprise/387/000/001/workflow >> /home/easyinfo/entfilebak/rsyncenterprise.log
rsync -avz /home/easyinfo/masterenterprise/387/000/001/information/ /home/easyinfo/enterprise/387/000/001/information >> /home/easyinfo/entfilebak/rsyncenterprise.log
定时计划:
*/10 * * * * /home/easyinfo/entfilebak/rsyncfile.sh

使用sersync同步文件=====================
服务端
下载sersync2.5_64bit_binary_stable_final.tar.gz
#tar -zxvf sersync2.5_64bit_binary_stable_final.tar.gz
#vi confxml.xml
    <sersync>
        <localpath watch="/home/easyinfo/masterenterprise">
            <remote ip="192.168.0.205" name="rsyncenterprise"/>
        </localpath>
        <rsync>
            <commonParams params="-artuz"/>
            <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="30"><!--600mins-->
            <crontabfilter start="false">
                <exclude expression="*.php"></exclude>
                <exclude expression="info/*"></exclude>
            </crontabfilter>
        </crontab>
        <plugin start="false" name="command"/>
    </sersync>
#/home/easyinfo/soft/GNU-Linux-x86/sersync2 -r -n 6 -d -o /home/easyinfo/soft/GNU-Linux-x86/confenterprise.xml
客户端
#vi /etc/rsyncd.conf
uid=root
gid=root
max connections=36000
use chroot=no
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock

[rsyncuser]
path = /home/easyinfo/user
read only = no
ignore errors = yes
hosts allow = 192.168.0.203
hosts deny = *
list = true

[rsyncenterprise]
path = /home/easyinfo/enterprise
read only = no
ignore errors = yes
hosts allow = 192.168.0.203
hosts deny = *
list = true
#rsync --daemon

转载于:https://my.oschina.net/huisage/blog/23919

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值