完善说明文档

This commit is contained in:
2026-02-27 15:10:12 +08:00
parent 03fa964669
commit b26ba36be4
2 changed files with 32 additions and 8 deletions

View File

@@ -13,16 +13,40 @@ ansible/
└── README.md
```
## 快速开始
## 使用方式
### 基本用法
### 1. linux 环境
ansible 在 windows 环境中运行不稳定,最好在 linux 环境中运行。如果要下载到本地,最好的方法是在 wsl 中安装 ansible
### 2. python 环境
ansible 依赖于 python 环境,在安装前需要确保系统里已经安装了 python。
ansible 在运行时会连接到目标机器进行操作,因此需要确定好本机和目标机器的 python 版本兼容性。ansble 官网列出了一个[版本支持矩阵](https://docs.ansible.com/projects/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix),根据这个表格确定需要安装的 python 版本和 ansible 版本
由于当前项目要操作的服务器中,最低版本的 python 为 3.8centos 预置),因此主机(控制机)要使用的 python 版本要在 3.8 - 3.13 之间。linux 系统中一般都会预置特定版本的 python如果主机预置的 python 版本不在范围内,需要手动安装范围内版本的 python不同 linux 发行版的安装方式略有差异。
### 3. 安装 ansible
ansible 有两个分支社区版本ansible和核心版本ansible-core现在项目适配的 ansible 版本为 ansible-core 2.19(适用于 python 3.8 - 3.13
```bash
pipx install ansible-core==2.19
```
### 4. 执行脚本
ansible 的执行命令比较繁琐,有一个简单的脚本文件包装了 ansible 的命令,方便在执行时传参
```bash
# 拉取日志并删除远程存档
# -y 年
# -m 月 ,必须是两位数
# -s 日,开始,必须是两位数
# -e 日,结束,必须是两位数
# 将拉取 s - e 之间日期的所有日志,会断点续传
# 月份和日期必须是两位数!
./scripts/compress_logs.sh -y 2025 -m 12 -s 01 -e 10
```
## 注意事项
脚本中开头有定义参数,尽量列出了有必要的变量用于灵活修改,但是还有些硬编码的部分,需要根据实际情况进行修改。
一次性不要拉太多日志,由于拉取流程中需要在服务器上压缩一次日志,要确保服务器空间有足够空余

View File

@@ -36,7 +36,7 @@ show_help() {
$0 -y 2025 -m 11 -s 21 -e 30
# 压缩2025年12月的所有日志
$0 -y 2025 -m 12 -s 1 -e 31
$0 -y 2025 -m 12 -s 01 -e 31
# 只处理jhlog服务器
$0 -y 2025 -m 11 -s 21 -e 30 -h jhlog