Linux 离线升级 RSYNC

前言:本文操作是在 CentOS-7 下执行的,不确定在其他 Linux 发布版是否能同样正常执行。

1、检查前置依赖组件

image

在安装 rsync 之前,需要确认已安装了相关依赖组件: gcc 、openssl-devel 、xxhash 、zstd 、lz4 。

rpm -qa | grep gcc
rpm -qa | grep openssl-devel
which xxhsum
which zstd
which lz4

相关前置依赖组件的具体离线安装方法请参考:

2、查询rsync当前版本号

image

rsync --version

3、下载新版本安装包

官网下载地址:https://rsync.samba.org/

image

本示例安装包的直接下载地址为:https://download.samba.org/pub/rsync/src/rsync-3.4.1.tar.gz

4、上传安装包到服务器

image

5、解压rsync安装包

image

tar -zxvf 新版本安装包名称

6、配置rsync

image

cd 新版本安装包解压目录
./configure

注意:如果没有先安装第一节提到的相关前置依赖组件,那么在配置 rsync 时可能会失败:
image

Configure found the following issues:

- Failed to find openssl/md4.h and openssl/md5.h for openssl crypto lib support.
- Failed to find xxhash.h for xxhash checksum support.
- Failed to find zstd.h for zstd compression support.
- Failed to find lz4.h for lz4 compression support.

See the INSTALL file for hints on how to install the missing libraries and/or
how to generate (or fetch) manpages:
https://github.com/RsyncProject/rsync/blob/master/INSTALL.md

To disable one or more features, the relevant configure options are:
--disable-openssl
--disable-xxhash
--disable-zstd
--disable-lz4

configure.sh: error: Aborting configure run

7、修改rsync类型字节数

image

vi config.status

image

经过配置后,在 config.status 文件中,上述 rsync 类型字节数的值可能为 0 ,需要修改为合适的值(见上图)。

D["SIZEOF_INT"]=" 4"
D["SIZEOF_LONG"]=" 8"
D["SIZEOF_LONG_LONG"]=" 8"
D["SIZEOF_SHORT"]=" 2"
D["SIZEOF_INT16_T"]=" 2"
D["SIZEOF_UINT16_T"]=" 2"
D["SIZEOF_INT32_T"]=" 4"
D["SIZEOF_UINT32_T"]=" 4"
D["SIZEOF_INT64_T"]=" 8"
D["SIZEOF_OFF_T"]=" 8"
D["SIZEOF_OFF64_T"]=" 8"
D["SIZEOF_TIME_T"]=" 8"
D["SIZEOF_CHARP"]=" 8"

8、编译rsync

image

make

注意:如果没有执行第七节的修改 rsync 类型字节数操作,那么在编译 rsync 时可能会失败:
image
gawk -f ./daemon-parm.awk ./daemon-parm.txt
gawk -f ./mkproto.awk ./*.c ./lib/compat.c daemon-parm.h
In file included from ./rounding.c:20:0:
./rsync.h:614:3: 错误:#error Could not find a 32-bit integer variable
# error Could not find a 32-bit integer variable
^
./rsync.h:683:2: 错误:未知的类型名‘int32’
int32 size, entries;
^
./rsync.h:684:9: 错误:expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘attribute’ before ‘node_size’
uint32 node_size;
^
./rsync.h:690:2: 错误:未知的类型名‘int32’
int32 key;
^
./rsync.h:774:3: 错误:#error Character pointers are not 4 or 8 bytes.
# error Character pointers are not 4 or 8 bytes.
^
./rsync.h:787:2: 错误:未知的类型名‘int32’
int32 num;
.........................
.........................
^
./proto.h:316:28: 错误:未知的类型名‘int32’
void see_token(char *data, int32 toklen);
^
./proto.h:369:8: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘fuzzy_distance’
uint32 fuzzy_distance(const char *s1, unsigned len1, const char *s2, unsigned len2, uint32 upperlimit);
^
./rounding.c: 在函数‘main’中:
./rounding.c:35:13: 警告:变量‘test_array’被设定但未被使用 [-Wunused-but-set-variable]
static int test_array[1 - 2 * (ACTUAL_SIZE != EXPECTED_SIZE)];
^
Failed to create rounding.h!
make: *** [rounding.h] 错误 1

9、安装rsync

image

make install

10、查询rsync升级后的版本号

image

rsync --version

提示:完成升级后,新版本号需要退出重新登录访问才能查询到,否则查到的是旧版本号。

本文参考

【1】【Rsync缓冲区溢出与信息泄露漏洞(CVE-2024-12084/CVE-2024-12085)通告】【绿盟科技】【2025-01-16】

【2】【Rsync 缓冲区溢出漏洞(CVE-2024-12084)】【启明星辰】【2025-01-17】

【3】【liuxiao】【64位centos上rsync源码编译时报错未知类型int32】【CSDN】【2022-01-22】

【4】【qqliuxiaoran】【build fail on ky10 arm】【github】【2023-02-10】

【5】【CentOS 升级RSync:轻松实现版本升级,解锁数据同步新效能!】【云原生实践】【2025-01-21】

【6】【men_nang】【rsync 版本升级】【CSDN】【2025-01-24】

【7】【JesJiang】【rsync离线安装】【CSDN】【2020-04-15】

原创作者: Javaer1995 转载于: https://www.cnblogs.com/Javaer1995/p/18703059
### CentOS 7 中离线安装或升级Rsync 3.4 版本 #### 准备工作 为了在CentOS 7中离线安装或升级rsync 3.4版本,首先需要获取该版本的源码以及依赖项。可以从官方站点下载所需文件并将其传输到目标机器。 - 访问 [Rsync官方网站](https://rsync.samba.org/) 下载对应版本的tarball文件。 - 使用 `scp` 或其他方式将下载好的 tarball 文件传送到离线服务器上[^3]。 #### 安装依赖库 由于是在离线环境中操作,因此需提前准备好所有必需的开发工具和库。可以预先在一个联网的相同架构的系统中通过如下命令来收集这些rpm包: ```bash yumdownloader --resolve epel-release gcc g++ gawk autoconf automake python3-pip acl libacl-devel attr libattr-devel xxhash-devel libzstd-devel lz4-devel openssl-devel ``` 之后同样利用SCP或者其他手段把这些rpm包转移到离线主机,并执行批量安装: ```bash rpm -ivh *.rpm ``` #### 编译与安装 完成上述准备工作后,在离线环境下按照下面流程继续操作: 1. 解压已传送过来的rsync源代码压缩包: ```bash tar zxvf rsync-3.4.x.tar.gz cd rsync-3.4.x/ ``` 2. 配置编译环境 ```bash ./configure ``` 3. 开始编译过程 ```bash make ``` 4. 执行安装指令 ```bash make install ``` 此时,默认情况下rsync会被安装到 `/usr/local/bin/` 路径下[^1]。 #### 更新服务配置 如果之前已经存在旧版的服务定义,则可能还需要调整 systemd 的 service file 来指向新的二进制位置(/usr/local/bin/rsync),具体做法为修改 `/usr/lib/systemd/system/rsyncd.service` 文件中的 ExecStart 参数值为新路径,并重启服务使更改生效: ```bash systemctl daemon-reload systemctl restart rsync ``` 另外需要注意的是对于某些安全敏感场景下的设置比如密码文件权限管理等问题也应当给予适当关注,例如可以通过以下命令降低 `/etc/rsync.password` 文件的访问级别以增强安全性[^2]: ```bash chmod 600 /etc/rsync.password ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值