rsync配置

1、通过yum安装

2、确认是否安装了xinetd,未安装,通过yum安装

3、在firewall中开放rsync需要的端口,修改/etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 873 -j ACCEPT  

 4、增加配置文件 /etc/rsyncd.conf

touch /etc/rsyncd.conf
chmod 600 /etc/rsyncd.conf

 5、编辑rsyncd.conf

uid = nobody
gid = nobody
user chroot = no
max connections = 200
timeout = 600
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
motd file = /etc/rsyncd.motd 
log file = /var/log/rsyncd.log
[data]
path = /data
ignore errors
read only = yes
list = no
hosts allow = 10.8.83.0/255.255.255.0 10.8.100.0/255.255.255.0
auth users = rsync
secrets file =/etc/rsyncd.pwd

 6、创建欢迎文件 /etc/rsyncd.motd

touch /etc/rsyncd.motd
chmod 600 /etc/rsyncd.motd

 7、创建密码文件 /etc/rsyncd.pwd

touch /etc/rsyncd.pwd
chmod 600 /etc/rsyncd.pwd

 8、编辑密码文件/etc/rsyncd.pwd

rsync:rsync

 9、编辑启动文件/etc/xinetd.d/rsync中的disable改为no

service rsync
{
        disable = no
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID
}

 10、配置成随系统启动

chkconfig rsync on

 11、启动

service xinetd restart
/etc/rc.d/init.d/xinetd reload

 12、测试是否已经正常启动

netstat -a | grep rsync

 13、直接检查文件

rsync --list-only rsync@10.8.100.100::data

 

客户端使用方法

1、安装,如果不做为服务器,yum安装即可

2、如果不想输入密码,生成密码文件,可任意名 

touch /etc/rsyncd.pwd
chmod 600 /etc/rsyncd.pwd

 3、使用:

#将远程数据拉取回来
rsync -vzrtopg --delete rsync@10.8.100.100::data /data --password-file=/etc/rsyncd.pwd
将本地数据备份至远程rsync Server
rsync -vzrtopg --delete /data rsync@10.8.100.100::data --password-file=/etc/rsyncd.pwd

#--delete表示完全一致,会执行目标文件夹的删除,

 4、使用cron实现定时操作

(1)生成脚本 /usr/backup.sh

touch /usr/backup.sh
chmod /usr/backup.sh

 (2)增加内容

#!/bin/sh
rsync -vzrtopg --delete rsync@10.8.100.100::data /data --password-file=/etc/rsyncd.pwd

 (3)加入至cron

 crontab -e

#添加
* * * * * sh /usr/backup.sh     /*表示每一分钟执行一次/usr/backup.sh文件

 (4)重启cron

/etc/init.d/crond restart

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值