MySQL: Fabric installation and mysqlfabric Installation
Install MySQL Fabric
MySQL Fabric is a tool provided by Oracle to assist in ha \ sharding. Its basic architecture is as follows:
As shown above, Fabric can be used to build HA clusters, Sharing, and HA + Sharding.
The application learns the ing relationships between databases, tables, and partitions from fabric, and then accesses the corresponding mysql instance.
Fabric consists of three components:
1) Manage fabric (mysqlfabric ).
2) fabric nodes. One or more nodes can be started. Each node is also a process. It is used to process fabric management requests and application mapping requests.
3) backstore, which is also a mysql server, maintains HA Group and Sharding Group.
Download
For Versions later than mysql 5.6, the corresponding fabric version is 1.5, which can be directly downloaded from the mysql official website. Fabric is written in python and mysql-connector-python is used for internal communication. Therefore, you must download the corresponding python driver.
The version I downloaded is:
mysql-utiltities-1.5.6-1.el6.noarch.rpmmysql-connector-ptyhon-2.0.4-1.el6.noarch.rpm
Install
1, Installation media
Use the root user of the operating system for installation.
First install mysql-connector-ptyhon, and then install mysql-utilities:
rpm –i mysql-connector-ptyhon-2.0.4-1.el6.noarch.rpmrpm –i mysql-utiltities-1.5.6-1.el6.noarch.rpm
After installation, a mysqlfabric command is available. Therefore, you can use this command to determine whether the installation is successful.
2, Configuration file
After fabric is installed, a default configuration file fabric. cfg is created.
Default Configuration File Location:
Platform |
Package |
Location |
Microsoft Windows |
Mysql-utilities-1.5.6-win32.msi |
UTILITIES_INSTALLDIR/Etc/mysql/fabric. cfg |
Ubuntu Linux 14.04 |
Mysql-utilities_1.5.6-1ubuntu14.04_all.deb |
/Etc/mysql/fabric. cfg |
Debian Linux 6.0. |
Mysql-utilities_1.5.6-1debian6.0_all.deb |
/Etc/mysql/fabric. cfg |
Red Hat Enterprise Linux 6/Oracle Linux 6 |
Mysql-utilities-1.5.6-1.el6.noarch.rpm |
/Etc/mysql/fabric. cfg |
OS X |
Mysql-utilities-1.5.6-osx10.9.dmg |
/Etc/mysql/fabric. cfg |
Default Configuration File preview:
[DEFAULT]prefix = /usr/localsysconfdir = /usr/local/etclogdir = /var/log[storage]address = localhost:3306user = fabric_storepassword = secretdatabase = mysql_fabricauth_plugin = mysql_native_passwordconnection_timeout = 6connection_attempts = 6connection_delay = 1[servers]user = fabric_serverpassword = secretbackup_user = fabric_backupbackup_password = secretrestore_user = fabric_restorerestore_password = secretunreachable_timeout = 5[protocol.xmlrpc]address = localhost:32274threads = 5user = adminpassword = secretdisable_authentication = norealm = MySQL Fabricssl_ca =ssl_cert =ssl_key =[protocol.mysql]address = localhost:32275user = adminpassword = secretdisable_authentication = nossl_ca =ssl_cert =ssl_key =[executor]executors = 5[logging]level = INFOurl = file:///var/log/fabric.log[sharding]mysqldump_program = /usr/bin/mysqldumpmysqlclient_program = /usr/bin/mysql[statistics]prune_time = 3600[failure_tracking]notifications = 300notification_clients = 50notification_interval = 60failover_interval = 0detections = 3detection_interval = 6detection_timeout = 1prune_time = 3600[connector]ttl = 1
This configuration file involves many types of accounts:
· Backstore
In the [storage] area, configure the backstore mysql server information. Therefore, the Operation account of the backstore mysql server is configured here.
Required permissions:
ALTER - alter some database objectsCREATE - create most database objectsCREATE VIEW - create viewsDELETE - delete rowsDROP - drop most database objectsEVENT - manage eventsREFERENCES - foreign keysINDEX - create indexesINSERT - insert rowsSELECT - select rowsUPDATE - update rows
· Server
In the [servers] region, all accounts of the managed mysql server are configured.
Required permissions:
The permissions are as follows:
DELETE - prune_shardPROCESS - list sessions to killRELOAD - RESET SLAVEREPLICATION CLIENT - SHOW SLAVE STATUSREPLICATION SLAVE - SHOW SLAVE HOSTS
The permissions of the Fabric database:
ALTER - alter some database objectsCREATE - create most database objectsDELETE - delete rowsDROP - drop most database objectsINSERT - insert rowsSELECT - select rowsUPDATE - update rows
· Backup
Configured in the [servers] region, it is the account used for backup on all managed mysql servers. For example, execute mysqldump.
Permissions of the User:
EVENT - show event informationEXECUTE - show routine information inside viewsREFERENCES - foreign keysSELECT - read dataSHOW VIEW - SHOW CREATE VIEWTRIGGER - show trigger information
· Restore
Configured in the [servers] region, it is the account used for restore on all managed mysql servers. You can use the mysql client to perform Restore operations.
Permissions of the User:
ALTER - ALTER DATABASEALTER ROUTINE - ALTER {PROCEDURE|FUNCTION}CREATE - CREATE TABLECREATE ROUTINE - CREATE {PROCEDURE|FUNCTION}CREATE TABLESPACE - CREATE TABLESPACECREATE VIEW - CREATE VIEWDROP - DROP TABLE (used before CREATE TABLE)EVENT - DROP/CREATE EVENTINSERT - write dataLOCK TABLES - LOCK TABLES (--single-transaction)REFERENCES - Create tables with foreign keysSELECT - LOCK TABLES (--single-transaction)SUPER - SET @@SESSION.SQL_LOG_BIN = 0TRIGGER - CREATE TRIGGER
· Admin
The admin user configured in [protocol. mysql] and [protocol. xmlrpc] is the user and password used for Fabric CLI (mysqlfabric) and fabric node interaction.
When using mysqlfabric, you can use the default configuration file or custom configuration file. No matter which configuration file is used, related configuration items must be configured.
3Create backstoreAccount
Create a mysql instance as the fabric backstore. Create a fabric backstore account.
CREATE USER 'fabric_store'@'localhost' IDENTIFIED BY 'secret';GRANT ALTER, CREATE, CREATE VIEW, DELETE, DROP, EVENT, INDEX, INSERT, REFERENCES, SELECT, UPDATE ON mysql_fabric.* TO 'fabric_store'@'localhost';
The created user name and password must be the same as the user and password in the [storeage] area of the configuration file fabric. cfg.
At this time, the fabric database has not been created, but do not create it by yourself.
4Initialize fabricDatabases and tables
Use mysqlfabric to initialize:
mysqlfabric manage setup
If you want to use the custom fabric. cfg configuration file:
mysqlfabric --config=/your/fabric/cfg/path manage setup
5, MysqlfabricCommand
1) Start the fabric Node
mysqlfabric --config=/your/fabric/cfg/path manage start
2) Stop the fabric Node
mysqlfabric --config=/your/fabric/cfg/path manage stop
For other commands, refer to the official documentation.