{"id":23404769,"url":"https://github.com/shashank-bhat-collpoll/slave-server","last_synced_at":"2026-04-14T00:01:48.630Z","repository":{"id":268391907,"uuid":"904201150","full_name":"shashank-bhat-collpoll/slave-server","owner":"shashank-bhat-collpoll","description":"Setting Up a Docker Container with MySQL as a Slave Server","archived":false,"fork":false,"pushed_at":"2024-12-16T12:50:12.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-23T23:36:12.799Z","etag":null,"topics":["database","docker","replication"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shashank-bhat-collpoll.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-12-16T12:44:55.000Z","updated_at":"2024-12-16T12:54:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"bb26ccd9-b707-4725-8d12-cac4807b98b6","html_url":"https://github.com/shashank-bhat-collpoll/slave-server","commit_stats":null,"previous_names":["shashank-bhat-collpoll/slave-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shashank-bhat-collpoll/slave-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shashank-bhat-collpoll%2Fslave-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shashank-bhat-collpoll%2Fslave-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shashank-bhat-collpoll%2Fslave-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shashank-bhat-collpoll%2Fslave-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shashank-bhat-collpoll","download_url":"https://codeload.github.com/shashank-bhat-collpoll/slave-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shashank-bhat-collpoll%2Fslave-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31776013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T20:17:16.280Z","status":"ssl_error","status_checked_at":"2026-04-13T20:17:08.216Z","response_time":93,"last_error":"SSL_read: 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","docker","replication"],"created_at":"2024-12-22T13:15:39.542Z","updated_at":"2026-04-14T00:01:48.623Z","avatar_url":"https://github.com/shashank-bhat-collpoll.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Setting Up a Docker Container with MySQL as a Slave Server\n\nThis guide provides detailed instructions for setting up a Docker container with MySQL configured as a slave server. The container will connect to a master MySQL database running on your local machine and include a dummy Nginx server to keep the container running.\n\n## Prerequisites\n\n**Install Docker** \n\nFollow the instructions [here](https://docs.docker.com/engine/install/ubuntu/) to install Docker on your local machine.\n\n\n## Master Configuration\n\n**Create Mysql replica user**\n\nBoth master and slave servers should have the same user and password. Run the following commands on the master:\n\n```\nCREATE USER 'replica_write'@'%' IDENTIFIED BY 'Welcome@123';\nGRANT REPLICATION SLAVE ON *.* TO 'replica_write'@'%';\nFLUSH PRIVILEGES;\n```\n\nBoth master and slave should have same user and password make sure to create this first in master.\nFor slave replica_write user will get added while running docker container.\nAlso grant permission for all database to the user.\n\n\n**Master mysql config file changes**\n\nConfigured master MySQL server with the following settings in `/etc/mysql/mysql.conf.d/mysqld.cnf`:\n\n```shell\nsudo nano /etc/mysql/mysql.conf.d/mysqld.cnf\n```\n\n```ini\n[mysqld]\nserver-id=1\nport=3306\nlog_bin=/var/log/mysql/mysql-bin.log\nbind-address=0.0.0.0\nbinlog_do_db=test_db1\nbinlog_do_db=test_db2\n```\n\nRestart mysql server to apply the changes.\n```shell\nsudo systemctl restart mysql\n```\n\n**Check master binlog and position**\n\nLogin to master server db check binlog and position by entering below command\n```\nmysql\u003e SHOW MASTER STATUS\\G;\n*************************** 1. row ***************************\n             File: mysql-bin.001828\n         Position: 3072\n     Binlog_Do_DB: db_test1\n Binlog_Ignore_DB: \nExecuted_Gtid_Set: \n1 row in set (0.00 sec)\n```\nUpdate the file and position in the `Dockerfile`\n\n**Create master db dump**\n\nRun the following command to create the database dump:\n```shell\nmysqldump --single-transaction=TRUE -u replica_write -pWelcome@123 --databases test_db1 test_db2 \u003e db_dump.sql\n```\n\nPlace the latest database dump file in `slave-server/db_dump.sql`.\n\n\n## Preparing the Slave Server\n\n### Build the Docker Image\n\nRun the following commands in the directory containing the `Dockerfile`, `my.cnf`, and `entrypoint.sh`:\n\n```bash\ndocker build -t mysql-slave .\n```\n\n### Run the Docker Container\n\nStart the container, mapping ports for MySQL (3306) and Nginx (80):\n\n```bash\ndocker run --name mysql-slave -p 3307:3306 -p 8085:80 mysql-slave\n```\n\n### SSH into the Slave server\n\nAccess the container’s terminal:\n\n```bash\ndocker exec -it mysql-slave bash\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshashank-bhat-collpoll%2Fslave-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshashank-bhat-collpoll%2Fslave-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshashank-bhat-collpoll%2Fslave-server/lists"}