{"id":28911401,"url":"https://github.com/turtacn/mha4rdb","last_synced_at":"2026-05-08T14:47:52.811Z","repository":{"id":293404010,"uuid":"983903066","full_name":"turtacn/mha4rdb","owner":"turtacn","description":"Mha4RDB：an open source Master-HA framework and service for rational database powered by generative AI. ","archived":false,"fork":false,"pushed_at":"2025-06-12T06:10:05.000Z","size":9462,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-21T19:05:19.838Z","etag":null,"topics":["ha","mha","mongo","mongodb","mysql","postgresql","raft","vastbase","vip"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/turtacn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-15T05:10:41.000Z","updated_at":"2025-06-12T06:10:08.000Z","dependencies_parsed_at":"2025-05-15T07:33:13.540Z","dependency_job_id":null,"html_url":"https://github.com/turtacn/mha4rdb","commit_stats":null,"previous_names":["turtacn/mha4rdb"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/turtacn/mha4rdb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turtacn%2Fmha4rdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turtacn%2Fmha4rdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turtacn%2Fmha4rdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turtacn%2Fmha4rdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/turtacn","download_url":"https://codeload.github.com/turtacn/mha4rdb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turtacn%2Fmha4rdb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32785396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"ssl_error","status_checked_at":"2026-05-08T08:22:45.650Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ha","mha","mongo","mongodb","mysql","postgresql","raft","vastbase","vip"],"created_at":"2025-06-21T19:05:17.242Z","updated_at":"2026-05-08T14:47:52.771Z","avatar_url":"https://github.com/turtacn.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# mha4rdb: Relational Database Master High Availability \n\n`mha4rdb` is kind of Master High Availability for Relational Databases(e.g. Vastbase、Mysql、Postgresql、...)\n\n* Here RDB is Vastbase for example\n* Here common service is IaaS, to take HCI基础设施[5]for example\n\n## 1. Project Introduction\n\n`mha4rdb` is a Master High Availability (MHA) solution for Vastbase databases specifically designed for Hyper-Converged Infrastructure (HCI[5]基础设施) scenarios. It leverages the Raft consistency protocol, either built into or integrated with the Vastbase database, to ensure strong consistency and durability of configuration data. Through a lightweight Agent and Virtual IP (VIP) mechanism, it provides automated fault detection and failover for the database service, offering a stable, reliable, and highly available configuration data backend for HCI基础设施[5]infrastructure software.\n\nCompared to general OLTP databases, HCI基础设施[5]scenarios place a particularly high emphasis on data consistency, while the requirement for extreme read/write performance is relatively secondary. `mha4rdb` focuses on meeting these core needs of the HCI基础设施[5]environment, providing a simple, easy-to-use, highly automated database HA capability that integrates well with the HCI基础设施[5]platform.\n\n## 2. Key Features\n\n* **Raft-based Strong Consistency**: Relies on the Raft protocol implemented by the Vastbase database itself to ensure data is not lost and remains consistent during cluster state changes and node failures.\n* **Virtual IP (VIP) Management**: By automatically managing the floating of the Virtual IP, it provides a fixed database access point for HCI基础设施[5]services, eliminating the need to be aware of backend Leader node switches.\n* **Lightweight MHA Agent**: An Agent deployed on each database node is responsible for monitoring the status of the local Vastbase instance, participating in cluster state synchronization, and executing VIP management and decision-making.\n* **Automated Failover**: Automatically detects Leader node failures and, coordinated by a majority of Agents, automatically switches the VIP to the new Leader node.\n* **Multiple Deployment Modes**: Supports single-node, dual-node + arbiter, and multi-node cluster deployment modes to meet different scale and reliability requirements.\n* **Easy Integration**: Provides an MHA Client library for easy integration by HCI基础设施[5]services to query database cluster status.\n\n## 3. Architecture Overview\n\nThe core components of the `mha4rdb` system include:\n\n* **Vastbase Database Instances**: Form the Raft cluster, responsible for data storage and replication.\n* **MHA Agents**: Deployed on each Vastbase node, monitoring database status, participating in cluster management, and managing the VIP.\n* **Optional Arbiter Service**: Provides an additional vote in dual-node mode to prevent split-brain scenarios.\n* **Virtual IP**: Provides a unified access point.\n* **HCI基础设施[5]Service**: The control plane of the HCI基础设施[5]infrastructure software, accessing the database via the VIP and interacting with the Agents via the MHA Client library to obtain status.\n\nFor a detailed architecture design, please refer to the [架构设计 / Architecture Design Document](docs/architecture.md).\n\nFor a more detailed architecture and more designs, please refer to the [详细设计](docs/design.md).\n\n\n## 4. Deployment Modes\n\n`mha4rdb` supports the following deployment modes:\n\n* **Single Node**: Suitable for development or test environments, provides basic health check capabilities.\n* **Dual Node + Arbiter**: Introduces an independent arbiter node alongside two Vastbase instances to form a minimum majority, providing basic high availability.\n* **Multi Node Cluster**: Three or more Vastbase instances form a Raft cluster, providing higher availability and fault tolerance.\n\n## 5. Getting Started\n\n### 5.1 Dependencies\n\n* Go language environment (version \u003e= 1.20.2)\n* Vastbase database (needs to support or integrate the Raft protocol and expose MHA-related status query and management interfaces)\n* (Optional) Operating system tools or libraries for managing VIP (e.g., `ip` command)\n* (Optional) Arbiter service (for dual-node + arbiter mode)\n\n### 5.2 Building\n\n```bash\n# Clone the repository\ngit clone https://github.com/turtacn/mha4rdb.git\ncd mha4rdb\n\n# Build the MHA Agent\ngo build -o bin/mha-agent cmd/agent/main.go\n\n# Build the MHA Client library (to be used as a Go module dependency, no separate executable needed)\n# go get https://github.com/turtacn/mha4rdb/pkg/client\n````\n\n### 5.3 Configuration\n\nAgent configuration is primarily done via a YAML file. Refer to the `configs/agent.yaml` example.\n\n### 5.4 Running\n\nRun the MHA Agent on each Vastbase database node:\n\n```bash\n./bin/mha-agent --config configs/agent.yaml\n```\n\nFor specific deployment and running steps, as well as configuration details for different modes, please refer to the detailed [Deployment Guide](https://www.google.com/search?q=docs/deployment_guide.md) (To Be Completed).\n\n## 6\\. Integration with [5]基础设施\n\nHCI基础设施[5]infrastructure software can integrate with MHA Agents by including the `pkg/client` package. The MHA Client provides interfaces to query cluster status, get the Leader address, etc. HCI基础设施[5]services can use this information for database connection management and fault handling.\n\nHCI基础设施[5]services are responsible for connecting to the VIP for normal database read/write operations. Upon detecting a Leader switch event (obtained via the MHA Client), they should update their internal connection state or perform other necessary coordination logic.\n\n## 7\\. Contributing\n\nWe welcome contributions from the community\\! If you are interested in the `mha4rdb` project and would like to report bugs, suggest improvements, or submit code, please refer to the [Contributing Guide](https://www.google.com/search?q=CONTRIBUTING.md) (To Be Completed).\n\n## 8\\. License\n\nThis project is licensed under the [Apache 2.0 License](https://www.google.com/search?q=LICENSE).\n\n## 9\\. Project Tree (WIP)\n\n```text\nmha4rdb/\n├── cmd/                                # 命令行入口\n│   ├── mha-agent/                      # MHA Agent命令行\n│   ├── mha-manager/                    # MHA Manager命令行\n│   └── mha-cli/                        # MHA CLI工具命令行\n├── docs/                               # 文档\n│   ├── architecture.md                 # 架构文档\n│   ├── deployment.md                   # 部署文档\n│   └── api.md                          # API文档\n├── examples/                           # 示例\n│   ├── client/                         # 客户端示例\n│   ├── config/                         # 配置示例\n│   └── scripts/                        # 脚本示例\n├── internal/                           # 内部包\n│   ├── common/                         # 通用代码\n│   │   ├── constants/                  # 常量定义\n│   │   ├── errors/                     # 错误定义\n│   │   ├── logging/                    # 日志\n│   │   ├── metrics/                    # 指标\n│   │   └── utils/                      # 工具函数\n│   ├── agent/                          # Agent实现\n│   │   ├── server/                     # Agent服务\n│   │   ├── monitor/                    # 监控实现\n│   │   ├── vip/                        # VIP管理\n│   │   └── handlers/                   # 请求处理\n│   ├── manager/                        # Manager实现\n│   │   ├── server/                     # Manager服务\n│   │   ├── cluster/                    # 集群管理\n│   │   ├── election/                   # 选举管理\n│   │   └── handlers/                   # 请求处理\n│   └── db/                             # 数据库适配\n│       ├── mysql/                      # MySQL适配\n│       ├── postgresql/                 # PostgreSQL适配\n│       └── vastbase/                   # Vastbase适配\n├── pkg/                                # 公共包\n│   ├── api/                            # API定义\n│   │   ├── client/                     # 客户端API\n│   │   ├── agent/                      # Agent API\n│   │   └── manager/                    # Manager API\n│   ├── config/                         # 配置\n│   ├── client/                         # 客户端实现\n│   ├── raft/                           # Raft实现\n│   ├── db/                             # 数据库接口\n│   └── models/                         # 数据模型\n├── test/                               # 测试\n│   ├── integration/                    # 集成测试\n│   ├── benchmark/                      # 基准测试\n│   └── utils/                          # 测试工具\n├── scripts/                            # 脚本工具\n│   ├── install/                        # 安装脚本\n│   ├── build/                          # 构建脚本\n│   └── ci/                             # CI脚本\n├── Makefile                            # 构建规则\n├── go.mod                              # Go模块定义\n\n```\n\n## 10\\. References\n- [1] [MySQL Group Replication](https://dev.mysql.com/doc/refman/8.0/en/group-replication.html)\n- [2] [PostgreSQL Patroni](https://patroni.readthedocs.io/en/latest/)\n- [3] [Development tree of Master High Availability Manager and tools for MySQL (MHA), Manager part](https://github.com/yoshinorim/mha4mysql-manager)\n- [4] [Development tree of Master High Availability Manager and tools for MySQL (MHA), Node (MySQL Server) part](https://github.com/yoshinorim/mha4mysql-node)\n- [5] [full-stack hyperconverged infrastructure](https://www.gartner.com/reviews/market/full-stack-hyperconverged-infrastructure-software)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturtacn%2Fmha4rdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fturtacn%2Fmha4rdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturtacn%2Fmha4rdb/lists"}