Git Product home page Git Product logo

docker-mysql-replication's Introduction

docker-mysql-replication

基于docker 的MySQL主从配置

Running with docker-compose

Step1: 启动容器

docker-compose up --build -d

Step2: 连接master,并运行以下命令,创建一个用户用来同步数据

GRANT REPLICATION SLAVE ON *.* to 'backup'@'%' identified by '123456';

Step3: 查看master status, 记住File、Position的值,如果没查到数据,请检查第一、第二步,配置问题。 我查出来的是mysql-bin.000004、312

show master status;

Step4: 连接slave, 运行以下命令连接master

change master to master_host='<master-ip>',master_user='backup',master_password='123456', master_log_file='mysql-bin.000004',master_log_pos=312,master_port=3307;

Step5: 启动slave

start slave;

Step6: 查看slave status。

show slave status;

如果看到Waiting for master send event 什么的就成功了,你现在在主库上的修改,都会同步到从库上。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.