1) 完成Rsync配置并实现同步机制
2) 安装Lsyncd
[root@node1 ~]# yum --enablerepo=epel install lsyncd -y
3) 配置lsyncd
[root@node1 ~]# vim /etc/lsyncd.conf
# 注释第8行
-- sync{default.rsyncssh, source="/var/www/html", host="localhost", targetdir="/tmp/htmlcopy/"}
......
......
......
......
......
......
# 于文件最底部追加如下内容
settings{
statusFile = "/tmp/lsyncd.stat",
statusInterval = 1,
}
sync{
default.rsync,
# 监控所需要同步的目录
source="/root/test/",
# 同步到指定的FQDN或IP
target="node1.1000cc.net::cloud",
# 指定同步时所需要排除的文件
excludeFrom="/root/rsync-exclude.txt",
}
[root@node1 ~]# systemctl enable --now lsyncd
[root@node1 ~]# touch test/a{6..8}.txt
4) 客户端测试
[root@node5 ~]# /tech/cloud/
├── a1.txt
├── a2.txt
├── a3.txt
├── a4.txt
├── a5.txt
├── a6.txt
├── a7.txt
└── a8.txt
0 directories, 8 files
|