Add blank lines around headers

This commit is contained in:
yeasy
2026-03-24 09:27:04 -07:00
parent 857e3b73f6
commit ae8636e96f
112 changed files with 468 additions and 0 deletions

View File

@@ -48,6 +48,7 @@ scrape_configs:
rule_files:
- /etc/prometheus/rules.yml
```
#### 2. 编写 Docker Compose 文件
创建 `compose.yaml` ( `docker-compose.yml`)
@@ -105,6 +106,7 @@ networks:
volumes:
prometheus_data:
```
#### 3. 启动服务
```bash

View File

@@ -71,6 +71,7 @@ volumes:
networks:
logging:
```
#### 2. 配置 Fluentd
创建 `fluentd/conf/fluent.conf`
@@ -101,6 +102,7 @@ networks:
</store>
</match>
```
#### 3. 配置应用容器使用 fluentd 驱动
启动一个测试容器指定日志驱动为 `fluentd`

View File

@@ -91,6 +91,7 @@ done
# MEM % 接近 100%:容器即将 OOM需要增加内存或排查内存泄漏
# 如果 NET I/O 中 dropped 为非零:网络拥塞或丢包
```
### 19.3.3 cAdvisor 容器监控系统
cAdvisor Google 开发的容器监控工具提供比 `docker stats` 更详细的性能数据
@@ -150,6 +151,7 @@ scrape_configs:
- targets: ['localhost:8080']
metrics_path: '/metrics'
```
### 19.3.4 Prometheus 容器监控配置
使用 Prometheus node-exporter 进行长期的容器性能监控
@@ -275,6 +277,7 @@ container_memory_cache_bytes / container_memory_usage_bytes
# 按镜像统计容器数
count(container_memory_usage_bytes) by (image)
```
### 19.3.5 容器 OOM 排查与内存限制调优
#### OOM 问题诊断
@@ -293,6 +296,7 @@ docker logs <container_id> 2>&1 | grep -i "out of memory\|oom"
dmesg | grep -i "oom\|kill"
journalctl -u docker -n 100 | grep -i "oom"
```
#### 内存泄漏检测
使用专项工具分析应用内存使用
@@ -347,6 +351,7 @@ jstat -gc <pid> 1000 # 每秒采样一次
# S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU
# 6144 6144 0 6144 39424 12288 149504 84320 50552 47689 6464 5989
```
#### 内存限制最佳实践
```bash
@@ -385,6 +390,7 @@ services:
memory: 2G
memory_reservation: 1G # 预留 1GB允许突发到 2GB
```
### 19.3.6 镜像体积优化与多阶段构建
#### 镜像体积分析工具
@@ -411,6 +417,7 @@ chmod +x hadolint
# 检查 Dockerfile 最佳实践
./hadolint Dockerfile
```
#### 多阶段构建最佳实践
**Go 应用的最小化镜像构建**
@@ -528,6 +535,7 @@ EXPOSE 5000
CMD ["python", "app.py"]
```
#### 镜像体积优化检查清单
```bash
@@ -558,6 +566,7 @@ RUN apt-get update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
```
### 19.3.7 常见性能问题及解决方案
**问题 1: 容器频繁被 OOM 杀死**