Chinaunix首页 | 论坛 | 博客
  • 博客访问: 307769
  • 博文数量: 90
  • 博客积分: 2850
  • 博客等级: 少校
  • 技术积分: 951
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-02 14:01
文章分类

全部博文(90)

文章存档

2015年(1)

2014年(1)

2013年(2)

2011年(3)

2010年(83)

分类: LINUX

2010-11-16 17:16:46

Rsync安装与配置
 
系统:Fedora12
安装rsync :Yum install rsync
vi /etc/xinetd.d/rsync
disable         = no  <---------- change to yes

服务端相关配置
1./etc/下创建三个文件
rsyncd.conf     rsyncd.motd     rsyncd.secrets
 
2.配置文件
vi rsyncd.conf
motd file = /etc/rsyncd.motd      #
欢迎文件
read only = no
list = yes
uid = root                         #
可以创建了备份用户,也可用root,默认是nobody
gid = root
Use chroot =no                    #默认是yes(需root运行rsync)额外的安全保护
#hosts allow = 192.168.0.61
#hosts deny =192.168.128.0/24
max connections = 2             
#设置连接数为2, 默认连接数不限制
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
#define dirctory for rsync
[test]                             
#模块:rsync的客户端
#comment = nagios's directory from 192.168.0.61
path =/var/www/example_com/dl01/pub   #欲备份的文档目录
secrets file =/etc/rsyncd.secrets
                 #密码存放文件
auth users = test             
#连接帐号,和系统帐号没关系,服务器必须上存在此账号
read only = no
 
3.欢迎文件
[root@localhost test]# vi /etc/rsyncd.motd
Welcome to use the test rsync services!
 
4.密码文件
[root@localhost test]#vi /etc/rsyncd.secrets
#密码文件权限为600,此步必须设置
test:test
5.chmod 600 /etc/rsyncd.*
6.
运行rsync
rsync --daemon /etc/rsyncd.conf
rsync的路径 rsync配置文件
 
 
客户端相关配置

1.a)
安装rsync ----yum install rsync
  b)
创建密码文件
  [root@localhost ~]#vi /etc/rsyncd.secrets 
  test#
客户端只需密码无须用户
注:此处密码一定要与rsync服务器端密码文件中密码保持一致,并且应为rsync客户端密码。
  c)chmod 600 /etc/rsyncd.secrets ----
修改权限
如果没有这步会报如下:
password file must not be other-accessible
continuing without password file
Password:


2.同步连接测试
[root@mail pub]# rsync -vzrtopg --progress --delete --password-file=/etc/rsyncd.secrets test@192.168.0.61::test /var/www/example_com/dl01/pub/
receiving incremental file list
./
test.txt
           0 100%    0.00kB/s    0:00:00 (xfer#1, to-check=0/2)
 
sent 78 bytes  received 150 bytes  152.00 bytes/sec
total size is 0  speedup is 0.00
[root@mail pub]# ls
test.txt

测试成功

3.
实现定时同步,假设凌晨2两同步

vim crond.rsync
00 2 * * * rsync -vzrtopg --progress --delete --password-file=/etc/rsyncd.secrets
/var/www/example_com/dl01/pub
crontab crond.rsync
crontab -e
编辑现在有crontab
crontab -l
 
 
完成
阅读(926) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~