Ubuntu/FreeBSD下rsync同步镜像服务器配置教程

Linux大全评论1.1K views阅读模式

主服务器:192.168.1.2 (Linux Ubuntu 2.6.27-7-server)
从服务器:192.168.1.3 (FreeBSD 8.0-RELEASE-p2)

============================== 1> 在两台主机上分别安装rsync ==============================

Ubuntu安装如下:

  1. roger#apt-get install rsync

正常情况很快就安装完毕,rsync 服务器架设比较简单,可我们安装好rsync后,并没有发现配置文件以及rsync服
务器启动程序,因为每个管理员可能对rsync 用途不一样,所以一般的发行版只是安装好软件就完事了,让管理员来根据自己的用途和方向来自己架设rsync服务器。

============================== 2> rsync服务器的配置 ==============================

在/etc目录下创建一个rsyncd的目录,我们用来存放rsyncd.conf,rsyncd.secrets和rsyncd.motd文件;
rsyncd.conf 是rsync服务器的主配置文件;
rsyncd.secrets是用户密码文件;
rsyncd.motd配置一些服务欢迎及说明信息;

a>创建修改 rsyncd.conf
rsyncd.conf 是rsync服务器主要配置文件,我们来个简单的示例;比如我们要备份服务器上的 /tmp/目录 ,在/tmp/ 中,我想把test目录和test.php文件排除在外;

  1. roger#cd /etc
  2. roger#mkdir rsyncd
  3. roger#cd rsyncd
  4. roger#vim rsyncd.conf

写入(保证文件中每行没有空格):

下载rsync.conf

  1. pid file = /var/run/rsyncd.pid 
  2. port = 873
  3. address = 192.168.1.2
  4. #uid = nobody
  5. #gid = nobody  
  6. uid = root 
  7. gid = root 
  8.  
  9. use chroot = yes 
  10. read only = yes 
  11.  
  12.  
  13. #limit access to private LANs
  14. #设置可访问的主机:如果多个ip则用空格隔开:192.168.1.3 192.168.1.4 192.168.1.5或者设置区间 192.168.1.3/5
  15. hosts allow=192.168.1.3
  16. hosts deny=*
  17.  
  18. max connections = 5
  19. motd file = /etc/rsyncd/rsyncd.motd
  20.  
  21. #This will give you a separate log file
  22. log file = /var/log/rsync.log
  23.  
  24. #This will log every file transferred - up to 85,000+ per user, per sync
  25. transfer logging = yes
  26.  
  27. log format = %t %a %m %f %b
  28. syslog facility = local3
  29. timeout = 300
  30. #方括号中设置模块名
  31. [linuxsirhome]
  32. #要同步服务器的目录路径
  33. path = /data/www/yy
  34. list=yes
  35. ignore errors
  36. #auth users是必须在服务器上存在的真实的系统用户,如果你想用多个用户,那就以,号隔开;比如 auth users = roger,linuxsir
  37. auth users = roger
  38. #从服务器访问需要的密码文件
  39. secrets file = /etc/rsyncd/rsyncd.secrets 
  40. comment = linuxsir tmp 
  41. #设置不同步的目录或文件用空格隔开
  42. exclude = test/ test.php

b> 创建修改密码文件rsyncd.secrets

  1. roger#cd /etc/rsyncd
  2. roger#vim rsyncd.secrets

写入:

  1. roger:1q2w3e
  1. roger#chmod 600 rsyncd.secrets

企鹅博客
  • 本文由 发表于 2020年7月13日 06:32:20
  • 转载请务必保留本文链接:https://www.qieseo.com/139925.html

发表评论