centos7 安装使用rsync
服务端配置
1、环境及相关软件介绍
操作系统:centos7.7.1908
源服务器(推送):192.168.188.201
目标服务器(备份):192.168.188.203
2、rsync安装
yum -y install rsync
配置:
log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid lock file = /var/lock/rsyncd [common] comment = rsync info path = /tmp/test #该路径为需要同步的路径 ignore errors auth users = admin secrets file = /etc/rsyncd.pass hosts allow = 192.168.0.0/16 hosts deny = * list = false port = 873 address = 192.168.188.201 uid = root gid = root use chroot = no read only = no max connections = 10
3、创建认证文件
vi /etc/rsyncd.pass admin:123456 #格式是用户名:密码
授权:
chmod 600 /etc/rsyncd.pass
4、启动rsync
systemctl start rsyncd
客户端配置:
1、安装rsync,客户端安装完毕,不用单独配置
yum -y intall rsync
2、配置秘钥文件
vi /etc/rsync.pass 123456 授权: chmod 600 /etc/rsync.pass
3、同步文件测试
rsync -avz --delete --exclude=ccaaa --password-file=/etc/rsync.pass admin@192.168.188.201::common /tmp/test/ #--exclude=ccaaa 表示不复制ccaaa文件 #--delete 表示服务端、客户端文件完全同步