rsync 文件同步
A:192.168.137.128
B:192.168.137.129
(A,B 都已经部署rsync)
/etc/rsyncd.conf
[root@localhost data]# cat /etc/rsyncd.conf
uid=root
gid=root
use chroot=no
max connections=10
strict modes=yes
port=873
address=192.168.137.129(主机IP)
read only=no
list=no
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsync.lock
log file=/var/log/rsyncd.log
[case] (moduble)
path = /opt/data
comment = ucweb-file
1.创建文件
[root@localhost data]# >1.txt
[root@localhost data]# >2.txt
[root@localhost data]# >3.txt
[root@localhost data]#
[root@localhost data]# ls
1.txt 2.txt 3.txt
2.同步全部文件(注意:case,是在128的rsyncd.conf中配置的module)
[root@localhost data]# rsync -auvz /opt/data root@192.168.137.128::case
sending incremental file list
data/
data/1.txt
data/2.txt
data/3.txt
sent 190 bytes received 69 bytes 518.00 bytes/sec
total size is 0 speedup is 0.00
3.同步修改后的文件
[root@localhost data]# vi 1.txt
[root@localhost data]# rsync -auvz /opt/data root@192.168.137.128::case
sending incremental file list
data/
data/1.txt
sent 132 bytes received 31 bytes 326.00 bytes/sec
total size is 6 speedup is 0.04
结论:适合同步小文件,因为每次同步都会对比文件内容,遇到大文件的时候性能可能会降低(未测)
一般与inotify-tools配合使用效果更佳 。