Add environment configuration and documentation for various services

- Created .env.example files for Kafka, Kibana, KodBox, Kong, Langfuse, Logstash, n8n, Nginx, OceanBase, OpenCoze, RocketMQ, TiDB, and TiKV.
- Added README.md and README.zh.md files for OceanBase, RocketMQ, TiDB, and TiKV, detailing usage, configuration, and access instructions.
- Implemented docker-compose.yaml files for OceanBase, RocketMQ, TiDB, and TiKV, defining service configurations, health checks, and resource limits.
- Included broker.conf for RocketMQ to specify broker settings.
- Established a consistent timezone (UTC) across all services.
- Provided optional port overrides in .env.example files for flexibility in deployment.
This commit is contained in:
Sun-ZhenXing
2025-10-22 11:46:50 +08:00
parent 84e8b85990
commit ece59b42bf
49 changed files with 2326 additions and 0 deletions

11
src/tikv/.env.example Normal file
View File

@@ -0,0 +1,11 @@
# TiKV version (applies to PD and TiKV)
TIKV_VERSION=v8.5.0
# Timezone
TZ=UTC
# Port overrides (optional)
# TIKV_PD_PORT_OVERRIDE=2379
# TIKV_PD_PEER_PORT_OVERRIDE=2380
# TIKV_PORT_OVERRIDE=20160
# TIKV_STATUS_PORT_OVERRIDE=20180

98
src/tikv/README.md Normal file
View File

