码迷,mamicode.com
首页 > 其他好文 > 详细

Rsync之数据同步

时间:2016-11-04 17:36:37      阅读:103      评论:0      收藏:0      [点我收藏+]

标签:rsync

一、环境描述

操作系统: CentOS release 6.5 (Final)

机器A:10.10.10.102

机器B:10.10.10.101

业务要求:将B数据中的文件非实时同步到A机器中。

二、操作步骤

  1. 建立BA的信任关系

    a、生成私钥和公钥

    [root@jy .ssh]# ssh-keygen  -t rsa

    Generating public/private rsa key pair.

    Enter file in which to save the key(/root/.ssh/id_rsa):

    Enter passphrase (empty for no passphrase):

    Enter same passphrase again:

    ……

b、将B的公钥放到A的目录中

[root@jy .ssh]# scp ~/.ssh/id_rsa.pub  test@10.10.10.101:~/.ssh/authorized_keys

c、修改B中的sshd_config配置,将以下注释取消

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile      .ssh/authorized_keys

d、重启B中的sshd服务

[root@hq ~]# service sshd restart

停止 sshd[确定]

正在启动 sshd[确定]

                essh登陆A机器不需要密码

[root@jy .ssh]# ssh test@10.10.10.101

Last login: Sat Jul 12 07:39:47 2014 from10.10.10.102

 

 三、 crontab建立同步

*/1 * * * * /usr/bin/rsync -a --progress /root/test/ test@10.10.10.101:~/test >>~/rsync.log  2>&1

日志如下:

[root@jy~]# tail -f rsync.log

sendingincremental file list

sent 64bytes  received 12 bytes  50.67 bytes/sec

totalsize is 1073741828  speedup is14128181.95

tail:rsync.log:文件已截断

sendingincremental file list

./

tap.D1.tar.gz

     6137477 100%   60.64MB/s   0:00:00 (xfer#1, to-check=0/3)

 

sent6138337 bytes  received 34 bytes  12276742.00 bytes/sec

totalsize is 6137481  speedup is 1.00

tail:rsync.log:文件已截断

sending incremental file list


Rsync之数据同步

标签:rsync

原文地址:http://newguest.blog.51cto.com/10774226/1869457

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!