Site icon IT Tutorial

MySQL InnoDB Cluster with MySQL Shell MySQL Router using just Docker containers

Setting up MySQL InnoDB Cluster with MySQL Shell (plus MySQL Router) using just Docker containers.
MySQL InnoDB cluster provides a complete high availability solution for MySQL. Each MySQL server instance runs MySQL Group Replication, which provides the mechanism to replicate data within InnoDB clusters, with built-in failover.

 

MySQL Shell
MySQL server min 3 servers
Mysql Router as a loadbalancer

wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
rpm -ivh mysql80-community-release-el7-3.noarch.rpm
yum install mysql-shell -y

Install MysqlRouter only on the application server from yum repo.

yum install mysql-shell -y

sudo yum install mysql-router -y

mysqlsh –uri root@localhost
Not_so_secure1!
Not_so_secure1!

Do this on all instance

dba.configureInstance()
provide password
2

innodbcluster
Strong_Password1!

dba.checkInstanceConfiguration(‘innodbcluster@mysql1’)

\c innodbcluster@mysql2:3306
var mycls= dba.createCluster(‘MUGHEES_CLS’)
mycls.describe()
mycls.status()
mycls.SetupRouterAccount(‘myrouter’)

On First Prmry:

mycls.addinstance(‘mysql2:3306’)
mycls.addinstance(‘mysql3:3306’)

On Router server:
mysqlrouter –bootstrap MUGHEES_CLS@mysql1 -d myrouter_idc –account=myrouter

mysqlrouter –bootstrap MUGHEES_CLS@mysql1 –user mysqlrouter

##############Servers: mysql1:####################

CREATE USER ‘myadmin’@’%’ IDENTIFIED BY ‘Strong_Password1!’
Grant all privileges on *.* to myadmin’@’%’ with grant option;

mysqlsh –uri root@localhost

\sql
select @@hostname;
CREATE DATABASE schoool;USE schoool;
CREATE TABLE if not exists schoool.student(stndid int primary key auto_increment,stdname varchar(100),phone int,classid int);
INSERT schoool.student(stdname,phone,classid) values(‘Aslam’,123456977,7);INSERT schoool.student(stdname,phone,classid) values(‘Mughees’,123456977,8);
INSERT schoool.student(stdname,phone,classid) values(‘Ahmed’,123456977,9);
SELECT * FROM schoool.student;

select @@hostname;

####################Servers: mysq12####################

mysqlsh root@localhost

\sql
select @@hostname

SELECT * FROM schoool.student;

 

Exit mobile version