配置rsync同步

一、rsync接收端安装240

1、查看rsync安装包

# rpm -qa rsync

2、安装rsync

# yum install rsync -y

3、添加rsync服务的用户,管理本地目录的

# useradd -s /sbin/nologin -M rsync

# id rsync

4、生成rsyncd.conf配置文件

# cat /etc/rsyncd.conf

[backup]

uid = root

gid = root

use chroot = no

max connections = 400

strict modes = yes

port = 873

commet = This is MySQL Backup Data

ignore errors

read only = no

list = no

auth users =root

secrets file = /etc/rsync.pas

hosts allow = 192.168.1.0/24

hosts deny =0.0.0.0/0

pid file = /var/run/rsyncd.pid

lock file =/var/run/rsync.lock

log file = /var/log/rsyncd.log

path = /data/backup

5、根据rsyncd.conf的auth users配置帐户,远程连接的,并根据secrets file 参数生成密码文件。

vim /etc/rsync.pas

6、为密码文件配置权限

# chmod 600 /etc/rsync.password

7、创建共享目录并授权rsync服务管理

# mkdir /data/backup -p

# chown -R rsync.rsync /data/backup

8、启动rsync服务并检查

# rsync --daemon

# ps -ef | grep rsync

# lsof -i:873

9、加入开机自启动

# echo "/usr/bin/rsync --daemon" >> /etc/rc.local

# tail -1 /etc/rc.local

 

二、rsync 发送端241

1、查看rsync安装包

# rpm -qa rsync

2、安装rsync

系统默认都会安装rsync软件包的,如果查看发现没有安装,执行yum安装即可

# yum install rsync -y

3、添加rsync服务的用户,管理本地目录的

# useradd -s /sbin/nologin -M rsync

# id rsync

4、生成连接服务器需要的密码文件

vim /etc/rsync.pas

5、为密码文件配置权限

# chmod 600 /etc/rsync.password

# ls -1 /etc/rsync.password

6、同步文件语法

基于rsync daemon同步语法:

拉取: rsync [OPTION...] [USER@]HOST::SRC... [DEST] rsync [OPTION...] rsync://[USER@]HOST[:PORT]/SRC... [DEST]

推送: rsync [OPTION...] SRC... [USER@]HOST::DEST rsync [OPTION...] SRC...

7、测试手动推送是否正常

rsync -avz /data/backup/ root@192.168.1.240::backup --password-file=/etc/rsync.pas

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

有人拉屋米

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值