• [rsync] linux rsync 安装


    linux rsync 安装

    作者:flymaster

    qq:908601287

    blog:http://www.cnblogs.com/flymaster500/

    rsync作用比较:
    远程拷贝:scp
    本地拷贝:cp
    删除功能:rm

    rsync可以是一个网络服务(port socket)
    rsync命令是客服端命令:
    第一种工作模式:local
    rsync -avz /etc/hosts /tmp/ ===cp
    rsync -avz --delete /null/ /tmp/ ===rm
    第二种工作模式:remote shell
    push:
    rsync -avzP -e 'ssh -p 22' /tmp/ root@10.0.0.8:/tmp
    pull:
    rsync -avzP -e 'ssh -p 22' root@10.0.0.8:/tmp /tmp/


    操作流程
    1.yum install -y rsync
    2.rsync --version
    3.touch /etc/rsyncd.conf
    4.vi /etc/rsyncd.conf
    #Rsync server
    #created by oldboy
    ##rsyncd.conf start##
    uid = rsync
    gid = rsync
    use chroot =no
    max connections =2000
    timeout =600
    pid file = /var/run/rsyncd.pid
    lock file = /var/run/rsync.lock
    log file = /var/log/rsyncd.log
    ignore errors
    read only = false
    list = false
    hosts allow = 192.168.70.0/24
    hosts deny = 0.0.0.0/32
    auth users = rsync_backup
    secrets file = /etc/rsync.password
    ########################################
    [backup]
    comment = www by old0boy
    path = /backup
    ############################################

    [root@backup-105 etc]# ps -ef|grep rsync|grep -v grep
    root 3854 1 0 15:17 ? 00:00:00
    rsync --daemon(启动rsync服务。程序)
    [root@backup-105 etc]# netstat -lntup|grep rsync
    tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 3854/rsync
    tcp 0 0 :::873 :::* LISTEN 3854/rsync
    [root@backup-105 etc]# ss -lntup|grep rsync
    tcp LISTEN 0 5 :::873 :::* users:(("rsync",3854,5))
    tcp LISTEN 0 5 *:873 *:* users:(("rsync",3854,3))

    [root@backup-105 etc]# lsof -i :873
    COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
    rsync 3854 root 3u IPv4 15456 0t0 TCP *:rsync (LISTEN)
    rsync 3854 root 5u IPv6 15457 0t0 TCP *:rsync (LISTEN)
    [root@backup-105 etc]# useradd rsync -s /sbin/nologin -M
    [root@backup-105 etc]# id rsync
    uid=502(rsync) gid=502(rsync) 组=502(rsync)
    [root@backup-105 /]# mkdir /backup
    [root@backup-105 /]# chown -R rsync /backup/
    [root@backup-105 /]# ls -ld /backup/
    drwxr-xr-x. 2 rsync root 4096 9月 18 15:36 /backup/
    echo "rsync_backup:oldboy" >/etc/rsync.password
    [root@backup-105 etc]# cat /etc/rsync.password
    rsync_backup:oldboy
    chmod 600 /etc/rsync.password
    [root@backup-105 etc]# ll /etc/rsync.password
    -rw-------. 1 root root 20 9月 18 15:43 /etc/rsync.password

    rsync server:配置步骤
    1.vi /etc/rsyncd.conf
    #Rsync server
    #created by oldboy
    ##rsyncd.conf start##
    uid = rsync
    gid = rsync
    use chroot =no
    max connections =2000
    timeout =600
    pid file = /var/run/rsyncd.pid
    lock file = /var/run/rsync.lock
    log file = /var/log/rsyncd.log
    ignore errors
    read only = false
    list = false
    hosts allow = 192.168.70.0/24
    hosts deny = 0.0.0.0/32
    auth users = rsunc_backup
    secrets file = /etc/rsync.password
    ########################################
    [backup]
    comment = www by old0boy
    path = /backup
    ############################################


    2.创建rsync用户、共享目录/backup
    useradd rsync -s /sbin/nologin -M
    id rsync

    mkdir /backup
    chown -R rsync /backup
    ll-d /backup/

    3.创建密码文件
    echo "rsync_backup:oldboy" >/etc/rsync.password
    chmod 600 /etc/rsync.password

    4.rsync --daemon
    netstat -lntup|grep rsync
    ps -ef|grep rsync|grep -v grep

    5.加入开机自启动
    echo "rsync --daemon" >>/etc/rc.local
    cat /etc/rc.local
    rsync:客服端
    1.创建密码文件
    echo "oldboy" >/etc/rsync.password
    chmod 600 /etc/rsync.password
    ls -l /etc/rsync.password
    2.rsync
    push:
    rsync[OPTION...] SRC...[USER@]HOST::DEST
    rsync -avz /tmp/ rsync_backup@192.168.70.105::backup --password-file=/etc/rsync.password

    rsync --daemon --address=192.168.70.105
    killall(pkill)


  • 相关阅读:
    ①---Java开发环境配置
    1.java的基础和数据类型
    0、原生jdbc工厂类
    spring中使用quartz动态添加定时任务执行sql
    app前端代码打包步骤
    less的解析笔记
    转:玩转HTML5移动页面(动效篇)
    HTML5属性备忘单
    玩转git和github
    js基础----数组
  • 原文地址:https://www.cnblogs.com/flymaster500/p/10155502.html
Copyright © 2020-2023  润新知