hostnamectl set-hostname mysql-xxxx
install mysql tools
wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.22-1_all.deb
sudo apt-get update
sudo apt-get install mysql-router
sudo apt-get install mysql-shell
sudo apt-get install mysql-community-server
Edit configure file.
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
sudo service mysql restart
create user 'root'@'%' identified by 'trantech@128';
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;
vi /etc/hosts
10.2.1.154 mysql-master1
10.2.1.144 mysql-master2
10.2.1.150 mysql-master3
10.2.1.155 mysql-router
Login:
mysqlsh
MySQL JS > \connect --mysql root@localhost:3301
dba.configureInstance("root@localhost:3303")
cluster = dba.createCluster("demo")
cluster.status()
cluster.addInstance("root@localhost:3302")
cluster.addInstance("root@localhost:3303")
cluster.status()
CREATE TABLE movies(title VARCHAR(50) NOT NULL,genre VARCHAR(30) NOT NULL,director VARCHAR(60) NOT NULL,release_year INT NOT NULL,PRIMARY KEY(title));
mysqlrouter --bootstrap root@localhost:3301 --directory=demo_router
mysqlrouter -c mysqlrouter.conf
\c root@localhost:3301
\sql stop group_replication;
\c root@localhost:3301
\sql start group_replication;
sudo mysqlrouter --bootstrap root@mysql-master1 --user=mysqlrouter
/etc/mysqlrouter/** rw, /var/lib/mysqlrouter/** rw,
- Read/Write Connections: localhost:6446
- Read/Only Connections: localhost:6447
- Read/Write Connections: localhost:6448
- Read/Only Connections: localhost:6449
mysqlsh
\c root@localhost:6447
\sql