What is MyCAT
MyCAT Key Features
1. Here, based on the implementation of MySQL master-slave replication, mycat is used for read-write separation. The architecture diagram is as follows: 2. Demo 2.1 Create a database on mysql master Create db1 2.2 Create table student in database db1 At the same time, because MySQL master-slave replication is configured, there are also the same databases and tables on MySQL slave 2.3 Edit the mycat configuration file server.xml <!-- indicates the login username of mycat --> <user name="test"> <!-- indicates the login password of mycat --> <property name="password">test</property> <!-- indicates the logical database name of mycat, which can be customized --> <property name="schemas">TESTDB</property> </user> <user name="user"> <property name="password">user</property> <property name="schemas">TESTDB</property> <property name="readOnly">true</property> </user> 2.4 Edit the mycat configuration file schema.xml <!--TESTDB represents the logical database name of mycat. When the schema node has no child node table, the dataNode attribute must exist (pointing to the real mysql database). --> <schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1"> </schema> <!--Specify the master database db1--> <dataNode name="dn1" dataHost="192.168.0.4" database="db1" /> <!--Specify the masteret ip --> <dataHost name="192.168.0.4" maxCon="1000" minCon="10" balance="3" writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100"> <!--Indicates the heartbeat status of MySQL--> <heartbeat>select user()</heartbeat> <!-- master is responsible for writing --> <writeHost host="hostM1" url="192.168.0.4:3306" user="root" password="admin"> <!--slave is responsible for reading--> <readHost host="hostS2" url="192.168.0.5:3306" user="root" password="admin" /> </writeHost> </dataHost> At this point, the configuration of using mycat for read-write separation has been completed Note the following three properties of the dataHost node balance, switchType, writeType balance="0", the read-write separation mechanism is not enabled, and all read operations are sent to the currently available writeHost. balance="1", all readHosts and stand by writeHosts participate in the load balancing of the select statement. Simply put, when in dual-master and dual-slave mode (M1->S1, M2->S2, and M1 and M2 are mutually master and slave), under normal circumstances, M2, S1, and S2 all participate in the load balancing of the select statement. balance="2", all read operations are randomly distributed on writeHost and readhost. balance="3", all read requests are randomly distributed to the readhost under writeHost for execution, and writeHost does not bear the read pressure writeType indicates the write mode writeType="0", all operations are sent to the first configured writehost writeType="1", randomly send to all configured writehosts writeType="2", no write operation is performed switchType refers to the switching mode, and currently there are 4 possible values: switchType='-1' means no automatic switching switchType='1' default value, indicating automatic switching switchType='2' determines whether to switch based on the status of MySQL master-slave synchronization. The heartbeat statement is show slave status switchType='3' is based on the switching mechanism of MySQL galary cluster (suitable for cluster) (1.4.1), and the heartbeat statement is show status like 'wsrep%'. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Summary of 10 advanced tips for Vue Router
>>: Detailed explanation of how to use Node.js to implement hot reload page
This article lists some tips and codes about form...
There are many form elements. Here is a brief sum...
Ubuntu 16.04 builds FTP server Install ftp Instal...
The CentOS Project, a 100% compatible rebuild of ...
Method 1: Set the readonly attribute to true. INPU...
The span tag is often used when making HTML web pa...
This article example shares the specific code of ...
The /partition utilization of a server in IDC is ...
1. Count the number of users whose default shell ...
In many projects, it is necessary to implement th...
The method of wrapping the content (title attribut...
When the server needs to be started during develo...
Recently, the company has put forward a requireme...
Table of contents Achieve results Implementation ...
need: Merge identical items of one field and sort...