A Replication between MySql and MariaDB with SymmetricDS

A Replication between MySql and MariaDB with SymmetricDS

apt-get install mysql-server-5.6

mysql -u root -proot -e “CREATE DATABASE corp;”

mkdir -p /data/mariadb1

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

docker exec -it store001 bash

root@2954e5d5249c:/# export TERM=dumb

root@2954e5d5249c:/# mysql -u root -psecret -e ‘CREATE DATABASE store001;’
root@2954e5d5249c:/# exit

SEED_IP=$(docker inspect -f ‘{{ .NetworkSettings.IPAddress }}’ store001)

echo $SEED_IP
172.17.0.5

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=store002 irmann/galera-mariadb-10.0-xtrabackup seed

docker exec -it store002 bash

root@2954e5d5249c:/# export TERM=dumb

root@2954e5d5249c:/# mysql -u root -psecret -e ‘CREATE DATABASE store002;’
root@2954e5d5249c:/# exit

SEED_IP=$(docker inspect -f ‘{{ .NetworkSettings.IPAddress }}’ store002)

echo $SEED_IP
172.17.0.6

– download symmetric-server from http://sourceforge.net/projects/symmetricds/files/symmetricds/symmetricds-3.7/symmetric-server-3.7.10.zip/download

unzip symmetric-server-3.7.10.zip -d ~/opt/
cd ~/opt/symmetric-server-3.7.10/samples
subl corp-000.properties

engine.name=corp-000
group.id=corp
external.id=000
sync.url=http://localhost:31415/sync/corp-000
registration.url=
db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost/corp?tinyInt1isBit=false
db.user=root
db.password=root

job.purge.period.time.ms=7200000
job.routing.period.time.ms=5000
job.push.period.time.ms=10000
job.pull.period.time.ms=10000
initial.load.create.first=true

subl store-001.properties

engine.name=store-001
group.id=store
external.id=001
db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://172.17.0.5/store001?tinyInt1isBit=false
db.user=root
db.password=secret
registration.url=http://localhost:31415/sync/corp-000
job.routing.period.time.ms=5000
job.push.period.time.ms=10000
job.pull.period.time.ms=10000

subl store-002.properties

engine.name=store-002
group.id=store
external.id=002
db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://172.17.0.6/store002?tinyInt1isBit=false
db.user=root
db.password=secret
registration.url=http://localhost:31415/sync/corp-000
job.routing.period.time.ms=5000
job.push.period.time.ms=10000
job.pull.period.time.ms=10000

cp corp-000.properties ../engines/
cp store-001.properties ../engines/
cp store-002.properties ../engines/

../bin/dbimport –engine corp-000 –format XML –alter-case create_sample.xml
../bin/symadmin –engine corp-000 create-sym-tables
../bin/dbimport –engine corp-000 insert_sample.sql
../bin/sym

../bin/symadmin –engine corp-000 reload-node 001
../bin/symadmin –engine corp-000 reload-node 002

mysql -u root -proot -D corp

insert into item (item_id, name) values (110000055, ‘Soft Drink’);
insert into item_selling_price (item_id, store_id, price)
values (110000055, ‘001’, 0.65);
insert into item_selling_price (item_id, store_id, price)
values (110000055, ‘002’, 1.00);

docker exec -it store001 bash

root@2954e5d5249c:/# export TERM=dumb

root@2954e5d5249c:/# mysql -u root -psecret -D store001

select * from item_selling_price
-> ;
+———–+———-+——-+——+
| item_id | store_id | price | cost |
+———–+———-+——-+——+
| 11000001 | 001 | 0.20 | 0.10 |
| 110000055 | 001 | 0.65 | NULL |
+———–+———-+——-+——+

Advertisements

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;'

csaandra cluster with multi-host docker

in server 192.168.112.101 to run a cassandra seed node, where in cassandra.yaml, listen_address ,broadcast_address and rpc_address is 192.168.112.101

docker run –net=host -d –name cass1 -p 9042:9042 -p 7001:7001 -p 7000:7000 -p 7199:7199 -p 9160:9160 _YOUR_DOCKER_IMAGE_

in server 192.168.112.102 to run a cassandra node, where in cassandra.yaml, listen_address ,broadcast_address, rpc_address and seeds parameter is 192.168.112.102.

- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters: - seeds: "192.168.112.101"

docker run --net=host -d --name cass2 _YOUR_DOCKER_IMAGE_

192.168.112.102 and 192.168.112.101 should see ports 7000,7001,9042 and 7199 of each other.