rsync
Rsync(remote synchronize)是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件,也可以使用 Rsync 同步本地硬盘中的不同目录,也支持增量同步。
1.rsync系环境
rsync服务端:192.168.11.131
rsync客户端:192.168.11.132
2.rsync 安装(服务端和客户端都需要安装)
yum install -y rsync
3.服务端配置
添加如下代码到 /etc/rsyncd.conf
log file = /var/log/rsyncd.log
pidfile = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
secrets file = /etc/rsync.pass
motd file = /etc/rsyncd.Motd
port = 3873
[dbsync]
path = /data/dbsync
comment = dbsync
uid = root
gid = root
use chroot = no
read only = no
list = no
max connections = 200
timeout = 600
auth users = root
密码文件配置并授权
echo "root:Ahjkl0098$"> /etc/rsync.pass
chmod 600 /etc/rsync.pass
启动守护进程
rsync --daemon
netstat -antp |grep 3873
4.客户端配置
主需要配置访问密码即可
echo "Ahjkl0098$"> /root/.rsync_cp.pas
chmod 600 /root/.rsync_cp.pas
5.调试
在客户端拉取服务端/data/dbsync 下的1.txt 文件 到客户端/data/dbsync
rsync -avzP --port=3873 --password-file=/root/.rsync_cp.pas root@192.168.11.131::dbsync/1.txt /data/dbsync
服务端:
客户端: