rsync搭建

环境:

系统版本:CentOS6.5
软件版本:rsync-3.0.6-9.el6_4.1.x86_64
xinetd-2.3.14-39.el6_4.x86_64
yun源:CentOS6.5光盘源
A主机:192.168.10.5(服务端)
B主机:192.168.10.6(客户端)

服务端配置:

  1. yum安装rsync、xinetd:
yum -y install rsync
yum -y install xinetd
  1. 更改xinetd下rsync配置文件,将 disable 改为 no:
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
#       allows crc checksumming etc.
service rsync
{
        disable = no
        flags           = IPv6
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID
}
  1. 启动xinetd:
service xinetd start
  1. 添加rsync配置文件,rsync的配置文件是手动创建:
vi /etc/rsyncd.conf
uid = nobody	# 进行备份的用户 nobody 是所有用户
gid = nobody	# 进行备份的组 nobody 是所有组
user chroot = no  # 如果"use chroot"指定为true,那么rsync在传输文件以前首先chroot到path参数所指定的目录下。这样做的原因是实现额外的安全防护,但是缺点是需要以root权限,并且不能备份指向外部的符号连接所指向的目录文件。默认情况下
chroot值为true.但是这个一般不需要。
max connections = 200  # 最大连接数
timeout = 600  # 覆盖客户指定的IP超时时间,也就是说rsync服务器不会永远等待
一个崩溃的客户端。
pid file = /var/run/rsyncd.pid  # pid文件的存放位置
lock file = /var/run/rsyncd.lock   # 锁文件的存放位置
log file = /var/log/rsyncd.log  # 日志文件的存放位置

[backup]   # 这里是认证模块名,即跟samba语法一样,是对外公布的名字
path=/rsync/backup/  # 备份到本地的目录
ignore errors  # 可以忽略一些无关的IO错误
read only = no # 允许可读可写
list = no  # 不允许列清单
hosts allow = 192.168.0.0/255.255.255.0   # 指定IP或一整个网段
auth users = test  # 认证的用户名
secrets file = /etc/rsyncd.password  # 密码文件存放地址
  1. 创建密码文件rsyncd.password:
vi /etc/rsyncd.password
test:test
chmod 600 /etc/rsyncd.password
  1. 创建test本地用户,如果没有无法实现同步:
useradd test
passwd test # 密码 123456,密码必须要rsyncd.passwd中的密码区分
  1. 本地创建同步目录:
mkdir -p /rsync/backup
chmod -R 777 /rsync/backup
  1. 重启xinetd服务:
service xinetd restart

客户端配置:

  1. yum安装rsync、xinetd服务:
yum -y install rsync
yum -y install xinetd
  1. 客户端添加密码文件 rsyncd.password:
vi /etc/rsyncd.password
test  # 这里仅仅只需要密码,不需要用户了。
chmod 600 /etc/rsyncd.password

测试

  1. 从服务器上下载文件:
rsync -avz --password-file=/etc/rsyncd.password test@192.168.10.6::backup /home/1.txt
  1. 从本地上传到服务器上去:
rsync -avz --password-file=/etc/rsyncd.password /home/1.txt test@192.168.10.5::backup
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值