SUSE Linux Rsync+inotify精准系统同步配置实战

发布于:2024-05-06 ⋅ 阅读:(39) ⋅ 点赞:(0)

配置不难,也可以说难,这完全取决于需求。
一.服务器状况:
NFS文件服务器,存储提交的附件和图片。希望搭建一个在线的备份文件服务器,实现主服务和备份服务器之间的文件的实时同步。
Filesserver:/tmp # lsb_release -a
LSB Version:    n/a
Distributor ID:    SUSE
Description:    SUSE Linux Enterprise Server 12 SP3
Release:    12.3
Codename:    n/a

Filesserver:/tmp # chkconfig --list |grep rsync
Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'. To see services enabled on particular target use 'systemctl list-dependencies [target]'.
rsync                     0:off  1:off  2:off  3:off  4:off  5:off  6:off
        rsync:              off
可以看到,服务器已经有了rsync组件。

主服务器上存放附件和图片的目录:为/u01/Files_documents
备份服务器上的备份路径设置相同。

二.rsync的基本语法参数
本地复制:rsync -a /原文件夹  /目标文件夹
远程复制:rsync -av /源文件夹 root@ip:/目标文件夹
常用参数:
-v 显示过程详细信息
-P 显示进度
-a 归档模式
-r  递归到目录
-t  保持mtime属性
-o 保持owener
-g 保持group
-p 保持权限
-z 传输时压缩
-password-file 密码文件
-W-全量传输

三. inotify-tool的安装
suse inotify-tool安装可复杂了。
首先得找到了suse inotify-tool的安装包
https://software.opensuse.org/download.html?project=filesystems&package=inotify-tools
1.直接安装失败
Filesserver:/tmp # zypper addrepo https://download.opensuse.org/repositories/filesystems/SLE_12_SP5/filesystems.repo
Download (curl) error for 'https://download.opensuse.org/repositories/filesystems/SLE_12_SP5/filesystems.repo':
Error code: Curl error 60
Error message: SSL certificate problem: certificate has expired

2.手工下载后再安装 inotify-tool
Filesserver:/tmp # zypper in inotify-tools-3.20.2.2-17.1.x86_64.rpm
Loading repository data...
Reading installed packages...
Resolving package dependencies...

Problem: nothing provides libinotifytools.so.0()(64bit) needed by inotify-tools-3.20.2.2-17.1.x86_64
 Solution 1: do not install inotify