Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use MySQL Fabric to achieve High availability

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "how to use MySQL Fabric to achieve high availability", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use MySQL Fabric to achieve high availability" this article.

Download and install MySQL Fabric

Download MySQL Utilities 1.5 from http://dev.mysql.com/downloads/utilities/, and MySQL Fabric is part of MySQL Utilities 1.5.

MySQL Fabric is supported by downloading java connector,5.1.30 from http://dev.mysql.com/downloads/connector/j/ and later versions.

Second, create MySQL users

You need to create a user on each MySQL instance for MySQL Fabric. You need to close bin log during the process of creating a user on the cluster instance, otherwise when MySQL Fabric creates a master-slave relationship, it will re-execute the operation of creating the same user in master on slave, resulting in an error. The following example assumes that the MySQL Fabric and backing store instances are installed on the same server:

Create a store user on the backing store instance and replace the fabric_store and secret_store in the following code with the appropriate user name and password.

CREATE USER 'fabric_store'@'localhost'

Create a server user on each cluster instance and replace the fabric_server and secret_server in the following code with the appropriate user name and password.

CREATE USER 'fabric_server'@'%'

Create a backup user on each cluster instance and replace the fabric_backup and secret_backup in the following code with the appropriate user name and password.

CREATE USER 'fabric_backup'@'%'

Create a restore user on each cluster instance and replace the fabric_restore and secret_restore in the following code with the appropriate user name and password.

CREATE USER 'fabric_restore'@'%' III. Configure MySQL

Enable gtid-mode, bin-log, and log-slave-updates in each cluster instance, and ensure that the server-id of all cluster instances are not duplicated.

[mysqld] IV. Configure and initialize MySQL Fabric

Modify the [storage] and [servers] sections in / etc/mysql/fabric.cfg to configure users and passwords for store user, server user, backup user and restore user.

[storage]

To initialize store server for mysqlfabric manage setup, you need to set the password for admin/xmlrpc, which is the password used to access MySQL Fabric using the username admin. You can configure this password in the password in the [protocol.xmlrpc] section of the fabric.cfg, otherwise you will be prompted for it every time you execute the MySQL Fabric command.

Start and stop MySQL Fabric

Execute mysqlfabric manage start to start MySQL Fabric.

Execute mysqlfabric manage stop to stop MySQL Fabric.

Create a server group

Execute mysqlfabric group create my_group to create a server group, where my_group is the group name.

Perform mysqlfabric group add my_group master_server:port to add the primary server, where master_server:port is the IP and port of the primary server.

Execute mysqlfabric group promote my_group to promote the primary server to the master of the server group.

Execute mysqlfabric group add my_group slave_server:port to add the slave server, where slave_server:port is the IP and port of the slave server. After the slave server is added, the slave server will automatically synchronize the data that has been written to bin log on the master server.

Perform an automatic failover of mysqlfabric group activate my_group activation.

Mysqlfabric group lookup_servers ys_group

VII. Error recovery

After the server fails, it will be marked as FAULTY in MySQL Fabric, and the state will not be automatically restored after the server is restored. The wrong server needs to be removed from the group and rejoined manually.

`port` > mysqlfabric group remove my_group server: shell 8. Connect to MySQL Fabric using Java connector

Taking the Tomcat datasource configuration as an example, you only need to modify driverClassName and url to switch from a direct connection to a MySQL connection through MySQL Fabric:

DriverClassName= "com.mysql.fabric.jdbc.FabricMySQLDriver"

Where localhost:32274 is the service address of MySQL Fabric, fabricUsername and fabricPassword are the user name and password of MySQL Fabric, database is the default database name, and fabricServerGroup is the server group name.

The above is all the content of the article "how to use MySQL Fabric to achieve High availability". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report