标签:case body aop install one lis sage 0.11 options
rsync命令是一个远程数据同步工具,一般企业用作文件定时同步目录,代码发布等功能。
1.rsync分为服务端和客户端,两端都需要安装rsync服务。
yum -y install rsync
编辑/etc/xinetd.d/rsync
disable = yes 改为no #表示不禁用rsync。
2.客户端:编辑/etc/rsyncd.conf 修改以下。服务端推送到客户端文件的话需要在客户端修改,即客户端要接收文件的话要指定一个路径、权限。
uid = nobody    #表示目录的权限必须要是nobody,若推送报错权限拒绝,一定是目录或文件不是nobody权限。
gid     = nobody
use chroot      = yes
max connections = 30
pid file=/var/run/rsyncd.pid
log file=/var/log/rsyncd.log
list = no
[www1]     #同步项  即同步模块  
path            = /home/server1     #同步到的路径  
hosts allow     = 192.168.50.118    #允许ip  
read only       = no  #是否只读,一定要no,否则无法推送。
3.服务端:编辑/etc/rsyncd.conf 修改以下。
uid = nobody    #表示目录的权限必须要是nobody,若推送报错权限拒绝,一定是目录或文件不是nobody权限。
gid = nobody
use chroot = yes
max connections = 30
pid file=/var/run/rsyncd.pid
log file=/var/log/rsyncd.log
list = no
4.制作rsync启动脚本 vim /etc/init.d/xinetd
PATH=/sbin:/bin:/usr/bin:/usr/sbin
# Source function library.
. /etc/init.d/functions
# Get config.
test -f /etc/sysconfig/network && . /etc/sysconfig/network
# More config
test -f /etc/sysconfig/xinetd && . /etc/sysconfig/xinetd
RETVAL=0
prog="xinetd"
start(){
    [ -f /usr/sbin/xinetd ] || exit 5
    [ -f /etc/xinetd.conf ] || exit 6
    # this is suitable way considering SELinux is guarding write 
    # access to PID file
        [ $EUID -eq 0 ] || exit 4
echo -n $"Starting $prog: "
# Localization for xinetd is controlled in /etc/synconfig/xinetd
    if [ -z "$XINETD_LANG" -o "$XINETD_LANG" = "none" -o "$XINETD_LANG" = "NONE" ]; then
        unset LANG LC_TIME LC_ALL LC_MESSAGES LC_NUMERIC LC_MONETARY LC_COLLATE
    else
        LANG="$XINETD_LANG"
        LC_TIME="$XINETD_LANG"
        LC_ALL="$XINETD_LANG"
        LC_MESSAGES="$XINETD_LANG"
        LC_NUMERIC="$XINETD_LANG"
        LC_MONETARY="$XINETD_LANG"
        LC_COLLATE="$XINETD_LANG"
        export LANG LC_TIME LC_ALL LC_MESSAGES LC_NUMERIC LC_MONETARY LC_COLLATE
    fi
    unset HOME MAIL USER USERNAME
    daemon $prog -stayalive -pidfile /var/run/xinetd.pid "$EXTRAOPTIONS"
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/xinetd
    return $RETVAL
}
stop(){
    [ -f /usr/sbin/xinetd ] || exit 5
    [ -f /etc/xinetd.conf ] || exit 6
    # this is suitable way considering SELinux is guarding write 
    # access to PID file
        [ $EUID -eq 0 ] || exit 4
    echo -n $"Stopping $prog: "
    killproc -p /var/run/xinetd.pid $prog
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/xinetd
    return $RETVAL
}
reload(){
    [ -f /usr/sbin/xinetd ] || exit 5
    [ -f /etc/xinetd.conf ] || exit 6
    echo -n $"Reloading configuration: "        
    killproc $prog -HUP
    RETVAL=$?
    echo
    return $RETVAL
}
restart(){
    stop
    start
}
condrestart(){
    if [ -e /var/lock/subsys/xinetd ] ; then
        restart
        RETVAL=$?
        return $RETVAL
    fi
    RETVAL=0
    return $RETVAL
}
# See how we were called.
case "$1" in
    start)
        start
        RETVAL=$?
        ;;
    stop)
        stop
        RETVAL=$?
        ;;
    status)
        status $prog
        RETVAL=$?
        ;;
    restart)
        restart
        RETVAL=$?
        ;;
    reload|force-reload)
        reload
        RETVAL=$?
        ;;
    condrestart|try-restart)
        condrestart
        RETVAL=$?
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
        RETVAL=2
esac
exit $RETVAL
chmod +x /etc/init.d/xinetd
5.开始使用了:
rsync -avz authorized_keys 192.168.0.164::dsa_pub
sending incremental file list
authorized_keys
sent 576 bytes  received 33 bytes  1218.00 bytes/sec--delete
total size is 616  speedup is 1.01
6:参数详解:
-v, --verbose 详细模式输出。
-a, --archive 归档模式,表示以递归方式传输文件,并保持所有文件属性
-z, --compress 对备份的文件在传输时进行压缩处理。
--delete 同步删除  例:rsync -avz --delete /tmp/2/ /var/spool/clientmqueue/     清楚/var/spool/clientmqueue/下的垃圾。
--exclude="" 排除同步 例--exclude=".svn",提交到svn目录的时候要排除隐藏的svn目录。
标签:case body aop install one lis sage 0.11 options
原文地址:http://www.cnblogs.com/qinyujie/p/7194032.html