Coder Social home page Coder Social logo

aaronbbrown / mysql-failover Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amplify-holding/mysql-failover

0.0 2.0 1.0 748 KB

MySQL master/master failover using ZooKeeper for coordination

License: MIT License

Ruby 96.91% Shell 2.92% HTML 0.17%

mysql-failover's Introduction

Amplify::Failover

Overview

Architecture Diagram

Running it

To build

./build.sh

To run

./go

To specify the config file

FAILOVER_CONFIG=config/myconfig.yaml ./go

To specify the server port

FAILOVER_CONFIG=config/myconfig.yaml ./go server[8888]

Privileges Required

MySQL Watchdog

The MySQL watchdog MySQL user requires the following privileges

  • SUPER on *.* to set read_only on and off, stop/start slaves
  • PROCESS on *.* to kill attached connections
  • ALL PRIVILEGES on the failover database in order to create and read/write to the tracking table

The system user only needs privileges to read the config file and bind to the specified port.

Application Watchdog

The system user requires the following permissions and privileges

  • read the config file and bind to the specified port
  • execute the commands specified in application.cmd_on_* in the config file. This probably means limited sudo access in order to restart the service.

How to Fail Over A Database

Any of these commands may be executed by SSHing into any node within an environment and application that is running the failover watchdog. For example, mysql-001, mysql-002, web-001, web-002 all run the failover watchdog for the named application.

To list available fail over targets

$ sudo java -jar /opt/failover/failover.war -S bin/failover -c /etc/failover/failover.yaml list
Available fail over targets (* denotes currently active master):
* mysql-001
  mysql-002

To fail over to a new database

$ sudo java -jar /opt/failover/failover.war -S bin/failover -c /etc/failover/failover.yaml failover mysql-002
I, [2014-03-12T17:39:12.662000 #1969]  INFO -- : Failing over to mysql-002...
I, [2014-03-12T17:39:13.050000 #1969]  INFO -- : /failover_state changed.  New value: transitioning
I, [2014-03-12T17:39:13.054000 #1969]  INFO -- : State changed to transitioning
I, [2014-03-12T17:39:13.055000 #1969]  INFO -- : Failover in progress...
I, [2014-03-12T17:39:13.115000 #1969]  INFO -- : /failover_state changed.  New value: complete
I, [2014-03-12T17:39:13.116000 #1969]  INFO -- : State changed to complete
I, [2014-03-12T17:39:13.122000 #1969]  INFO -- : Failover complete.

Failing over to a new database can take at least 60 seconds, depending on the value of mysql.tracking_max_wait_secs in failover.yml. If it takes more than 2x tracking_max_wait_secs, something might be stuck and you should look at the logs on other hosts.

mysql-failover's People

Contributors

aaronbbrown avatar

Watchers

 avatar  avatar

Forkers

liuqian1990

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.