sky_cheng

导航

 

一、首先两台服务器做hlim用户的免密ssh登录

su - hlim
ssh-keygen -t rsa
ssh-keygen -t rsa -f /home/hlim/.ssh/id_rsa -P ""

在目标服务器上执行,将另外一台服务器的/home/hlim/.ssh/id_rsa.pub内容复制到/home/hlim/^Csh/authorized_keys中 

su - hlim
vim .ssh/authorized_keys

二、验证免密登录

su - hlim
ssh ip

三、配置lsync服务使用hlim用户运行

vim /usr/lib/systemd/system/lsyncd.service
[Service]
User=hlim
Group=hl95
Type=simple

四、重启服务

ystemctl daemon-reload
systemctl start lsyncd.service

五、如果启动失败,手动执行服务,查看报错信息

su - hlim
[hlim@ecs-szhyypt-itsm-07-0001 ~]$ /usr/bin/lsyncd -nodaemon /etc/lsyncd.conf
11:27:43 Normal: --- Startup ---
Cannot open logfile [/var/log/lsyncd.log]!chmod 777 /var/log/lsyncd.log 
chmod 777 /var/log/lsyncd.status

六、需要手动设置权限

[hlim@ecs-szhyypt-itsm-07-0001 ~]$ /usr/bin/lsyncd -nodaemon /etc/lsyncd.conf
11:28:45 Normal: --- Startup ---
11:28:45 Normal: recursive startup rsync: /home/hlim/imdata/ -> 10.40.131.22:/home/hlim/imdata/ excluding
contmp
log
.gnome2
UnionTech OS Server 20 1050e
sending incremental file list

sent 299 bytes  received 14 bytes  626.00 bytes/sec
total size is 231,618  speedup is 739.99
11:28:45 Normal: Startup of "/home/hlim/imdata/" finished: 0

七、显示同步成功。设置开机自启动

systemctl enable lsyncd

 

posted on 2025-01-02 11:48  sky_cheng  阅读(9)  评论(0编辑  收藏  举报