rhel上配置rsync

服务端配置(192.168.1.203)

1、安装

[root@robbiehost oracle]# yum instll rsync
[root@robbiehost oracle]# rpm -qa|grep rsync
rsync-3.0.6-9.el6.x86_64


在/etc/下创建三个文件
rsyncd.conf     rsyncd.motd     rsyncd.secrets

[root@robbiehost oracle]# cat /etc/rsyncd.conf 
uid = root
gid = root
port = 873                           //指定运行端口,默认是873,您可以自己指定
hosts allow = 192.168.1.202, 192.168.1.201 // 允许访问的客户机
#hosts deny = 0.0.0.0/32                      //拒绝访问的
use chroot = 
max connections = 
timeout=

// 下面这些绿色文件是安装完RSYNC服务后自动生成的文件,当然也可以手动配置到指定路径
pid file = /var/run/rsyncd.pid      //pid文件的存放
lock file = /var/run/rsync.lock     //锁文件的存放位置
log file = /var/log/rsyncd.log      //日志记录文件的存放
#motd file = /etc/rsyncd.motd      //欢迎

// 上面这段是全局配置,下面的模块可以有
[test]                   // 模块名字,自己命名
path = /home/tomcat/test               //指定文件目录所在位置,这是必须指定 
comment = rsync files                         // 注释
ignore errors                                 //忽略IO
read only = yes 
list = no                                     // 是否把rsync 服务器上提供同步数据的目录显示
//下面这一行,同步验证时用的账号,如果没有这项就是匿名同步,client同步时不用用户名也能同步。
auth users = rsync
secrets file = /etc/rsync.passwd             // 指定认证文件
[root@robbiehost oracle]# cat /etc/rsync.passwd 
rsync:robbie

[root@robbiehost oracle]# cat /etc/rsyncd.motd 
Welcome the rsync services!


2、启动rsync服务

先修改文件,将disable=yes 改为no

 

cat /etc/xinetd.d/rsync 
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
#       allows crc checksumming etc.
service rsync
{
        disable = no
        flags           = IPv6
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID
}
 [root@robbiehost oracle]# /usr/bin/rsync --daemon  --config=/etc/rsyncd.conf 
[root@robbiehost oracle]# lsof -i :873
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
rsync   3599 root    3u  IPv4 386484      0t0  TCP *:rsync (LISTEN)
rsync   3599 root    5u  IPv6 386485      0t0  TCP *:rsync (LISTEN)

服务端启动成功!(注意防火墙)

 

客户端配置(192.168.1.202)

1、安装[root@mail home]# yum install rsync

[root@mail home]# rpm -qa|grep rsync
rsync-3.0.6-9.el6.x86_64

2、启动,第一次启动须创建/etc/rsyncd.conf 文件,可以为空。

[root@mail home]# /usr/bin/rsync --daemon  --config=/etc/rsyncd/rsyncd.conf  
[root@mail home]# lsof -i :873
COMMAND  PID USER   FD   TYPE  DEVICE SIZE NODE NAME
rsync   4284 root    4u  IPv6 3870571       TCP *:rsync (LISTEN)
rsync   4284 root    5u  IPv4 3870572       TCP *:rsync (LISTEN) 

 

测试

把服务器上的 /home/tomcat/test文件夹中的内容备份到客户端的/home/us中:

[root@mail us]# /usr/bin/rsync -vzrtopg --delete  --progress [email protected]::test /home/us
Welcome the rsync services!

Password: 
receiving incremental file list
deleting DeviceSocket.rar
deleting .bashrc
./
uniguard2012-3-18.dmp
   206544896 100%    5.53MB/s    0:00:35 (xfer#1, to-check=0/2)

sent 77 bytes  received 67008301 bytes  1740477.35 bytes/sec
total size is 206544896  speedup is 3.08

 如果不想输密码,可以创建密码文件/etc/rsync.pass

[root@mail home]# cat /etc/rsyncd.pass 
robbie
[root@mail home]# chmod 600 /etc/rsyncd.pass 
[root@mail home]# /usr/bin/rsync -vzrtopg --delete  --progress [email protected]::test /home/us --password-file=/etc/rsyncd.pass
Welcome the rsync services!


receiving incremental file list

sent 55 bytes  received 163 bytes  436.00 bytes/sec
total size is 206544896  speedup is 947453.65



 

 

你可能感兴趣的:(rhel上配置rsync)