centos7安装rsync及两台机器进行文件同步
Posted wangbaihan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7安装rsync及两台机器进行文件同步相关的知识,希望对你有一定的参考价值。
安装及配置
yum -y install rsync #启动rsync服务 systemctl start rsyncd.service systemctl enable rsyncd.service #检查是否已经成功启动 netstat -lnp|grep 873
服务端配置
# /etc/rsyncd: configuration file for rsync daemon mode # See rsyncd.conf man page for more options. # configuration example: uid = root gid = root port = 873 use chroot = no # read only = no # list = no max connections = 4 # pid file = /var/run/rsyncd.pid exclude = lost+found/ transfer logging = yes timeout = 900 motd file = /etc/rsyncd/rsyncd.motd log file = /var/log/rsyncd.log lock file = /var/run/rsyncd.lock ignore nonreadable = yes dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2 [simba] path = /root/************/ comment=simba ignore errors read only = no write only = no list = no auth users = root secrets file = /etc/rsyncd.pass hosts allow = *
给rsync定义身份,如下:
echo ‘root:123456‘>/etc/rsyncd.passwd //文件用户名和路径为上面定义,别写错,密码自己定 chmod 600 /etc/rsyncd.passwd //修改权限
重启服务
systemctl restart rsyncd.service
客户端配置
创建密码
echo ‘123456‘ >>/etc/rsyncd-test.passwd //注意这里只需要服务器rsyncd.passwd 中的密码 chmod 600 /etc/rsyncd-test.passwd
同步
rsync -auv --password-file=/etc/rsyncd-test.passwd /root/*********/ [email protected]::simba
以上是关于centos7安装rsync及两台机器进行文件同步的主要内容,如果未能解决你的问题,请参考以下文章
CentOS7通过rsync+crontab实现两台服务器文件同步