@@ -0,0 +1,98 @@
# TiKV
TiKV is an open-source, distributed, transactional key-value database. It provides APIs in multiple languages and is designed to complement or work independently of TiDB.
## Usage
```bash
docker compose up -d
```
## Components
This setup includes:
- **PD (Placement Driver)**: Manages and schedules TiKV clusters
- **TiKV**: Distributed transactional key-value storage engine
## Ports
- `2379`: PD client port
- `2380`: PD peer port
- `20160`: TiKV service port
- `20180`: TiKV status and metrics port
## Access
### Using TiKV Client
TiKV provides client libraries for multiple languages:
- [Rust Client](https://github.com/tikv/client-rust)
- [Go Client](https://github.com/tikv/client-go)
- [Java Client](https://github.com/tikv/client-java)
- [Python Client](https://github.com/tikv/client-py)
### Example (using tikv-client-rust)
```rust
use tikv_client::{RawClient, Config};
#[tokio::main]
async fn main() {
let client = RawClient::new(vec!["127.0.0.1:2379"], None)
.await
.unwrap();
// Put a key-value pair
client.put("key".to_owned(), "value".to_owned()).await.unwrap();
// Get the value
let value = client.get("key".to_owned()).await.unwrap();
println!("Value: {:?}", value);
}
```
### Status and Metrics
Check TiKV status:
```bash
curl http://localhost:20180/status
```
Get metrics in Prometheus format:
```bash
curl http://localhost:20180/metrics
```
## Features
- **Distributed Transactions**: ACID transactions across multiple keys
- **Geo-Replication**: Data replication across data centers
- **Horizontal Scalability**: Scale storage by adding more TiKV nodes
- **Consistent Snapshot**: Snapshot isolation for reads
- **Cloud Native**: Designed for cloud environments
## Use Cases
- **As a key-value store**: Standalone distributed key-value database
- **With TiDB**: Storage layer for TiDB (see `tidb` service)
- **Cache backend**: Distributed cache with persistence
- **Metadata store**: Store metadata for distributed systems
## Notes
- This is a minimal single-node setup for development
- For production, deploy at least 3 TiKV nodes for data replication
- Deploy at least 3 PD nodes for high availability
- Monitor using Prometheus and Grafana
- Data is persisted in named volumes
## References
- [TiKV Official Documentation](https://tikv.org/docs/stable/)
- [TiKV Deep Dive](https://tikv.org/deep-dive/)
- [TiKV Docker Images](https://hub.docker.com/r/pingcap/tikv)
- [TiKV Clients](https://tikv.org/docs/stable/develop/clients/introduction/)

98
src/tikv/README.zh.md Normal file
View File

@@ -0,0 +1,98 @@
# TiKV
TiKV 是一个开源、分布式、事务型键值数据库。它提供多种语言的 API可以独立使用或与 TiDB 配合使用。
## 使用方法
```bash
docker compose up -d
```
## 组件说明
此配置包含:
- **PD (Placement Driver)**:管理和调度 TiKV 集群
- **TiKV**:分布式事务键值存储引擎
## 端口说明
- `2379`PD 客户端端口
- `2380`PD 对等端口
- `20160`TiKV 服务端口
- `20180`TiKV 状态和指标端口
## 访问方式
### 使用 TiKV 客户端
TiKV 提供多种语言的客户端库:
- [Rust 客户端](https://github.com/tikv/client-rust)
- [Go 客户端](https://github.com/tikv/client-go)
- [Java 客户端](https://github.com/tikv/client-java)
- [Python 客户端](https://github.com/tikv/client-py)
### 示例(使用 tikv-client-rust
```rust
use tikv_client::{RawClient, Config};
#[tokio::main]
async fn main() {
let client = RawClient::new(vec!["127.0.0.1:2379"], None)
.await
.unwrap();
// 存储键值对
client.put("key".to_owned(), "value".to_owned()).await.unwrap();
// 获取值
let value = client.get("key".to_owned()).await.unwrap();
println!("Value: {:?}", value);
}
```
### 状态和指标
检查 TiKV 状态:
```bash
curl http://localhost:20180/status
```
获取 Prometheus 格式的指标:
```bash
curl http://localhost:20180/metrics
```
## 特性
- **分布式事务**:跨多个键的 ACID 事务
- **地理复制**:跨数据中心的数据复制
- **水平扩展**:通过添加更多 TiKV 节点扩展存储
- **一致性快照**:读取的快照隔离
- **云原生**:专为云环境设计
## 使用场景
- **键值存储**:独立的分布式键值数据库
- **与 TiDB 配合**:作为 TiDB 的存储层(参见 `tidb` 服务)
- **缓存后端**:具有持久化能力的分布式缓存
- **元数据存储**:为分布式系统存储元数据
## 注意事项
- 这是一个最小的单节点配置,适合开发环境
- 生产环境需要部署至少 3 个 TiKV 节点以实现数据复制
- 部署至少 3 个 PD 节点以实现高可用
- 使用 Prometheus 和 Grafana 进行监控
- 数据持久化在命名卷中
## 参考资料
- [TiKV 官方文档](https://tikv.org/docs/stable/)
- [TiKV 深入了解](https://tikv.org/deep-dive/)
- [TiKV Docker 镜像](https://hub.docker.com/r/pingcap/tikv)
- [TiKV 客户端](https://tikv.org/docs/stable/develop/clients/introduction/)

View File

@@ -0,0 +1,81 @@
x-default: &default
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 100m
max-file: "3"
services:
pd:
<<: *default
image: pingcap/pd:${TIKV_VERSION:-v8.5.0}
command:
- --name=pd
- --client-urls=http://0.0.0.0:2379
- --peer-urls=http://0.0.0.0:2380
- --advertise-client-urls=http://pd:2379
- --advertise-peer-urls=http://pd:2380
- --data-dir=/data
environment:
TZ: ${TZ:-UTC}
volumes:
- pd_data:/data
ports:
- "${TIKV_PD_PORT_OVERRIDE:-2379}:2379"
- "${TIKV_PD_PEER_PORT_OVERRIDE:-2380}:2380"
deploy:
resources:
limits:
cpus: '1.0'
memory: 1G
reservations:
cpus: '0.25'
memory: 512M
healthcheck:
test: ["CMD-SHELL", "wget -q -O - http://localhost:2379/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
tikv:
<<: *default
image: pingcap/tikv:${TIKV_VERSION:-v8.5.0}
command:
- --addr=0.0.0.0:20160
- --advertise-addr=tikv:20160
- --status-addr=0.0.0.0:20180
- --pd=http://pd:2379
- --data-dir=/data
- --log-file=/logs/tikv.log
environment:
TZ: ${TZ:-UTC}
volumes:
- tikv_data:/data
- tikv_logs:/logs
ports:
- "${TIKV_PORT_OVERRIDE:-20160}:20160"
- "${TIKV_STATUS_PORT_OVERRIDE:-20180}:20180"
depends_on:
pd:
condition: service_healthy
deploy:
resources:
limits:
cpus: '2.0'
memory: 4G
reservations:
cpus: '0.5'
memory: 2G
healthcheck:
test: ["CMD-SHELL", "wget -q -O - http://localhost:20180/status || exit 1"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
volumes:
pd_data:
tikv_data:
tikv_logs: