Ubuntu Server 安装与配置 rsync 作者: 萧禹 时间: 2017-02-06 分类: 其他 访问: 1,345 次 简介: 介绍 rsync 的使用和配置. 环境: OS: Ubuntu Server 16.04 rsync: 3.1.1 Server 修改启动方式 Ubuntu Server 自带了 rsync, 但 rsync 服务默认不启动的, 首先修改配置: $sudo nano /etc/default/rsync ``` # start rsync in daemon mode from init.d script? # only allowed values are "true", "false", and "inetd" # Use "inetd" if you want to start the rsyncd from inetd, # all this does is prevent the init.d script from printing a message # about not starting rsyncd (you still need to modify inetd's config yourself). RSYNC_ENABLE=true #false改true ``` rsync 有两种启动方式 当rsync服务器负载比较高时,则使用 daemon 独立启动模式节省资源 当rsync服务器负载较低时,可使用xinetd运行方式 创建配置文件 $sudo cp /usr/share/doc/rsync/examples/rsyncd.conf /etc #复制示例配置 $sudo nano /etc/rsyncd.conf #官方手册 注意配置文件中的红色为不可少的 ``` # sample rsyncd.conf configuration file # GLOBAL OPTIONS #motd file=/etc/motd #log file=/var/log/rsyncd # for pid file, do not use /var/run/rsync.pid if # you are going to run rsync out of the init.d script. # The init.d script does its own pid file handling, # so omit the "pid file" line completely in that case. #pid file=/var/run/rsyncd.pid #syslog facility=daemon #socket options= # MODULE OPTIONS [test] #模块名称 comment = public archive path = /home/sxsfeq/download/test use chroot = yes # max connections=10 lock file = /var/lock/rsyncd # the default for read only is yes... read only = yes list = yes uid = nobody #与下方gid代表用 nobody 读取上方 path 的目录, 如果此处用户名不正确可能无法读取 path 的内容 gid = nogroup # # exclude = # exclude from = # include = # include from = auth users = mytest secrets file = /etc/rsyncd.secrets strict modes = yes #如果出现客户端 "@ERROR: auth failed on module xxx" 可尝试改为 no, 该值在 windows 下有意义(见rsyncd.conf官方手册) # hosts allow = # hosts deny = ignore errors = no ignore nonreadable = yes transfer logging = no # log format = %t: host %h (%a) %o %f (%l bytes). Total %b bytes. timeout = 600 refuse options = checksum dry-run dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz ``` 创建密码文件 $sudo nano /etc/rsyncd.secrets mytest:mytest #用户名:密码 $sudo chmod 655 /etc/rsyncd.secrets 启动和停止服务 sudo /etc/init.d/rsync start #启动 sudo /etc/init.d/rsync stop #停止 Client $rsync -avP mytest@192.168.2.97::ftp . #"."代表当前目录 $PASSWORD: #输入在服务器上 /etc/rsyncd.secrets 里的密码 ### 参考: - Ubuntu下 rsync同步文件实例 rsync配置实例 (包括问题解决方案) ### 问题集锦: - Rsync ERROR: auth failed on module解决方法 标签: none 文章版权:萧禹的博客 - 这个人很懒, 什么都没写 本文链接:https://www.flysfeq.site/index.php/archives/81/ 转载请注明文章原始出处 !