首页
/ Stolon 开源项目使用教程

Stolon 开源项目使用教程

2024-08-07 00:27:49作者:江焘钦

1. 项目的目录结构及介绍

Stolon 项目的目录结构如下:

stolon/
├── bin/
├── cmd/
│   ├── stolon-keeper/
│   ├── stolon-proxy/
│   └── stolon-sentinel/
├── docs/
├── examples/
├── Godeps/
├── scripts/
├── store/
├── tests/
├── vendor/
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── Dockerfile
├── LICENSE
├── Makefile
├── README.md
└── VERSION

目录介绍

  • bin/: 编译生成的二进制文件存放目录。
  • cmd/: 包含各个组件的入口文件,如 stolon-keeperstolon-proxystolon-sentinel
  • docs/: 项目文档存放目录。
  • examples/: 示例配置文件和使用案例。
  • Godeps/: Go 依赖管理文件。
  • scripts/: 一些辅助脚本。
  • store/: 存储相关的代码。
  • tests/: 测试代码。
  • vendor/: 项目依赖的第三方库。
  • .gitignore: Git 忽略文件配置。
  • .travis.yml: Travis CI 配置文件。
  • CHANGELOG.md: 版本变更日志。
  • CODE_OF_CONDUCT.md: 行为准则。
  • CONTRIBUTING.md: 贡献指南。
  • Dockerfile: Docker 镜像构建文件。
  • LICENSE: 项目许可证。
  • Makefile: 编译和构建脚本。
  • README.md: 项目介绍和使用说明。
  • VERSION: 项目版本号。

2. 项目的启动文件介绍

Stolon 项目的主要启动文件位于 cmd/ 目录下,包括:

  • stolon-keeper/: 负责管理 PostgreSQL 实例。
  • stolon-proxy/: 负责代理客户端请求到正确的 PostgreSQL 实例。
  • stolon-sentinel/: 负责监控集群状态并做出决策。

启动文件介绍

  • stolon-keeper/main.go: stolon-keeper 的入口文件,负责启动和管理 PostgreSQL 实例。
  • stolon-proxy/main.go: stolon-proxy 的入口文件,负责代理客户端请求。
  • stolon-sentinel/main.go: stolon-sentinel 的入口文件,负责监控集群状态。

3. 项目的配置文件介绍

Stolon 项目的配置文件通常位于 examples/ 目录下,包括:

  • stolon-cluster-config.json: 集群配置文件,定义了集群的拓扑结构和参数。
  • stolon-keeper-config.json: stolon-keeper 的配置文件,定义了 PostgreSQL 实例的参数。
  • stolon-proxy-config.json: stolon-proxy 的配置文件,定义了代理的参数。
  • stolon-sentinel-config.json: stolon-sentinel 的配置文件,定义了监控和决策的参数。

配置文件介绍

  • stolon-cluster-config.json:

    {
      "initMode": "new",
      "storeBackend": "etcd",
      "storeEndpoints": ["http://etcd:2379"],
      "clusterName": "mycluster"
    }
    
  • stolon-keeper-config.json:

    {
      "clusterName": "mycluster",
      "storeBackend": "etcd",
      "storeEndpoints": ["http://etcd:2379"],
      "dataDir": "/var/lib/stolon/data",
      "pgListenAddress": "0.0.0.0",
      "pgPort": 5432
    }
    
  • stolon-proxy-config.json:

    {
      "clusterName": "mycluster",
      "storeBackend": "etcd",
    
登录后查看全文
热门项目推荐
相关项目推荐