Non classé

Simplify multi instance management with easymysql

Easymysql

EasyMysql is a helper Bash script for MySQL multi instance management.

Git Hub source repository

https://github.com/jmrenouard/easymysql

Purpose

This tools is a simple Bash script that help you to clone and manage several MySQL server instances on the same server.


It supports 6 main features:

  • clone
  • destroy
  • start
  • stop
  • restart
  • status

Installation from Git

1
# git clone https://github.com/jmrenouard/easymysql

Download Source from GitHub

1
2
# curl https://github.com/jmrenouard/easymysql/archive/master.zip
# unzip master.zip

Setup

1
# source mysql_functions.sh

Examples

  • Cloning a instance standard 3306 instance
1
2
# source mysql_functions.sh
# mclone 1
  • Cloning MySQL instance 1 port 3307
1
2
# source mysql_functions.sh
# mclone 2 1
  • Destroying MySQL instance 2
1
2
# source mysql_functions.sh
# mdestroy 2
  • Getting the status of all MySQL instances
1
2
3
4
5
6
# source mysql_functions.sh
# mstatus
ID DIRECTORY PORT STATUS PID
PRI /var/lib/mysql 3306 ON 2144
1 /var/lib/mysql1 3307 ON 3029
2 /var/lib/mysql2 3308 ON 3048
  • Stopping MySQL instance 2
1
2
3
4
5
6
7
# source mysql_functions.sh
 # mstop 2
 # mstatus
 ID DIRECTORY PORT STATUS PID
 PRI /var/lib/mysql 3306 ON 2144
 1 /var/lib/mysql1 3307 ON 3029
 2 /var/lib/mysql2 3308 OFF
  • Starting MySQL instance 2
1
2
3
4
5
6
7
# source mysql_functions.sh
# mstart 2
# mstatus
ID DIRECTORY PORT STATUS PID
PRI /var/lib/mysql 3306 ON 2144
1 /var/lib/mysql1 3307 ON 3029
2 /var/lib/mysql2 3308 ON 3049
  • Restarting MySQL instances 1 2
1
2
3
4
5
6
7
# source mysql_functions.sh
# mrestart 1 2
# mstatus
ID DIRECTORY PORT STATUS PID
PRI /var/lib/mysql 3306 ON 2144
1 /var/lib/mysql1 3307 ON 3029
2 /var/lib/mysql2 3308 ON 3049
  • Creating 10 MySQL instances at once
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# source mysql_functions.sh
 # for i in `seq 1 10`; do mclone $i; done
 # mstatus
 ID DIRECTORY PORT STATUS PID
 PRI /var/lib/mysql 3306 ON 2144
 1 /var/lib/mysql1 3307 ON 3029
 10 /var/lib/mysql10 3316 ON 4018
 2 /var/lib/mysql2 3308 ON 3048
 3 /var/lib/mysql3 3309 ON 3562
 4 /var/lib/mysql4 3310 ON 3627
 5 /var/lib/mysql5 3311 ON 3692
 6 /var/lib/mysql6 3312 ON 3757
 7 /var/lib/mysql7 3313 ON 3822
 8 /var/lib/mysql8 3314 ON 3887
 9 /var/lib/mysql9 3315 ON 3952
  • Stopping 10 first MySQL instances
1
2
# source mysql_functions.sh
# mstart `seq 1 10`
  • Destroying 10 MySQL instances
1
2
# source mysql_functions.sh
# mdestroy `seq 1 10`
  • Getting a mysql client on MySQL instances 7
1
2
3
# source mysql_functions.sh
# mclient 7
mysql> ...
  • Requesting from a mysql client on MySQL instances 4
1
2
3
4
# source mysql_functions.sh
# mclient 4 select @@server_id
@@server_id
4

Support easymysql script

Bugs report

https://github.com/jmrenouard/easymysql/issues

Pull request

https://github.com/jmrenouard/easymysql/pulls

Send an email

jmrenouard@gmail.com

4 thoughts on “Simplify multi instance management with easymysql”

  1. What’s up i am kavin, its my first time
    to commenting anywhere, when i read this piece of writing
    i thought i could also make comment due to this brilliant post.

  2. I’ve been exploring for a bit for any high quality articles or blog posts in this kind of space
    . Exploring in Yahoo I ultimately stumbled upon this web
    site. Studying this information So i’m satisfied to express
    that I’ve an incredibly excellent uncanny feeling
    I found out exactly what I needed. I so much indisputably will make sure to don?t omit this site and provides it a look regularly.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.