Speaking of mysql clusters, it is estimated that many people will first think of mysql's built-in replication or mysql-mmm. Mysql-mmm is actually based on the built-in replication of mysql, but the encapsulation is better, but it is still difficult to configure, And it is powerless to dynamically increase or decrease the master node.
By chance, I learned that there is a mysql-Based Cluster galera. Apart from InnoDB only, there are basically no disadvantages. Let's take a look at what the official saying is:
To put it bluntly, start testing immediately. The OS used for testing is 64-bit CentOS 6. First, add the software repository of MariaDB and create the file "/etc/yum. repos. d/MariaDB. repo ".
# MariaDB 5.5 CentOS repository list - created 2013-11-05 06:30== http://yum.mariadb.org/5.5==1
# yum -y install MariaDB-Galera-server.x86_64 MariaDB-client.x86_64 galera.x86_64
# Cp/usr/share/mysql/wsrep. cnf/etc/my. cnf. d/
By default, Galera uses port 4567 to synchronize data. You need to modify the firewall. In this case, the firewall is disabled directly.
# /etc/init.d/iptables stop
MariaDB-Galera does not seem to provide you with the supporting selinux configuration. For convenience, selinux is directly disabled.
# setenforce 0
Since it is a cluster, of course, there cannot be only one machine
Modify "/etc/my. cnf. d/wsrep. cnf" of machine.
=="gcomm://"=192.168.56.103
Because machine a is the first node, you can enter "gcomm: //" in wsrep_cluster_address. To join a cluster, enter the ip address of any node in the cluster, for example, "gcomm: // 192.168.56.103: 4567 ". Wsrep_sst_receive_address is the ip address used by the local machine to receive synchronization data. By default, it is the first ip address found in the machine network configuration. If the machine has multiple ip addresses, you 'd better specify them, for example, "192.168.56.103 ". Start mysql Database Service
# /etc/init.d/mysql start
Now we need to add machine B to the cluster and modify the configuration file "/etc/my. cnf. d/wsrep. cnf ".
=="gcomm://192.168.56.103:4567"=192.168.56.104
Start the mysql service of machine B.
Now the cluster has been set up, and now the cluster is officially tested. First, connect to machine a's mysql service and create a database and a table. The table contains an AUTO_INCREMENT field that makes mysql-mmm troublesome and troublesome, by the way, add a user to access this database.
# mysql the MariaDB monitor. Commands ; .33aMariaDB MariaDB Server, wsrep_23., , Oracle, Monty Program Ab help. Type clear the row affected ( asdf. @ identified rows affected ( aatt (aa rows affected ( aatt ( row affected ( aatt ( row affected ( aa rows ( sec)
The step of auto_increment is automatically changed to 2. Is it intelligent? Now we go to machine B and use the new user name to log on to the mysql service and perform similar operations.
# mysql u aauu the MariaDB monitor. Commands ; .33aMariaDB MariaDB Server, wsrep_23., , Oracle, Monty Program Ab help. Type clear the aatt ( row affected ( aatt ( row affected ( aa rows ( sec)
No? There is nothing worth mentioning about the data inserted just now. What's amazing is that the new user on machine a can be used here! Now let's dynamically add machine c to the cluster.
=="gcomm://192.168.56.104:4567"=192.168.56.105
As mentioned before, you can add the ip addresses of any node in the cluster. Start the mysql service of machine c and perform similar operations
# mysql the MariaDB monitor. Commands ; .33aMariaDB MariaDB Server, wsrep_23., , Oracle, Monty Program Ab help. Type clear the information completion this feature get a quicker startup aatt ( row affected ( aatt ( row affected ( aa rows ( sec)
The step of auto_increment is automatically changed to 3. Do you see it?
Here I just briefly list a use case of Galera, and there are many advanced aspects of Galera that I did not mention here. You can check it on its official website.
Reference URL: