rsync使用说明

需求:把10.5.128.190数据同步到10.5.128.27

用客服端-服务器模式,需要从客户端发起 也就是从10.5.128.27发起

10.5.128.27 作为客户端

10.5.128.190 作为服务端




1. 服务端取得rsync程序文件,一般放到/usr/bin
ftp中转机 rsync目录有

2 .配置服务端
   配置文件
   用户及密码文件

配置文件/etc/rsyncd.conf(默认无此文件)

use chroot = false
strict modes = false
hosts allow = *
log file = /app/rsync/rsyncd.log
lock file = /app/rsync/rsyncd.lock

# Module definitions
#
[hdarun_app_hdarun]
max connections = 5
uid = root
gid = system
use chroot = no
###服务器需要同步的目录
path = /app/hdarun/test
ignore errors = yes
read only = yes
write only = no
hosts allow = *
hosts deny = 192.168.1.112
comment = rsync files
list = yes
auth users = cnaps2
secrets file = /app/rsync/rsyncd.scrt 
transfer logging = yes



用户及密码文件 /app/rsync/rsyncd.scrt
username:password
cnaps2:xxxxxx



3启动服务端 rsync --daemon 



4查看服务端
# rsync rsync://10.5.128.190
hdarun_app_hdarun       rsync files



5客户端同步(也要先取得rsync执行程序,注意密码文件/etc/rsyncd_cli.scrt 应chmod 600 /etc/rsyncd_cli.scrt,里面只写密码)


ftp中转机 根目录有rsyncx文件
------------------------------
客户端执行
rsync -vzrtopg --progress cnaps2@10.5.128.190::hdarun_app_hdarun /app/hdarun/test --password-file /etc/rsyncd_cli.scrt 


如果加--delete 服务端删除,客户端也会删。


错误:
# rsync -vzrtopg --progress cnaps2@10.5.128.190::hdarun_app_hdarun /app/hdarun/test --password-file /etc/rsyncd_cli.scrt
@ERROR: auth failed on module hdarun_app_hdarun
rsync error: error starting client-server protocol (code 5) at main.c(1516) [Receiver=3.0.9]

hdarun_app_hdarun:远程rsync服务模块名称

服务端和客户端的账户密码文件权限必须600


客户端上/etc/rsyncd_cli.scrt只写密码,不用写对应用户
xxxxxx









 



                                    
原文地址:https://www.cnblogs.com/hzcya1995/p/13352433.html