Linux rsync 配置具体实现说明)
- 格式:docx
- 大小:1.22 MB
- 文档页数:5
对于选择linux 作为应用平台的的中小型企业或网站来说,往往面临如何实现数据远程备份或者网站镜象的问题,虽然有商业化的备份和镜象产品可供选择。
1,首先SERVER与CLIENT都需要安装RSYNC
2,其次在SERVER的/etc/下面建立rsyncd.conf内容可以按照下面的写法
[root@vm-base-01local]#more/etc/rsyncd.conf uid=root///RSYNC启动ID gid=root usechroot=no logfile=/var/log/rsyncd.log////日志存放pidfile=/var/run/rsyncd.pid lockfile=/var/run/rsync.lock [publishonline]///模块名称---也就一个需要同步或备份的目录path=/usr/local/apache/htdocs/publish/online/images comment=homecadfolder ignoreerrors readonly=yes list=no authusers=xp20adm////登录用户名--自我随意设置secretsfile=/etc/rsyncd.scrt////密码存放文件----一般需要自我建立此文件,路经与命名随意[publishdown] path=/usr/local/apache/htdocs/publish/down/images comment=homecadfolder ignoreerrors readonly=yes list=no authusers=xp20adm secretsfile=/etc/rsyncd.scrt [magdown] path=/usr/local/apache/htdocs/publish/down comment=homecadfolder ignoreerrors readonly=yes list=no authusers=xp20adm secretsfile=/etc/rsyncd.scrt 3,SERVER就基本配置好了,自己不要忘记配置模块中制定的目录与密码存放点//////////////////////////////注意////////////////////////////////////
bash-2.03#cat/etc/rsyncd.scrt
密码格式如下
用户名:密码(有个冒号哟)
!!!!!!!!出于安全目的,文件的属性必需是只有属主可读(不能错)!!!!!!!!!!!!!!!!!chmod400
4,然后就可以启动SERVER端的RSYNC程序了,如果上述配置不正确,rsync是无法正常启动的
启动方案
在server端将rsync以守护进程形式启动
bash-2.03#rsync--daemon
如果要在启动时把服务起来,有几种不同的方法,比如:
a、加入inetd.conf
编辑/etc/services,加入rsync873/tcp,指定rsync的服务端口是873
编加/etc/inetd.conf,加入rsyncstreamtcpnowaitroot/bin/rsyncrsync--daemon
b、加入rc.local
在各种操作系统中,rc文件存放位置不尽相同,可以修改使系统启动时rsync--daemon加载进去。
5CLIENT设置
如果CLIENT想不输入RSYNC的密码而自动同步的话,可以设置一个秘密文件:可以用
--password-file=/password/path/file来指定密码文件,这样就可以在脚本中使用而无需交互式地输入验证密码了,这里需要注意的是这份密码文件权限属性要设得只有属主可读。
下面这个命令行中-vzrtopg里的v是verbose,z是压缩,r是recursive,topg都是保持文件原有属性如属主、时间的参数。
--progress是指显示出详细的进度情况,--delete是指如果服务器端删除了这一文件,那么客户端也相应把文件删除,保持真正的一致。
后面的inburst@ip 中,inburst是指定密码文件中的用户名,之后的::inburst这一inburst是模块名,也就是在/etc/rsyncd.conf中自定义的名称。
最后的/tmp是备份到本地的目录名。
举例CLIENT
如:rsync-vzrtopg--progress--deleteinburst@192.168.*.*::inburst--exclude="*.sh"--exclude="images* "--exclude="*.log"
--password-file=/etc/rsync.pas/home/quack/backup/
这个例子基本包含所有应用
参数说明
-vzrtopg里的
v是verbose,
z是压缩,
r是recursive,
topg都是保持文件原有属性如属主、时间的参数
----progress
是指显示出详细的进度情况
--delete
是指如果服务器端删除了这一文件,那么客户端也相应把文件删除,保持真正的一致inburst@192.168.168.52::inburst
用户名模块名
--exclude="*.sh"
不包含某些文件
--password-file
指定CLIENT端密码文件存放路径/home/quack/backup/
指定CLIENT端存放镜象目的路径
EXAMPLES
A simple rsyncd.conf file that allow anonymous rsync to a ftp area at /home/ftp would be:
[ftp]
path = /home/ftp
comment = ftp export area
A more sophisticated example would be:
uid = nobody
gid = nobody
use chroot = yes
max connections = 4
syslog facility = local5
pid file = /var/run/rsyncd.pid
[ftp]
path = /var/ftp/./pub
comment = whole ftp area (approx 6.1 GB)
[sambaftp]
path = /var/ftp/./pub/samba
comment = Samba ftp area (approx 300 MB)
[rsyncftp]
path = /var/ftp/./pub/rsync
comment = rsync ftp area (approx 6 MB)
[sambawww]
path = /public_html/samba
comment = Samba WWW pages (approx 240 MB)
[cvs]
path = /data/cvs
comment = CVS repository (requires authentication)
auth users = tridge, susan
secrets file = /etc/rsyncd.secrets
The /etc/rsyncd.secrets file would look something like this:
tridge:mypass
susan:herpass
FILES
/etc/rsyncd.conf or rsyncd.conf
SEE ALSO
rsync(1)。