使用xinetd来配置rsync服务器

保证一个机器的文件内容与主服务器内目录的文件内容自动同步

  1. 安装(xinetd 与rsync)
  2. chkconfig rsync on 与 service xinetd restart
  3. 配置文件 rsyncd.conf

配置文件 rsyncd.conf 默认在 /etc 目录下。为了将所有与 rsync 服务相关的文件放在单独的目录下,可以执行如下命令:
mkdir /etc/rsyncd
touch /etc/rsyncd/rsyncd.conf
ln -s /etc/rsyncd/rsyncd.conf /etc/rsyncd.conf

4.编辑vi /etc/rsyncd/rsyncd.conf

# Minimal configuration file for rsync daemon
# See rsync(1) and rsyncd.conf(5) man pages for help

# This line is required by the /etc/init.d/rsyncd script
# GLOBAL OPTIONS
uid = root                         
gid = root                                  

use chroot = no                             

read only = yes                            

#limit access to private LANs
hosts allow=172.16.0.0/255.255.0.0 192.168.1.0/255.255.255.0 10.0.1.0/255.255.255.0
hosts deny=*                                
max connections = 5                      

pid file = /var/run/rsyncd.pid             

secrets file = /etc/rsyncd/rsyncd.secrets   
#lock file = /var/run/rsync.lock           

motd file = /etc/rsyncd/rsyncd.motd        

#This will give you a separate log file
log file = /var/log/rsync.log               

#This will log every file transferred - up to 85,000+ per user, per sync
transfer logging = yes                    

log format = %t %a %m %f %b
syslog facility = local3
timeout = 300

# MODULE OPTIONS
[davidhome]                               
path = /alidata/www/client                       
list=yes                                   
ignore errors                              
auth users = david                          
comment = David home                  
exclude = important/ 

编辑hosts allow保证可以同步
编辑MODULE OPTIONS 确认同步目录正确

5.修改rsyncd.secrets文件
里面添加用户名密码

6.客户端使用方式
sudo rsync -avzP –delete david@ip::davidhome /var/www/client

还可以增加参数
–password-file=/tmp/rsync.password

# touch /tmp/rsync.password
# chmod 600 /tmp/rsync.password
# echo "asdf"> /tmp/rsync.password
# rsync -avzP  --delete  --password-file=/tmp/rsync.password  david@172.16.1.135::davidhome  /tmp/david/

可能会考虑rsync.password文件的所有者

7.设定定时任务
crontab -e

30 * * * * (sudo rsync -avzP –delete –password-file=/tmp/rsync.password david@120.26.113.130::davidhome /var/www/client)

半个小时执行一次

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hassen2010

你的鼓励我能输出跟多的好文章

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值