https://github.com/devopsmakers/go-sakila-remora
A sidecar process written in Go to monitor MySQL slaves / masters for replication errors or lag. Inspired by: https://githubengineering.com/context-aware-mysql-pools-via-haproxy/
https://github.com/devopsmakers/go-sakila-remora
devops golang haproxy healthcheck mysql percona slave wip
Last synced: about 2 months ago
JSON representation
A sidecar process written in Go to monitor MySQL slaves / masters for replication errors or lag. Inspired by: https://githubengineering.com/context-aware-mysql-pools-via-haproxy/
- Host: GitHub
- URL: https://github.com/devopsmakers/go-sakila-remora
- Owner: devopsmakers
- License: unlicense
- Created: 2017-02-23T13:19:03.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-12-13T23:05:23.000Z (over 8 years ago)
- Last Synced: 2025-01-11T15:48:04.807Z (over 1 year ago)
- Topics: devops, golang, haproxy, healthcheck, mysql, percona, slave, wip
- Language: Go
- Homepage:
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# go-sakila-remora
[](https://travis-ci.org/devopsmakers/go-sakila-remora)
[](https://goreportcard.com/report/github.com/devopsmakers/go-sakila-remora)
[](https://codecov.io/gh/devopsmakers/go-sakila-remora)
A sidecar process written in Go to monitor MySQL slaves / masters for replication errors or lag.
## Welcome!
Hi! and thanks for stopping by this project in it's early days.
Inspired by GitHub's interesting article:
https://githubengineering.com/context-aware-mysql-pools-via-haproxy/
It's similar to methods I've used previously to manage traffic being sent
to Asterisk VoIP servers based on various metrics.
## Project goals
Ultimately, I'm pretty new to Go and thought this would be an interesting
challenge and an awesome product if everything turns out well.
### Phase 1:
The initial iteration will handle reading YAML configuration, executing some
basic checks against MySQL and presenting a JSON based endpoint for health
checking against. After this iteration I should have a decent BVP - Barely
Viable Product.
### Phase 2:
Let's not get ahead of ourselves.
## Percona master / slave for testing
I needed a really quick way to be able to:
* Spin up a master and slave with replication configured
* Create lag on the slave
* Stop lag on the slave
To do this I've thrown together a really dirty `docker-compose` file and a Makefile
with the following targets:
| Target | Description |
| -------------- | :-------------------------------------------------------: |
|`make up` | Brings up the master, slave and sets up replication |
|`make down` | Runs `docker-compose down` cleaning everything up |
|`make start-lag`| Uses `MASTER_DELAY=300` to start the slave lagging |
|`make stop-lag` | Stops slave lag by setting `MASTER_DELAY=0` |
|`make slave-lag`| Shows the current value of `Seconds_Behind_Master` |
|`make stuff` | Does some SQL stuff - a `CREATE` and `DROP` of a database |
### MySQL Ports
When running the containers you can access MySQL on host: `127.0.0.1` with:
* User: `root`
* Pass: `secret`
* Master Port: `3306`
* Slave Port: `3307`
> Obviously: Please! Please! Please! Don't ever use these settings or config
> In production (or any other application environment). This is for quick and
> dirty testing and development of `go-sakila-remora`.
### Simulating slave lag
To simulate slave lag for testing is super easy:
1. `make up` to bring up a master / slave and configure replication
2. `make start-lag` to start the slave lagging (up to 300s)
3. `make stuff` to do some SQL stuff and things
4. `make slave-lag` a few times to see the lag increasing
5. `make stop-lag` stops the slave lagging