本文默认服务器已经安装了 rsync !

本文默认服务器已经安装了 rsync !

本文默认服务器已经安装了 rsync !

切换到 /etc目录,默认情况下,rsyncd.conf 文件如下:

# /etc/rsyncd: configuration file for rsync daemon mode

# See rsyncd.conf man page for more options.

# configuration example:

# uid = nobody
# gid = nobody
# use chroot = yes
# max connections =
# pid file = /var/run/rsyncd.pid
# exclude = lost+found/
# transfer logging = yes
# timeout =
# ignore nonreadable = yes
# dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2 # [ftp]
# path = /home/ftp
# comment = ftp export area

1、配置 rsyncd.conf

参考模板:

# Minimal configuration file for rsync daemon
# See rsync() and rsyncd.conf() man pages for help # This line is required by the /etc/init.d/rsyncd script
# GLOBAL OPTIONS
uid = root
gid = root use chroot = no read only = no #limit access to private LANs
#hosts allow=
#hosts deny=*
max connections = pid file = /var/run/rsyncd.pid secrets file = /etc/rsyncd/rsyncd.secrets
lock file = /var/run/rsync.lock #motd file = /etc/rsyncd/rsyncd.motd #This will give you a separate log file
log file = /var/log/rsync.log #This will log every file transferred - up to ,+ per user, per sync
#transfer logging = yes log format = %t %a %m %f %b
syslog facility = local3
timeout = # MODULE OPTIONS [www]
path = /www/
list=yes
ignore errors
auth users = test
comment = test

2、配置完成之后要启动 rsync;如果已经重启的话,杀掉进程后再启动,运行:ps -aux | grep rsync,找到进程号,kill [进程号]

启动命令:

/usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf

3、rsyncd.conf 配置项说明

######### 全局配置参数 ##########
port= # 指定rsync端口。默认873
uid = rsync # rsync服务的运行用户,默认是nobody,文件传输成功后属主将是这个uid
gid = rsync # rsync服务的运行组,默认是nobody,文件传输成功后属组将是这个gid
use chroot = no # rsync daemon在传输前是否切换到指定的path目录下,并将其监禁在内
max connections = # 指定最大连接数量,0表示没有限制
timeout = # 确保rsync服务器不会永远等待一个崩溃的客户端,0表示永远等待
motd file = /var/rsyncd/rsync.motd # 客户端连接过来显示的消息
pid file = /var/run/rsyncd.pid # 指定rsync daemon的pid文件
lock file = /var/run/rsync.lock # 指定锁文件
log file = /var/log/rsyncd.log # 指定rsync的日志文件,而不把日志发送给syslog
dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2 # 指定哪些文件不用进行压缩传输 ###########下面指定模块,并设定模块配置参数,可以创建多个模块###########
[www] # 模块ID
path = /www/ # 指定该模块的路径,该参数必须指定。启动rsync服务前该目录必须存在。rsync请求访问模块本质就是访问该路径。
ignore errors # 忽略某些IO错误信息
read only = false # 指定该模块是否可读写,即能否上传文件,false表示可读写,true表示可读不可写。所有模块默认不可上传
write only = false # 指定该模式是否支持下载,设置为true表示客户端不能下载。所有模块默认可下载
list = false # 客户端请求显示模块列表时,该模块是否显示出来,设置为false则该模块为隐藏模块。默认true
hosts allow = 10.0.0.0/ # 指定允许连接到该模块的机器,多个ip用空格隔开或者设置区间
hosts deny = 0.0.0.0/ # 指定不允许连接到该模块的机器
auth users = rsync_backup # 指定连接到该模块的用户列表,只有列表里的用户才能连接到模块,用户名和对应密码保存在secrts file中,
# 这里使用的不是系统用户,而是虚拟用户。不设置时,默认所有用户都能连接,但使用的是匿名连接
secrets file = /etc/rsyncd.passwd # 保存auth users用户列表的用户名和密码,每行包含一个username:passwd。由于"strict modes"
# 默认为true,所以此文件要求非rsync daemon用户不可读写。只有启用了auth users该选项才有效。
[test] # 以下定义的是第二个模块
path=/test/
read only = false
ignore errors
comment = anyone can access

4、rsyncd.secrets 权限配置,如果这个文件的权限给太高的话,可能无法正常启动,给“只读”权限就行

chmod  rsyncd.secrets

5、查看 rsync 是否正常运行以及网络状态

ps -ef | grep rsync  #查看进程
netstat -lntup | grep rsync #查看网络状态

6、检查ECS服务器是否开发对应的端口,在服务器管理界面找到 “本实例安全组” -> "内网入方向全部规则",查看对应的 rsync 端口有没有开放,没有的话添加即可;在 “安全组列表” 的列表中选择你对应的安全组ID找到 “配置规则”,点进去,把你的 rsync 端口配置到 “入规则” 中

7、测试

rsync -avr composer.json rsync://www@[host]/www/

rsync -avr --delete --progress --password-file=rsyncd.secrets ./ --exclude '*.log' rsync://www@[host]/www/

