改改改

This commit is contained in:
2026-01-09 17:50:32 +08:00
parent cf14d8a6db
commit 0384834345
37 changed files with 1944 additions and 2 deletions

58
tempo/cos-tempo.yaml Normal file
View File

@@ -0,0 +1,58 @@
server:
http_listen_port: 3200 # HTTP 接口监听端口
grpc_listen_port: 9095 # gRPC 接口监听端口
distributor:
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317 # OTLP gRPC 接口监听地址
http:
endpoint: 0.0.0.0:4318 # OTLP HTTP 接口监听地址
ingester:
lifecycler:
ring:
replication_factor: 1 # 数据的副本数
max_block_duration: 5m # 最大数据块时长
trace_idle_period: 10s # 如果某个 Trace 长时间未活动,自动清理
compactor:
compaction:
block_retention: 720h # 数据块保留时间720小时30天
compacted_block_retention: 168h # 压缩后的数据块保留时间168小时7天
max_compaction_objects: 1000000 # 每次压缩的最大对象数
metrics_generator:
registry:
external_labels:
source: tempo
cluster: linux-microservices
storage:
path: /data/tempo/data/wal
remote_write:
- url: http://127.0.0.1:9090/api/v1/write
send_exemplars: true
storage:
trace:
backend: s3
s3:
endpoint: outscalelink-1324597558.cos.na-siliconvalley.myqcloud.com
bucket: outscalelink-1324597558
prefix: tempo-data/
forcepathstyle: true
enable_dual_stack: false
insecure: true
access_key: AKIDkgR4lHvU1QfieR7cxBLLTaUCh0S0dDev
secret_key: fAWjldKuPhz4wb6RedPzPccOwGOet9Ug
wal:
path: /data/tempo/data/wal
local:
path: /data/tempo/blocks
overrides:
metrics_generator_processors: [service-graphs, span-metrics]

96
tempo/dm.sh Normal file
View File

@@ -0,0 +1,96 @@
mkdir -p /data/tempo/{conf,data,metrics-generator}
mkdir -p /data/tempo/data/wal
mkdir -p /data/tempo/metrics-generator/wal
chown -R tempo:tempo /data/tempo
chown -R tempo:tempo /data/tempo/data/traces
# 创建一个专用用户并配置服务,确保 Tempo 在后台稳定运行
sudo useradd --no-create-home --shell /bin/false tempo || true
# 下载tar包
wget https://github.com/grafana/tempo/releases/download/v2.9.0/tempo_2.9.0_linux_amd64.tar.gz
# 解压
tar -xzf tempo_2.9.0_linux_amd64.tar.gz -C /data/tempo/
# 移动可执行文件到 /usr/local/bin/
mv /data/tempo/tempo /data/tempo/tempo-cli /data/tempo/tempo-query /usr/local/bin/
# 检查版本
tempo --version
# 创建配置文件(本地为存储介质)
vim local-tempo.yaml
server:
http_listen_port: 3200 # Tempo Web 端口Grafana 对接用)
grpc_listen_port: 9095 # gRPC 端口(可选)
distributor:
receivers: # 接收 OTel 追踪数据的协议(核心)
otlp:
protocols:
grpc: # 监听 4317 端口(和 OTel Collector 一致,接收 OTLP gRPC 数据)
endpoint: 0.0.0.0:4317
http: # 监听 4318 端口(接收 OTLP HTTP 数据)
endpoint: 0.0.0.0:4318
ingester:
max_block_duration: 5m # 数据块存储时长(测试环境可设小)
trace_idle_period: 10s # 追踪会话空闲超时
compactor:
compaction:
block_retention: 30d # 追踪数据保留 30 天(可按需调整)
storage:
trace:
backend: local # 单节点本地存储(生产可换 S3/MinIO
local:
path: /data/tempo/data # 追踪数据存储目录(指定到 /data/tempo/data
wal:
path: /data/tempo/data/wal # 预写日志目录(保证数据不丢)
# 存储桶为存储对象
vim cos-tempo.yaml
# 前台启动
/usr/local/bin/tempo \
-config.file=/data/tempo/conf/tempo.yaml \
-config.expand-env=true
# 检查服务状态
systemctl is-active tempo
# Systemd 服务守护进程
vim /etc/systemd/system/tempo.service
[Unit]
Description=Grafana Tempo
Wants=network-online.target
After=network-online.target
[Service]
User=tempo
Group=tempo
Type=simple
# config.file 指定配置文件路径,这里的配置文件注意文件名
ExecStart=/usr/local/bin/tempo \
-config.file=/data/tempo/conf/tempo.yaml \
-config.expand-env=true
Restart=always
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
# 加载配置
sudo systemctl daemon-reload
# 启动并设置自启
sudo systemctl enable --now tempo
# 检查状态
sudo systemctl status tempo
# 查看日志
journalctl -u tempo --no-pager -n 50