gzip: stdin: unexpected end of file tar: 归档文件中异常的 EOF 安装redis过程出错-日记

在CentOS7系统中配置Redis时遇到压缩包解压错误,提示gzip和tar异常。问题可能源于从Windows主机拖拽到虚拟机的压缩包在传输过程中受损。解决方案包括检查两个系统中压缩包的大小,确认是否完整,如果受损则重新传输或直接在虚拟机内从官网下载。

一、案发现场:

今天xin麒在自己虚拟机配置好了centos7系统,打算配置一下redis环境,于是出现下面报错:

在这里插入图片描述

再来一遍:tar -zxvf redis-6.2.6.tar.gz

在这里插入图片描述

于是xin麒使用sudo rm -rf + 文件夹名称删除了。

报错信息:

gzip: stdin: unexpected end of file
tar: 归档文件中异常的 EOF
tar: 归档文件中异常的 EOF
tar: Error is not recoverable: exiting now

二、解决:

这样有一个原因:

可能是在虚拟机的压缩包有损坏。xin麒就是将win主机的redis压缩包(redis-6.2.6.tar.gz)拖到虚拟机里的,可以查看两压缩包的属性看看两压缩包大小是不是不一样,是不是拖到虚拟机里的压缩包小了很多,如果是这个问题那么很可能是压缩包受损了。

在保证win主机里redis-6.2.6.tar.gz压缩包是完好的情况下可以重新将虚拟机里的压缩包删除了,重新扔进去一个,看看压缩包大小有没有受损,如果还是受损,那就直接在虚拟机从官网里下载吧。

#!/usr/bin/env php <?php /** * auth_prosody.php - Prosody 外部认证接口(修复版) * 支持 auth 和 exists 类型 */ // 加载外部配置(防止源码泄露) $configFile = '/etc/myapp/database.conf'; if (!file_exists($configFile)) { error_log("CRITICAL: Config file not found: $configFile"); fwrite(STDOUT, "N\n"); exit; } $config = json_decode(file_get_contents($configFile), true); if (json_last_error() !== JSON_ERROR_NONE) { error_log("CRITICAL: Invalid JSON in config file"); fwrite(STDOUT, "N\n"); exit; } $log_file = '/tmp/prosody_auth.log'; function safe_log($msg) { @file_put_contents($log_file, "[".date('Y-m-d H:i:s')."] " . $msg . "\n", FILE_APPEND | LOCK_EX); } try { $pdo = new PDO("mysql:host={$config['host']};dbname={$config['dbname']};charset=utf8", $config['user'], $config['pass']); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (Exception $e) { safe_log("CRITICAL: Database connection failed"); fwrite(STDOUT, "N\n"); exit; } // 仅读取一行输入(外部认证协议每请求一行) $line = trim(fgets(STDIN)); if (empty($line)) { safe_log("ERROR: Empty input"); fwrite(STDOUT, "N\n"); exit; } $parts = explode(":", $line, 4); // 最多切分4段 if (count($parts) < 3) { safe_log("ERROR: Malformed input: too few parts"); fwrite(STDOUT, "N\n"); exit; } list($type, $username, $realm) = $parts; $password = $parts[3] ?? ''; // 第四个字段是密码(auth时才需要) $result = false; try { switch ($type) { case "auth": if (empty($password)) { safe_log("FAIL: Missing password for user '$username'"); break; } $stmt = $pdo->prepare(" SELECT u.password, u.ec_salt FROM ecs_openfire_sync s JOIN ecs_users u ON s.user_id = u.user_id WHERE s.openfire_username = ? "); $stmt->execute([$username]); $user = $stmt->fetch(); if ($user) { $hashed_input = md5(md5($password) . $user['ec_salt']); $result = hash_equals($hashed_input, $user['password']); } else { safe_log("USER_NOT_FOUND: $username"); } break; case "exists": $stmt = $pdo->prepare("SELECT 1 FROM ecs_openfire_sync WHERE openfire_username = ?"); $stmt->execute([$username]); $result = (bool)$stmt->fetch(); break; default: safe_log("UNKNOWN_CMD: $type"); } } catch (Exception $e) { safe_log("EXCEPTION: " . $e->getMessage() . " | User: $username"); } // ✅ 正确输出 Y/N safe_log(($result ? "SUCCESS" : "FAILURE") . " | type=$type user=$username"); fwrite(STDOUT, $result ? "Y\n" : "N\n"); fflush(STDOUT); ?>
最新发布
11-12
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值