热门标签 | HotTags
当前位置:  开发笔记 > 运维 > 正文

Rsync安装与配置

系统:Fedora12安装rsync:Yuminstallrsyncvietcxinetd.drsyncdisableno----------changetoyes相关阅读:Debian与Fedora下使用Rsync自动同步工具http:www.linuxidc.comLinux2011-0840819.htm服务端相关配置1.在etc下创建三个文

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

相关阅读:Debian与Fedora下使用Rsync自动同步工具 http://www.linuxidc.com/Linux/2011-08/40819.htm

服务端相关配置
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 test@192.168.0.61::test /var/www/example_com/dl01/pub
crontab crond.rsync
crontab -e编辑现在有crontab
crontab -l
 
完成


推荐阅读
author-avatar
双鱼獒主
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有