2.1 doc esak (#127)
* Update MySQL-Replication-Read-Write-Splitting-Tutorial.md * Update MySQL-Replication-Read-Write-Splitting-Tutorial.md * Update MySQL-Replication-Read-Write-Splitting-Tutorial.md * Update MySQL-Cluster-Setup.md * Update Administration-Tutorial.md * Update Administration-Tutorial.md * Update Galera-Cluster-Connection-Routing-Tutorial.md * Update CLI.md * Update ReadWriteSplit.md * Update Tee-Filter.md * Update CCRFilter.md * Update RabbitMQ-Filter.md * Update Debug-And-Diagnostic-Support.md * Update MaxBinlogCheck.md * Update Configuration-Guide.md * Update Module-Commands.md
This commit is contained in:
@ -1,30 +1,8 @@
|
||||
# MySQL Cluster setup and MariaDB MaxScale configuration
|
||||
|
||||
Massimiliano Pinto
|
||||
|
||||
Last Updated: 1st August 2014
|
||||
|
||||
## Contents
|
||||
|
||||
## Document History
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>Date</td>
|
||||
<td>Change</td>
|
||||
<td>Who</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>31st July 2014</td>
|
||||
<td>Initial version</td>
|
||||
<td>Massimiliano Pinto</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
## Overview
|
||||
|
||||
The document covers the MySQL Cluster 7.2.17 setup and MariaDB MaxScale configuration in order to load balancing the SQL nodes access.
|
||||
The document covers the MySQL Cluster 7.2.17 setup and MariaDB MaxScale configuration for load balancing the SQL nodes access.
|
||||
|
||||
## MySQL Cluster setup
|
||||
|
||||
@ -32,19 +10,16 @@ The MySQL Cluster 7.2.17 setup is based on two virtual servers with Linux Centos
|
||||
|
||||
- server1:
|
||||
|
||||
NDB Manager process
|
||||
* NDB Manager process
|
||||
* SQL data node1
|
||||
* MySQL 5.5.38 as SQL node1
|
||||
|
||||
SQL data node1
|
||||
- server2:
|
||||
|
||||
MySQL 5.5.38 as SQL node1
|
||||
* SQL data node2
|
||||
* MySQL 5.5.38 as SQL node2
|
||||
|
||||
- server2:
|
||||
|
||||
SQL data node2
|
||||
|
||||
MySQL 5.5.38 as SQL node2
|
||||
|
||||
Cluster configuration file is /var/lib/mysql-cluster/config.ini, copied on all servers
|
||||
Cluster configuration file is `/var/lib/mysql-cluster/config.ini`, copied on all servers.
|
||||
|
||||
```
|
||||
[ndbd default]
|
||||
@ -70,7 +45,7 @@ hostname=178.62.38.199
|
||||
hostname=162.243.90.81
|
||||
```
|
||||
|
||||
Note, it’s possible to specify all node ids and datadir as well for each cluster component
|
||||
Note that it’s possible to specify all node id:s and `datadir` as well for each cluster component.
|
||||
|
||||
Example:
|
||||
|
||||
@ -81,7 +56,7 @@ id=43
|
||||
datadir=/usr/local/mysql/data
|
||||
```
|
||||
|
||||
and /etc/my.cnf, copied as well in all servers
|
||||
Also, `/etc/my.cnf`, copied as well in all servers.
|
||||
|
||||
```
|
||||
[mysqld]
|
||||
@ -95,31 +70,38 @@ ndb-connectstring=178.62.38.199
|
||||
|
||||
## Startup of MySQL Cluster
|
||||
|
||||
Each cluster node process must be started separately, and on the host where it resides. The management node should be started first, followed by the data nodes, and then finally by any SQL nodes:
|
||||
Each cluster node process must be started separately, and on the host where it resides. The management node should be started first, then the data nodes, and finally any SQL nodes:
|
||||
|
||||
- On the management host, server1, issue the following command from the system shell to start the management node process:
|
||||
|
||||
```
|
||||
[root@server1 ~]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini
|
||||
```
|
||||
|
||||
- On each of the data node hosts, run this command to start the ndbd process:
|
||||
|
||||
```
|
||||
[root@server1 ~]# ndbd —-initial -—initial-start
|
||||
|
||||
[root@server2 ~]# ndbd —-initial -—initial-start
|
||||
```
|
||||
|
||||
- On each SQL node start the MySQL server process:
|
||||
|
||||
```
|
||||
[root@server1 ~]# /etc/init.d/mysql start
|
||||
|
||||
[root@server2 ~]# /etc/init.d/mysql start
|
||||
```
|
||||
|
||||
## Check the cluster status
|
||||
|
||||
If all has gone well, and the cluster has been set up correctly, the cluster should now be operational.
|
||||
If all has gone well and the cluster has been set up correctly, the cluster should now be operational.
|
||||
|
||||
It’s possible to test this by invoking the ndb_mgm management node client.
|
||||
It’s possible to test this by invoking the `ndb_mgm` management node client.
|
||||
|
||||
The output should look as shown here, although you might see some slight differences in the output depending upon the exact version of MySQL in use:
|
||||
|
||||
The output should look like that shown here, although you might see some slight differences in the output depending upon the exact version of MySQL that you are using:
|
||||
```
|
||||
[root@server1 ~]# ndb_mgm
|
||||
|
||||
@ -151,11 +133,13 @@ id=23 @162.243.90.81 (mysql-5.5.38 ndb-7.2.17)
|
||||
|
||||
ndb_mgm>
|
||||
```
|
||||
|
||||
The SQL node is referenced here as [mysqld(API)], which reflects the fact that the mysqld process is acting as a MySQL Cluster API node.
|
||||
|
||||
## Working with NDBCLUSTER engine in MySQL
|
||||
|
||||
- First create a table with NDBCLUSTER engine:
|
||||
|
||||
```
|
||||
[root@server1 ~]# mysql
|
||||
|
||||
@ -179,13 +163,17 @@ mysql> show create table t1;
|
||||
|
||||
1 row in set (0.01 sec)
|
||||
```
|
||||
- Just add a row in the table:
|
||||
|
||||
- Add a row in the table:
|
||||
|
||||
```
|
||||
mysql> insert into test.t1 values(11);
|
||||
|
||||
Query OK, 1 row affected (0.15 sec)
|
||||
```
|
||||
|
||||
- Select the current number of rows:
|
||||
|
||||
```
|
||||
mysql> select count(1) from t1;
|
||||
|
||||
@ -197,7 +185,9 @@ mysql> select count(1) from t1;
|
||||
|
||||
1 row in set (0.07 sec)
|
||||
```
|
||||
- The same from the MySQL client pointing to SQL node on server2
|
||||
|
||||
- The same from the MySQL client pointing to SQL node on server2:
|
||||
|
||||
```
|
||||
[root@server2 ~]# mysql
|
||||
|
||||
@ -211,9 +201,11 @@ mysql> select count(1) from test.t1;
|
||||
|
||||
1 row in set (0.08 sec)
|
||||
```
|
||||
|
||||
## Configuring MariaDB MaxScale for connection load balancing of SQL nodes
|
||||
|
||||
Add these sections in maxscale.cnf config file:
|
||||
Add these sections into the maxscale.cnf config file:
|
||||
|
||||
```
|
||||
[Cluster Service]
|
||||
type=service
|
||||
@ -253,13 +245,17 @@ address=162.243.90.81
|
||||
port=3306
|
||||
protocol=MySQLBackend
|
||||
```
|
||||
Assuming MariaDB MaxScale is installed in server1, start it
|
||||
|
||||
Assuming MariaDB MaxScale is installed in server1, start it.
|
||||
|
||||
```
|
||||
[root@server1 ~]# cd /usr/bin
|
||||
|
||||
[root@server1 bin]# ./maxscale -c ../
|
||||
```
|
||||
Using the debug interface it’s possible to check the status of monitored servers
|
||||
|
||||
Using the debug interface it’s possible to check the status of monitored servers.
|
||||
|
||||
```
|
||||
MaxScale> show monitors
|
||||
|
||||
@ -300,9 +296,11 @@ Number of connections: 0
|
||||
Current no. of conns: 0
|
||||
Current no. of operations: 0
|
||||
```
|
||||
It’s now possible to run basic tests with the read connection load balancing for the two configured SQL nodes
|
||||
|
||||
It’s now possible to run basic tests with the read connection load balancing for the two configured SQL nodes.
|
||||
|
||||
(1) test MaxScale load balancing requesting the Ndb_cluster_node_id variable:
|
||||
|
||||
```
|
||||
[root@server1 ~]# mysql -h 127.0.0.1 -P 4906 -u test -ptest -e "SHOW STATUS LIKE 'Ndb_cluster_node_id'"
|
||||
|
||||
@ -320,9 +318,11 @@ It’s now possible to run basic tests with the read connection load balancing
|
||||
| Ndb_cluster_node_id | 22 |
|
||||
+---------------------+-------+
|
||||
```
|
||||
|
||||
The MariaDB MaxScale connection load balancing is working.
|
||||
|
||||
(2) test a select statement on an NBDBCLUSTER table, database test and table t1 created before:
|
||||
|
||||
```
|
||||
[root@server1 ~] mysql -h 127.0.0.1 -P 4906 -utest -ptest -e "SELECT COUNT(1) FROM test.t1"
|
||||
|
||||
@ -332,10 +332,13 @@ The MariaDB MaxScale connection load balancing is working.
|
||||
| 1 |
|
||||
+----------+
|
||||
```
|
||||
|
||||
(3) test an insert statement
|
||||
|
||||
```
|
||||
mysql -h 127.0.0.1 -P 4906 -utest -ptest -e "INSERT INTO test.t1 VALUES (19)"
|
||||
```
|
||||
|
||||
(4) test again the select and check the number of rows
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user