發送端配置:
一、配置密鑰
1. 主/從服務器之間啟用基於密鑰的身份驗證。登錄發送端服務器並用 " ssh-keygen " 命令生成公共或私有的密鑰。
2. 使用 " ssh-copy-id " 復制密鑰文件到接收端服務器。
ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.16.144
二、安裝rsync + lsyncd
1. 安裝rsync
yum -y install rsync
2. 安裝Lsyncd
1. 安裝lsyncd依賴包
yum install lua lua-devel pkgconfig gcc asciidoc
2. 安裝lsyncd rpm資源,並安裝lsyncd
rpm -iUvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
yum install lsyncd
三、配置lsyncd
1. 復制lsyncd配置文件
cp /usr/share/doc/lsyncd-2.1.5/examples/lrsync.lua /etc/lsyncd.conf
2. 編輯lsyncd配置文件
vi /etc/lsyncd.conf
----
-- User configuration file for lsyncd. --
-- Simple example for default rsync. -- settings { logfile ="/var/log/lsyncd.log", statusFile = "/tmp/lsyncd.stat", statusInterval = 1, } sync { default.rsync, source="/usr/blues/", target="192.168.16.144::backup", rsync = { rsh ="/usr/bin/ssh -l root -i /root/.ssh/id_rsa", binary = "/usr/bin/rsync", archive = true, compress = true, verbose = true } }
四、啟動服務,並設置開機啟動
1. 啟動lsyncd服務
systemctl start lsyncd
2. 啟動完成查看lsyncd狀態,確保lsync啟動成功
systemctl status lsyncd
3. 設置開機啟動
systemctl enable lsyncd
******