参考:
https://blog.csdn.net/jsd2honey/article/details/78731637
https://www.cnblogs.com/zhangsubai/p/5194490.html
https://www.cnblogs.com/wang-xd/p/6551402.html

rsync配置教程的更多相关文章

  1. Linux的rsync 配置,用于服务器之间远程传大量的数据

    [教程主题]:rsync [课程录制]: 创E [主要内容] [1] rsync介绍 Rsync(Remote Synchronize) 是一个远程资料同步工具,可通过LAN/WAN快速同步多台主机, ...

  2. Linux rsync配置用于服务器之间传输大量的数据

    Linux的rsync 配置,用于服务器之间远程传大量的数据   [教程主题]:rsync [课程录制]: 创E [主要内容] [1] rsync介绍 Rsync(Remote Synchronize ...

  3. openvpn配置教程

    openvpn配置教程 本文是为解决本地服器能从外网访问web页,从新改写(临摹) 烂泥:ubuntu 14.04搭建OpenVPN服务器这篇文章 腾讯云为服务器,本地服务器为客户端 一.服务器安装o ...

  4. VMware Workstation虚拟机中的Linux通过NAT模式共享上网配置教程

    VMware Workstation虚拟机中的Linux通过NAT模式共享上网配置教程 在VMware Workstation虚拟机下面,Linux虚机要上网,一般是桥接模式,但我自己的电脑上网的环境 ...

  5. 百度在线编辑器UEditor(v1.3.6) .net环境下详细配置教程之更改图片和附件上传路径

    本文是接上一篇博客,如果有疑问请先阅读上一篇:百度在线编辑器UEditor(v1.3.6) .net环境下详细配置教程 默认UEditor上传图片的路径是,编辑器包目录里面的net目录下 下面就演示如 ...

  6. 百度在线编辑器UEditor(v1.3.6) .net环境下详细配置教程

    UEditor是百度开发团队奉献的一款很不错的在线编辑器.在百度自己很多产品上都有应用,本文主要是该编辑器的配置教程. 1.下载UEditor,当前最新版本是1.3.6.这里下载的.net版本,选择U ...

  7. OpenGL 4.3配置教程

    OpenGL 4.3配置教程 下载开发包 需要下载的开发包主要包含如下几个组件:freeglut+glew+ OpenGL.Development.Cookbook+源码+GLM+SOIL. Open ...

  8. Hadoop集群安装配置教程_Hadoop2.6.0_Ubuntu/CentOS

    摘自:http://www.powerxing.com/install-hadoop-cluster/ 本教程讲述如何配置 Hadoop 集群,默认读者已经掌握了 Hadoop 的单机伪分布式配置,否 ...

  9. PHP调试工具Xdebug安装配置教程

    说道PHP代码调试,对于有经验的PHPer,通过echo.print_r.var_dump函数,或PHP开发工具zend studio.editplus可解决大部分问题,但是对于PHP入门学习的童鞋来 ...

随机推荐

  1. 【LeetCode】动态规划(下篇共39题)

    [600] Non-negative Integers without Consecutive Ones [629] K Inverse Pairs Array [638] Shopping Offe ...

  2. 牛客ACM赛 C 区区区间间间

    链接 C 区区区间间间 给定长度为\(n\)序列,求\[\sum_{i=1}^{n} \sum_{j=i}^{n} max-min\] 其中\(max\),\(min\)为区间最大,最小值,\(n\l ...

  3. git log的个性化设置

    --date=(relative|local|default|iso|rfc|short|raw) Only takes effect for dates shown in human-readabl ...

  4. 配置Android Studio

    1.去gradle官网下载gradle,gradle的版本可以在C:\Program Files\Android\Android Studio\gradle下看到 2.新建一个项目,退出后把下载好的g ...

  5. Seek the Name, Seek the Fame (poj2752

    Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 14561   Ac ...

  6. pl/sql中return和exit区别

    经测试: 1.exit只能用于循环中,并且退出循环往下执行: 2.return可用于循环或非循环,并且退出整个程序模块不往下执行. declare i number :=1; j number :=1 ...

  7. 专人写接口+模型,专人写业务逻辑---interface_model -- business logical

    专人写接口+模型,专人写业务逻辑---interface_model -- business logical 0-控制台脚本重构为“面向接口编程”:1-仓库类通过__constru方法,来实现一处实例 ...

  8. git subtree模块化代码管理

    Git Subtree 的原理 首先,你有两个伟大的项目——我们叫他P1项目.P2项目,还有一个牛逼的要被多个项目共用的项目——我们叫他S项目.我们通过简要讲解使用Subtree来同步代码的过程来解释 ...

  9. tr:hover变色的问题

    做表格隔行变色(高亮显示),可以通过设置css中的 tr:hover伪类属性达到效果, 但是,会出一点小问题.td的背景色会覆盖tr的背景色, 在tr:hover下边加上一句:tr:hover td{ ...

  10. StringOfChar 将一个字符重复多次 形成一个 字符串

    StringOfChar Returns a string with a specified number of repeating characters. In Delphi code, Strin ...