Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
maria_ha_maxscale [2020/10/22 17:14] – [Setup Galera Cluster] andonovj | maria_ha_maxscale [2020/10/24 18:17] (current) – [Testing the Environment] andonovj | ||
---|---|---|---|
Line 18: | Line 18: | ||
* node4 | * node4 | ||
- | =====Setting up===== | + | =====Configuration===== |
- | To set up we have to install the packages and configure the repositories. Do that on all nodes in the cluster. In our case on all 4: | + | The whole processes will go as follows: |
+ | - Install MariaDB and Maxscale on all nodes | ||
+ | - Configure Galera Cluster | ||
+ | - Configure Maxscale | ||
+ | - Feature tests | ||
+ | ====Setup Repo==== | ||
< | < | ||
[root@node1 ~]# curl -sS https:// | [root@node1 ~]# curl -sS https:// | ||
Line 110: | Line 115: | ||
* innodb_autoinc_lock_mode – This setting defines how the InnoDB Storage Engine generates values for auto_increment columns. Using mode 2 here is very important for Galera to work properly. In short, mode 2 cause much less locking during auto_increment generation and hence doesn’t interfere with other locking. Values other than 2 can cause deadlocking and other issues with Galera. | * innodb_autoinc_lock_mode – This setting defines how the InnoDB Storage Engine generates values for auto_increment columns. Using mode 2 here is very important for Galera to work properly. In short, mode 2 cause much less locking during auto_increment generation and hence doesn’t interfere with other locking. Values other than 2 can cause deadlocking and other issues with Galera. | ||
+ | After that we can finally bootstrat the cluster ONLY on the first node: | ||
+ | < | ||
+ | [root@node2 log]# galera_new_cluster | ||
+ | [root@node2 log]# ps -ef | grep mysql | ||
+ | mysql 24722 | ||
+ | root 24749 18744 0 17:12 pts/0 00:00:00 grep --color=auto mysql | ||
+ | [root@node2 log]# ps -ef ^C | ||
+ | [root@node2 log]# | ||
+ | [root@node2 log]# mysql -uroot | ||
+ | Welcome to the MariaDB monitor. | ||
+ | Your MariaDB connection id is 7 | ||
+ | Server version: 10.5.6-MariaDB MariaDB Server | ||
+ | |||
+ | Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. | ||
+ | |||
+ | Type ' | ||
+ | |||
+ | MariaDB [(none)]> | ||
+ | +--------------------+-------+ | ||
+ | | Variable_name | ||
+ | +--------------------+-------+ | ||
+ | | wsrep_cluster_size | 1 | | ||
+ | +--------------------+-------+ | ||
+ | </ | ||
+ | |||
+ | As you can see we have ONLY one member on the first node. | ||
+ | Once that is done start the mysql on the other nodes: | ||
+ | |||
+ | |||
+ | < | ||
+ | [root@node3 ~]# service mariadb start | ||
+ | Redirecting to / | ||
+ | [root@node3 ~]# | ||
+ | [root@node4 ~]# service mariadb start | ||
+ | Redirecting to / | ||
+ | </ | ||
+ | |||
+ | After that, we can see that the members of the cluster increased: | ||
+ | |||
+ | < | ||
+ | MariaDB [(none)]> | ||
+ | +--------------------+-------+ | ||
+ | | Variable_name | ||
+ | +--------------------+-------+ | ||
+ | | wsrep_cluster_size | 3 | | ||
+ | +--------------------+-------+ | ||
+ | 1 row in set (0.000 sec) | ||
+ | |||
+ | MariaDB [(none)]> | ||
+ | </ | ||
+ | |||
+ | ====Prepare users for MaxScale==== | ||
+ | First we need to set up a user that MariaDB MaxScale use to attach to the cluster to get authentication data. On 192.168.10.182, | ||
+ | |||
+ | < | ||
+ | [root@node2 ~]# mysql -uroot | ||
+ | Welcome to the MariaDB monitor. | ||
+ | Your MariaDB connection id is 7 | ||
+ | Server version: 10.5.6-MariaDB MariaDB Server | ||
+ | |||
+ | Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. | ||
+ | |||
+ | Type ' | ||
+ | |||
+ | MariaDB [(none)]> | ||
+ | Query OK, 0 rows affected (0.023 sec) | ||
+ | |||
+ | MariaDB [(none)]> | ||
+ | Query OK, 0 rows affected (0.002 sec) | ||
+ | |||
+ | MariaDB [(none)]> | ||
+ | Query OK, 0 rows affected (0.002 sec) | ||
+ | |||
+ | MariaDB [(none)]> | ||
+ | Query OK, 0 rows affected (0.002 sec) | ||
+ | |||
+ | MariaDB [(none)]> | ||
+ | Query OK, 0 rows affected (0.002 sec) | ||
+ | MariaDB [(none)]> | ||
+ | </ | ||
+ | |||
+ | ====Setup MaxScale==== | ||
+ | The configuration of MaxScale is stored in: "/ | ||
+ | |||
+ | < | ||
+ | # Globals | ||
+ | [maxscale] | ||
+ | threads=1 | ||
+ | admin_secure_gui=false | ||
+ | admin_host=192.168.10.101 | ||
+ | admin_port=8989 | ||
+ | |||
+ | # Servers | ||
+ | [server1] | ||
+ | type=server | ||
+ | address=192.168.10.102 | ||
+ | port=3306 | ||
+ | protocol=MySQLBackend | ||
+ | |||
+ | [server2] | ||
+ | type=server | ||
+ | address=192.168.10.103 | ||
+ | port=3306 | ||
+ | protocol=MySQLBackend | ||
+ | |||
+ | [server3] | ||
+ | type=server | ||
+ | address=192.168.10.104 | ||
+ | port=3306 | ||
+ | protocol=MySQLBackend | ||
+ | |||
+ | # Monitoring for the servers | ||
+ | [Galera-Monitor] | ||
+ | type=monitor | ||
+ | module=galeramon | ||
+ | servers=server1, | ||
+ | user=myuser | ||
+ | password=mypwd | ||
+ | |||
+ | # Galera router service | ||
+ | [Splitter-Service] | ||
+ | type=service | ||
+ | router=readwritesplit | ||
+ | servers=server1, | ||
+ | user=myuser | ||
+ | password=mypwd | ||
+ | |||
+ | # Galera cluster listener | ||
+ | [Splitter-Listener] | ||
+ | type=listener | ||
+ | service=Splitter-Service | ||
+ | protocol=MariaDBClient | ||
+ | address=192.168.10.101 | ||
+ | port=3306 | ||
+ | </ | ||
+ | |||
+ | It took my REALLY LONG TIME, to figure out the configurations as they change from release to release. Like every open source software.... | ||
+ | |||
+ | After that we can start the maxscale: | ||
+ | |||
+ | < | ||
+ | [root@node1 maxscale]# service maxscale start | ||
+ | Redirecting to / | ||
+ | </ | ||
+ | |||
+ | =====Testing the Environment==== | ||
+ | In our test: | ||
+ | - We will connect to the listener on the maxscale server | ||
+ | - Check the server (e.g. server 3) | ||
+ | - Shutdown the MariaDB on the server from step 2) | ||
+ | - Check the server from our connection (we should be moved) | ||
+ | |||
+ | |||
+ | < | ||
+ | [root@node1 maxscale]# mysql -h 192.168.10.101 -P 3306 -u myuser -p | ||
+ | Enter password: | ||
+ | Welcome to the MariaDB monitor. | ||
+ | Your MariaDB connection id is 1 | ||
+ | Server version: 10.5.6-MariaDB MariaDB Server | ||
+ | |||
+ | Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. | ||
+ | |||
+ | Type ' | ||
+ | |||
+ | MariaDB [(none)]> | ||
+ | +---------------+-------+ | ||
+ | | Variable_name | Value | | ||
+ | +---------------+-------+ | ||
+ | | hostname | ||
+ | +---------------+-------+ | ||
+ | </ | ||
+ | |||
+ | Now from the session, connected on node3, shutdown the MariaDB: | ||
+ | |||
+ | < | ||
+ | [root@node3 ~]# systemctl stop mariadb.service | ||
+ | </ | ||
+ | |||
+ | Once we shut down the instance, our session should be moved to running server, so let's check it. | ||
+ | From the first session, without reconnected, | ||
+ | |||
+ | < | ||
+ | MariaDB [(none)]> | ||
+ | +---------------+-------+ | ||
+ | | Variable_name | Value | | ||
+ | +---------------+-------+ | ||
+ | | hostname | ||
+ | +---------------+-------+ | ||
+ | 1 row in set (0.001 sec) | ||
+ | </ | ||
+ | |||
+ | After, we can also connect to the GUI, which should listen on: http:// | ||
+ | |||
+ | ===GUI=== | ||
+ | {{ : | ||
+ | |||
+ | The default credentials are: | ||
+ | Username: admin | ||
+ | Password: mariadb | ||
+ | |||
+ | {{ : | ||