开心园地

导航

rsync 的安装

Server setup

    0)yum -y install xinetd

    vi /etc/xinetd.d/rsync


    and ensure following:
    
    disable = no
    
    1)vi /etc/rsyncd.conf
    --------------
    
    uid = nobody
    gid = nobody
    use chroot = no
    max connections = 50
    port = 873
    address = 0.0.0.0
    log file = /var/log/rsyncd.log
    pid file = /var/run/rsyncd.pid
    #hosts allow = 1.2.3.123/32
    
    [main]
    path = /data/upload
    comment = main server data dir
    read only = yes
    dont compress = *.gz *.tgz *.zip *.z *.bz2 *.tbz
    auth users = imguser
    secrets file = /etc/rsyncd.users
    
    *************************
    
    2)
    echo 'imguser:1234' >> /etc/rsyncd.users
    chmod 600 /etc/rsyncd.users 

    #important!can't use 777 or 700,otherwise will happen---auth failed on module
    
    3)
    yum -y install xinetd
    chkconfig  xinetd on
    chkconfig  sshd on
    
    service xinetd restart
    service sshd restart
    netstat -ano|grep :873
    
    4)
    setsebool -P rsync_disable_trans on

*************

Client comand examples 

command example 1:

rsync -avz imguser@10.68.229.204::main /data/upload/ --password-file=/etc/rsyncd.users

在客户端设置密码:#客户端的密码文件格式:password(只有密码,而没有用户名,因为用户名是在命令行指定的,而不能通过密码文件

echo '1234' >> /etc/rsyncd.users

chmod 600 /etc/rsyncd.users 

rsync -avz --delete coupon@10.68.229.204::main /data/upload/--password-file=/etc/rsyncd.users  

***crontjob script**********
vi /data/run.rsync.cms

#!/bin/bash
if [ `netstat -anp | grep rsync | wc -l` -gt 0
 ] ; then
echo "Prev rsync still running. Skip now. `date`" >> /var/log/rsyncd-messages.log
exit 1
else
RDIR='main/'
LDIR='/data/upload/'
RADD='10.68.229.204'
BAKUSER='imguser'
PROG='/usr/bin/rsync'
OPTIONS='-arHvz --checksum'
export RSYNC_PASSWORD='1234'
$PROG $OPTIONS $BAKUSER@$RADD::$RDIR $LDIR
fi

6) crontab -e

#sync every 5 seconds.
*/1 * * * * sleep 5 && /data/run.rsync.cms

refer: http://m.oschina.net/blog/91042

posted on 2014-02-27 13:52  开心园地  阅读(189)  评论(0编辑  收藏  举报