Coder Social home page Coder Social logo

nabangi / mariadb-in-docker Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 63 KB

SQL Database cluster deployment with Replication monitoring in Docker

License: GNU General Public License v3.0

Shell 59.01% PHP 40.99%
sql docker php bash-script mariadb ubuntu-server database-replication monitoring-server

mariadb-in-docker's Introduction

MariaDB-in-Docker

mariadb container master-slave replication with health Monitoring

Automatically deploy environment by;

Running the deploy_config.sh after clonning the Repo to you Server.

Environment prep and manually deploy

sudo apt update

Installing the Docker engine incase its not installed yet

sudo apt-get remove docker docker-engine docker.io

sudo apt install docker.io

sudo systemctl start docker

sudo systemctl enable docker

logout then login again to enable user rights incase they don't apply immediately

sudo groupadd docker

sudo gpasswd -a "${USER}" docker

usermod -aG docker "${USER}"

Create the database persistent volume to be mounted

mkdir -p /opt/mariadb/master-data

Grant Permissions

sudo chown -R 1001:1001 /opt/mariadb/master-data/

Running containers in dettached mode but when you remove the "-d" it could help with debugging the running configs in the container!

docker run -d or docker-compose up -d 

To login to a container

docker exec -it $container_id bash

mariadb

$ mysql -u my_user -p
  #my_password

after login check databases

show databases;
use my_databse;

then create table form there

exit;

check or configure replication

login with root

$ mysql -u root -p
  #master_root_password

then

show master status;

To import:

docker exec -i adprcc3ms_mariadb-master_1 mysql -uroot -pmaster_root_password my_database < mariadb-master-dump.sql

To export:

docker exec -i adprcc3ms_mariadb-master_1 mysqldump -uroot -pmaster_root_password my_database > mariadb-master-dump.sql

Stop and backup the currently running container, Uncomment the following lines

docker stop $container_id

rsync -a /opt/mariadb/master-data /opt/mariadb/master-data.bkp.$(date +%Y%m%d-%H.%M.%S)

incase you want to scale up number of slaves or scale down

docker-compose up --detach --scale mariadb-master=1 --scale mariadb-slave=3

To clean up

docker stop $container_id

docker rm $container_id

You can also remove all images and stopped contaners using

docker prune -a

Run the following to see if the cronjob you've defined actually runs.

sudo grep CRON /var/log/syslog

VOILAA...!!!

mariadb-in-docker's People

Contributors

nabangi avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.