MairaDB Galera Cluster with Docker


mkdir -p /data/mariadb1
mkdir -p /data/mariadb2

docker run -d -v /data/mariadb2:/var/lib/mysql -p 3306 -p 8080 -e XTRABACKUP_PASSWORD=abc -e MYSQL_ROOT_PASSWORD=secret --name=seed irmann/galera-mariadb-10.0-xtrabackup seed

docker exec -it seed bash

root@2954e5d5249c:/# export TERM=dumb

root@2954e5d5249c:/# mysql -u root -psecret -e 'CREATE DATABASE playground;'

root@2954e5d5249c:/#mysql -u root -psecret -e 'CREATE TABLE playground.equipment ( id INT NOT NULL AUTO_INCREMENT, type VARCHAR(50), quant INT, color VARCHAR(25), PRIMARY KEY(id));'

root@2954e5d5249c:/#mysql -u root -psecret -e 'INSERT INTO playground.equipment (type, quant, color) VALUES ("slide", 2, "blue")'

root@2954e5d5249c:/#mysql -u root -psecret -e 'SELECT * FROM playground.equipment;'

SEED_IP=$(docker inspect -f '{{ .NetworkSettings.IPAddress }}' seed)

echo $SEED_IP
172.17.0.58

docker run -d --name=node -v /data/mariadb1:/var/lib/mysql -p 3306 -p 8080 -e XTRABACKUP_PASSWORD=abc irmann/galera-mariadb-10.0-xtrabackup node 172.17.0.58

docker exec -it node bash

root@ccf73de2218b:/# export TERM=dumb

root@ccf73de2218b:/#mysql -u root -psecret -e 'SELECT * FROM playground.equipment;'

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s