发送端配置:
一、配置密钥
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
******