{"id":34947798,"url":"https://github.com/tariqulgithub/master-replica-example","last_synced_at":"2026-04-16T10:31:40.507Z","repository":{"id":329167976,"uuid":"1118417258","full_name":"tariqulgithub/master-replica-example","owner":"tariqulgithub","description":"MySQL 8 Master-Replica Docker Compose setup with separate users for app, replication, and read-only reporting. Ready for development and testing.","archived":false,"fork":false,"pushed_at":"2025-12-17T19:44:23.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-21T06:52:51.747Z","etag":null,"topics":["database","devops","docker","docker-compose","docker-container","docker-image","gtid","gtid-replication","master-replica","mysql","mysql-database","open-source","read-only","replication"],"latest_commit_sha":null,"homepage":"https://github.com/tariqulgithub/master-replica-example","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tariqulgithub.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-17T18:11:46.000Z","updated_at":"2025-12-17T19:44:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/tariqulgithub/master-replica-example","commit_stats":null,"previous_names":["tariqulgithub/master-replica-example"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/tariqulgithub/master-replica-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tariqulgithub%2Fmaster-replica-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tariqulgithub%2Fmaster-replica-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tariqulgithub%2Fmaster-replica-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tariqulgithub%2Fmaster-replica-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tariqulgithub","download_url":"https://codeload.github.com/tariqulgithub/master-replica-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tariqulgithub%2Fmaster-replica-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31882008,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T09:23:21.276Z","status":"ssl_error","status_checked_at":"2026-04-16T09:23:15.028Z","response_time":69,"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":["database","devops","docker","docker-compose","docker-container","docker-image","gtid","gtid-replication","master-replica","mysql","mysql-database","open-source","read-only","replication"],"created_at":"2025-12-26T20:48:55.760Z","updated_at":"2026-04-16T10:31:40.500Z","avatar_url":"https://github.com/tariqulgithub.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# MySQL Master-Replica Example 🐬\n\nThis project demonstrates a **MySQL 8 master-replica setup using Docker Compose**, with separate users for application, replication, and read-only reporting.  \n\nThe setup is ready for **development and testing**, and can be adapted for production reporting replicas.\n\n---\n\n## Features ✅\n\n- **Master (\\`mysql-master\\`)**  \n  - App database: \\`relvora\\`  \n  - App user: \\`relvora\\` (full access to \\`relvora\\` database)  \n  - Replication user: \\`repl\\`  \n\n- **Replica (\\`mysql-replica\\`)**  \n  - Read-only replica of master database  \n  - Reporting user: \\`report\\` (read-only access to all databases)  \n\n- Automatic replication via GTID (Global Transaction IDs)  \n- \\`read-only\\` mode on replica ensures safety  \n- Fully scripted with Docker Compose + SQL init scripts  \n\n---\n\n## Project Structure 📁\n\n```\nmaster-replica-example/\n│\n├─ docker-compose.yml         # Docker Compose setup for master and replica\n├─ master-init/\n│   └─ master-init.sql        # Master initialization: app user, replication user, reporting user\n├─ replica-init/\n│   └─ replica-init.sql       # Replica initialization: configure replication from master\n└─ README.md                  # Project documentation\n```\n\n---\n\n## Setup Instructions 🛠️\n\n### 1. Clone the repository\n\n```\ngit clone https://github.com/tariqulgithub/master-replica-example.git\ncd master-replica-example\n```\n### 2. Create network if not exist\n\n```\ndocker network create --driver bridge relvora-network\ndocker network ls\n```\n\n### 3. Start the containers\n\n\u003e **Warning:** For the first run, remove old volumes to allow init scripts to execute properly.\n\n```\ndocker compose down -v\ndocker compose up -d\n```\n\n\n### 4. Verify the setup\n\n**Check master databases:**\n\n```\ndocker exec -it mysql-master mysql -urelvora -prelvorapassword -e \"SHOW DATABASES;\"\n```\n\n**Check replica databases (read-only):**\n\n```\ndocker exec -it mysql-replica mysql -ureport -preportpassword -e \"SHOW DATABASES;\"\n```\n\n**Check replication status:**\n\n```\ndocker exec -it mysql-replica mysql -uroot -prootpassword -e \"SHOW REPLICA STATUS\\G\"\n```\n\n---\n\n## Users \u0026 Permissions 🔑\n\n| User     | Host | Permissions                               | Usage |\n|----------|------|-------------------------------------------|-------|\n| \\`root\\`   | \\`%\\`  | Full access (master), limited on replica | Admin |\n| \\`relvora\\`| \\`%\\`  | All privileges on \\`relvora\\` database     | App   |\n| \\`repl\\`   | \\`%\\`  | Replication privileges                    | Replication threads |\n| \\`report\\` | \\`%\\`  | \\`SELECT\\` on all databases                 | Read-only reporting on replica |\n\n---\n\n## Notes ⚠️\n\n- The replica is **read-only**, so no writes are allowed except through replication.  \n- Always remove volumes for the first run to ensure init scripts execute.  \n\n---\n\n## License\n\nThis project is **open source** and available under the MIT License. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftariqulgithub%2Fmaster-replica-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftariqulgithub%2Fmaster-replica-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftariqulgithub%2Fmaster-replica-example/lists"}