1. Disable selinux & firewalld
[root@mysqlrouter data]# sestatus
SELinux status: disabled
[root@mysqlrouter data]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@mysqlrouter data]#
2. additional hosts
[root@mysqlrouter data]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.10.10.45 mysqlrouter
10.10.10.51 mariadb01
10.10.10.52 mariadb02
[root@mysqlrouter data]#
3. install client mariadb mysql
[root@mysqlrouter data]# yum install mariadb -y
4. Download & Install mysqlrouter
[root@mysqlrouter data]# wget https://dev.mysql.com/get/Downloads/MySQL-Router/mysql-router-community-8.0.29-1.el7.x86_64.rpm
[root@mysqlrouter data]# ls
mysql-router-community-8.0.29-1.el7.x86_64.rpm
[root@mysqlrouter data]#
[root@mysqlrouter data]# yum install mysql-router-community-8.0.29-1.el7.x86_64.rpm -y
5. Start mysqlrouter
[root@mysqlrouter data]# systemctl enable mysqlrouter
Created symlink from /etc/systemd/system/multi-user.target.wants/mysqlrouter.service to /usr/lib/systemd/system/mysqlrouter.service.
[root@mysqlrouter data]# systemctl enable mysqlrouter
6. Configuration mysqlrouter.conf
[root@mysqlrouter data]# cat /etc/mysqlrouter/mysqlrouter.conf
..........................
# Documentation is available at
# http://dev.mysql.com/doc/mysql-router/en/
[DEFAULT]
logging_folder = /var/log/mysqlrouter
runtime_folder = /run/mysqlrouter
config_folder = /etc/mysqlrouter
plugin_folder = /usr/lib64/mysqlrouter
data_folder = /etc/mysqlrouter/data
[logger]
level = INFO
filename = mysqlrouter.log
[routing:basic_failover]
bind_address = 0.0.0.0
bind_port = 7001
mode = read-write
destinations = 10.10.10.51:3306,10.10.10.52:3306
[routing:load_balance]
bind_address = 0.0.0.0
bind_port = 7002
mode = read-only
destinations = 10.10.10.51:3306,10.10.10.52:3306
# If no plugin is configured which starts a service, keepalive
# will make sure MySQL Router will not immediately exit. It is
# safe to remove once Router is configured.
[keepalive]
interval = 60
[root@mysqlrouter data]#
7. enable profile
[root@mysqlrouter mysqlrouter]# mysqlrouter -c /etc/mysqlrouter/mysqlrouter.conf
[root@mysqlrouter data]# cat /etc/profile
# /etc/profile
export PATH=$PATH:/usr/bin/mysqlrouter
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
....
[root@mysqlrouter data]#
8. Login mysql cluster from mysqlrouter
[root@mysqlrouter mysqlrouter]# mysql -u root -p -h 10.10.10.45 -P 7001
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.1.48-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> select @@hostname;
+------------+
| @@hostname |
+------------+
| mariadb01 |
+------------+
1 row in set (0.01 sec)
MariaDB [(none)]>
9 Try stop mariadb01 stop & check again status
MariaDB [(none)]> select @@hostname;
ERROR 2013 (HY000): Lost connection to MySQL server during query
MariaDB [(none)]> select @@hostname;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 4
Current database: *** NONE ***
+------------+
| @@hostname |
+------------+
| mariadb02 |
+------------+
1 row in set (0.04 sec)
MariaDB [(none)]>
10. check mysqlrouter version
[root@mysqlrouter data]# mysqlrouter -V
MySQL Router Ver 8.0.29 for Linux on x86_64 (MySQL Community - GPL)
[root@mysqlrouter data]#
mantap mas teguh
ReplyDelete