• rsync远程同步


    第一次同步时 rsync 会复制全部内容,但在下一次只传输修改过的文件。

     

    服务安装

    [root@ygy130 ~]# yum install xinetd

     [root@ygy130 ~]# vim /etc/xinetd.d/rsync 

    启动服务

    [root@ygy130 ~]# /etc/init.d/xinetd restart
    Stopping xinetd: [ OK ]
    Starting xinetd: [ OK ]

    [root@ygy130 ~]# netstat -antup | grep xinetd
    tcp 0 0 :::873 :::* LISTEN 9743/xinetd

    chkconfig xinetd on   设置开机自启动

    使用系统用户进行同步: 在我的130机器上创建一个用户,把130服务器上的数据,复制到这台机器上

    useradd rget1              创建用户

    echo rget1:123456 | chpasswd    创建密码

    setfacl -R -m user:rget1:rwx /var/www/html/ 

    setfacl -R -m default:rget1:rwx /var/www/html/

    [root@yuguangyuan ~]# mkdir -p /web-back

    [root@yuguangyuan ~]# echo "0 3 * * * /usr/bin/rsync -avz --delete -e 'ssh -p 222 ' rget1@192.168.1.130:/var/www/html/ /web-back/ ">> /var/spool/cron/root

    每天3点备份一下数据。

    前提是要做密钥认证。

     [root@yuguangyuan ~]# ssh-keygen

    [root@yuguangyuan ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub  "-p 222  rget1@192.168.1.130"

    不使用系统用户进行备份。我这里只能使用ssh的22端口号,自定义的端口号,备份没有成功。

    [root@ygy130 ~]# vim /etc/rsyncd.conf        文件不存在,需要自己创建

    uid = nobody
    gid = nobody
    address = 192.168.1.130
    port = 873
    hosts allow = 192.168.1.131
    use chroot = yes
    max connections = 5
    pid file = /var/run/rsyncd.pid
    lock file = /var/run/rsync.lock
    log file = /var/log/rsyncd.log
    motd file = /etc/rsyncd.motd
    [wwwroot]
    path=/var/www/html
    comment = dd
    read only = yes
    list = yes
    auth users = rsyncuser
    secrets file = /etc/rsync.passwd

    保存,退出

    echo "Welcome to Backup Server" > /etc/rsyncd.motd    写提示信息
    [root@ygy130 ~]# echo rsyncuser:123 > /etc/rsync.passwd   密码
    chmod 600 /etc/rsync.passwd    修改权限
    /etc/init.d/xinetd restart         重启

    131机器输入:下面命令进行备份

    [root@yuguangyuan ~]# rsync -avz --progress --delete rsyncuser@192.168.1.130::wwwroot /web-back/
    Welcome to Backup Server


    Password:
    receiving incremental file list
    ./
    aaa.txt
    5 100% 4.88kB/s 0:00:00 (xfer#1, to-check=0/4)

    sent 84 bytes received 210 bytes 117.60 bytes/sec
    total size is 5 speedup is 0.02
    [root@yuguangyuan ~]#

    可以加密码文件,不要手动输入密码,手动创建一个passfile文件,文件内容为密码:123

    --password-file=/home/yy/passfile

    [root@yuguangyuan ~]# rsync -avz --progress --delete rsyncuser@192.168.1.130::wwwroot /web-back/ --password-file=/home/yy/passfile
    Welcome to Backup Server

    receiving incremental file list
    ./
    3.txt
    0 100% 0.00kB/s 0:00:00 (xfer#1, to-check=0/3)

    sent 84 bytes received 187 bytes 542.00 bytes/sec
    total size is 0 speedup is 0.00

  • 相关阅读:
    oracle sql日期比较
    rlwrap真是一个好东西
    Dataguard 归档丢失处理
    oracle latch工作原理
    Latch free等待事件
    Redhat Enterprise Linux 5 安装 Oracle 10g release 2
    oracle 日期问题
    Oracle自动存储管理 ASMLib的支持变化
    [官方文档] oracle官方文档总汇(9i,10g,11gR1, 11gR2)
    实时分布式搜索引擎比较(senseidb、Solr、elasticsearch)
  • 原文地址:https://www.cnblogs.com/yuguangyuan/p/5902060.html
Copyright © 2020-2023  润新知