Docker + MySQL Cluster + read / write separation + MYCAT Management + vertical sub database + load balancing

Chen Yangtian 2021-01-14 14:30:34
docker mysql cluster read write


It's still the same , Just follow my steps ,99.99999% It can be tested successfully

centos6.8 It is no longer maintained , Maybe many people can't use it in their virtual machine yum Command download docker,

But aliyuan can still be used Because of his centos-vault The warehouse has the previous version centos My bag

Only need centos Execute a few commands in the command line interface

sed -i "s|enabled=1|enabled=0|g" /etc/yum/pluginconf.d/fastestmirror.conf
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://www.xmpan.com/Centos-6-Vault-Aliyun.repo 
yum clean all
yum makecache

 

  Then execute the following command to install docker

 

yum install https://get.docker.com/rpm/1.7.1/centos-6/RPMS/x86_64/docker-engine-1.7.1-1.el6.x86_64.rpm

What if prompted to check for software failure , Try using the command  yum remove docker Delete docker, reinstall

After installation, you can give docker Configure the accelerator of alicloud , Specific method Baidu , I won't go over it here

docker After the installation is complete, start to prepare to build Mysql, I have always stressed that we should adhere to Appointment > To configure > code , The next step is to prepare the environment step by step :

I've got two virtual machines 130( Lord ), and 131( from ), First of all, on two computers, through docker install mysql

Because you need to configure read-write separation , Be sure to mount mysql Configuration file directory to host

docker pull mysql:5.6 // Pull mysql Mirror image 
docker run -p 3306:3306 --name mysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
docker cp containedID:/etc/mysql/my.cnf $PWD // Copy a configuration file in the container 

Two virtual machines perform the same operation , Configure master and slave Mysql It's better to have consistent database versions

The first is the main library my.cnf Configuration of :

stay mysql Of the configuration file [mysqld] The following changes ( The same is true from the library ):

 

# Enable master-slave replication , Configuration of main database (log-bin Property is specified only when the master and slave are configured , A single machine doesn't need )
log-bin= mysql3306-bin
# Specify the main library serverid
#server-id Both master and slave libraries need to be specified , But the main library server-id Must be less than... From the library server-id( important )
server-id=1
# Specify a synchronized database , If not specified, synchronize all databases ( In general, it is not necessary to specify )
#binlog-do-db=mybatis_1128
#( The commands entered in the configuration file must have a line of space below , Otherwise MySQL Don't recognize )

 

perform SQL Statement query status :
SHOW MASTER STATUS

 

  It needs to be recorded Position value , You need to set the synchronization start value in the slave library .( important )

And then restart 130( Lord ), Make profile effective

docker restart containerID

To configure 131( from ) Of my.cnf:

Just specify one server-id=2 that will do

And then restart 131( from ), Make profile effective

 

adopt sqlyog Connect two mysql The server ( Pay attention to the open port , In order to test , Just stop the firewall )

And then 130( Lord ) Enter the following command :

GRANT REPLICATION SLAVE ON *.* TO 'slave01'@'192.168.209.131'IDENTIFIED BY '123456';
FLUSH PRIVILEGES;

It means to add a slave Users who can log in , The user is called slave01, The password for 123456, Only through 131( from ), To log in

When it's done 131( from ) Execute the following command in :

CHANGE MASTER TO
MASTER_HOST='192.168.209.130',
MASTER_USER='slave01',
MASTER_PASSWORD='123456',
MASTER_PORT=3306,
MASTER_LOG_FILE='mysql3306-bin.000011',
MASTER_LOG_POS=38301;
START SLAVE;// Turn on the master-slave configuration
SHOW SLAVE STATUS // View master-slave configuration status information 

38301 as well as mysql3308-bin.000011 Corresponding 130( Lord ) Medium position and file Field ( important )

 

If show slave status after ,slave_io_running and slave_sql_running Values are yes, Then the configuration is successful ,

Directly in 130( Lord ) Build a database on the Internet , Find out 131( from ) The same database is also generated

Here we are ,Mysql The master-slave configuration ends .

A lot of people configure it , Start configuring dual data sources in your code , Through the code to achieve data source switching, in order to achieve the purpose of reading and writing separation , I always stressed , Appointment > To configure > code , This is obviously not desirable , Now that the master and slave are configured , Why not choose an efficient management method ?

This leads to the main point of this article :mycat

mycat yes

1、 A completely open source , Large database cluster for enterprise application development        

2、 Support transactions 、ACID、 Can replace MySQL Enhanced database of      

3、 One can be regarded as MySQL Enterprise database of cluster , To replace the expensive Oracle colony  

4、 A fusion of memory cache technology 、NoSQL technology 、HDFS New big data SQL Server   

5、 A new generation of enterprise database products combining traditional database and new distributed data warehouse    

6、 A new database middleware product

mycat It's for clustering , And can achieve the purpose of database partition through simple configuration

  1. Download and install Mycat  Execute the following command :
    docker pull longhronshens/mycat-docker
    mkdir -p /usr/local/mycat
    cd /usr/local/mycat

    Enter our new mycat Catalog , take server.xml rule.xml schema.xml Copy to this directory , The basic contents of the three documents are as follows :schema.xml

    <?xml version="1.0"?>
    <!DOCTYPE mycat:schema SYSTEM "schema.dtd">
    <mycat:schema xmlns:mycat="http://io.mycat/">
    <schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100">
    <!-- auto sharding by id (long) -->
    <table name="travelrecord" dataNode="dn1,dn2,dn3" rule="auto-sharding-long" />
    <!-- global table is auto cloned to all defined data nodes ,so can join
    with any table whose sharding node is in the same data node -->
    <table name="company" primaryKey="ID" type="global" dataNode="dn1,dn2,dn3" />
    <table name="goods" primaryKey="ID" type="global" dataNode="dn1,dn2" />
    <!-- random sharding using mod sharind rule -->
    <table name="hotnews" primaryKey="ID" autoIncrement="true" dataNode="dn1,dn2,dn3"
    rule="mod-long" />
    <!-- <table name="dual" primaryKey="ID" dataNode="dnx,dnoracle2" type="global"
    needAddLimit="false"/> <table name="worker" primaryKey="ID" dataNode="jdbc_dn1,jdbc_dn2,jdbc_dn3"
    rule="mod-long" /> -->
    <table name="employee" primaryKey="ID" dataNode="dn1,dn2"
    rule="sharding-by-intfile" />
    <table name="customer" primaryKey="ID" dataNode="dn1,dn2"
    rule="sharding-by-intfile">
    <childTable name="orders" primaryKey="ID" joinKey="customer_id"
    parentKey="id">
    <childTable name="order_items" joinKey="order_id"
    parentKey="id" />
    </childTable>
    <childTable name="customer_addr" primaryKey="ID" joinKey="customer_id"
    parentKey="id" />
    </table>
    <!-- <table name="oc_call" primaryKey="ID" dataNode="dn1$0-743" rule="latest-month-calldate"
    /> -->
    </schema>
    <!-- <dataNode name="dn1$0-743" dataHost="localhost1" database="db$0-743"
    /> -->
    <dataNode name="dn1" dataHost="localhost1" database="db1" />
    <dataNode name="dn2" dataHost="localhost1" database="db2" />
    <dataNode name="dn3" dataHost="localhost1" database="db3" />
    <!--<dataNode name="dn4" dataHost="sequoiadb1" database="SAMPLE" />
    <dataNode name="jdbc_dn1" dataHost="jdbchost" database="db1" />
    <dataNode name="jdbc_dn2" dataHost="jdbchost" database="db2" />
    <dataNode name="jdbc_dn3" dataHost="jdbchost" database="db3" /> -->
    <dataHost name="localhost1" maxCon="1000" minCon="10" balance="0"
    writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
    <heartbeat>select user()</heartbeat>
    <!-- can have multi write hosts -->
    <writeHost host="hostM1" url="192.168.209.130:3306" user="root"
    password="123456">
    <!-- can have multi read hosts -->
    <readHost host="hostS2" url="192.168.209.130:3306" user="root" password="123456" />
    </writeHost>
    <writeHost host="hostS1" url="192.168.209.130:3306" user="root"
    password="123456" />
    <!-- <writeHost host="hostM2" url="localhost:3316" user="root" password="123456"/> -->
    </dataHost>
    <!--
    <dataHost name="sequoiadb1" maxCon="1000" minCon="1" balance="0" dbType="sequoiadb" dbDriver="jdbc">
    <heartbeat> </heartbeat>
    <writeHost host="hostM1" url="sequoiadb://1426587161.dbaas.sequoialab.net:11920/SAMPLE" user="jifeng" password="jifeng"></writeHost>
    </dataHost>
    <dataHost name="oracle1" maxCon="1000" minCon="1" balance="0" writeType="0" dbType="oracle" dbDriver="jdbc"> <heartbeat>select 1 from dual</heartbeat>
    <connectionInitSql>alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'</connectionInitSql>
    <writeHost host="hostM1" url="jdbc:oracle:thin:@127.0.0.1:1521:nange" user="base" password="123456" > </writeHost> </dataHost>
    <dataHost name="jdbchost" maxCon="1000" minCon="1" balance="0" writeType="0" dbType="mongodb" dbDriver="jdbc">
    <heartbeat>select user()</heartbeat>
    <writeHost host="hostM" url="mongodb://192.168.0.99/test" user="admin" password="123456" ></writeHost> </dataHost>
    <dataHost name="sparksql" maxCon="1000" minCon="1" balance="0" dbType="spark" dbDriver="jdbc">
    <heartbeat> </heartbeat>
    <writeHost host="hostM1" url="jdbc:hive2://feng01:10000" user="jifeng" password="jifeng"></writeHost> </dataHost> -->
    <!-- <dataHost name="jdbchost" maxCon="1000" minCon="10" balance="0" dbType="mysql"
    dbDriver="jdbc"> <heartbeat>select user()</heartbeat> <writeHost host="hostM1"
    url="jdbc:mysql://localhost:3306" user="root" password="123456"> </writeHost>
    </dataHost> -->
    </mycat:schema>

    server.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- - - Licensed under the Apache License, Version 2.0 (the "License");
    - you may not use this file except in compliance with the License. - You
    may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 
    - - Unless required by applicable law or agreed to in writing, software -
    distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT
    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the
    License for the specific language governing permissions and - limitations
    under the License. -->
    <!DOCTYPE mycat:server SYSTEM "server.dtd">
    <mycat:server xmlns:mycat="http://io.mycat/">
    <system>
    <property name="useSqlStat">0</property> <!-- 1 To turn on real-time statistics 、0 To close -->
    <property name="useGlobleTableCheck">0</property> <!-- 1 To enable full overtime consistency testing 、0 To close -->
    <property name="sequnceHandlerType">2</property>
    <!-- <property name="useCompression">1</property>--> <!--1 For opening mysql Compression protocol -->
    <!-- <property name="fakeMySQLVersion">5.6.20</property>--> <!-- Set simulated MySQL Version number -->
    <!-- <property name="processorBufferChunk">40960</property> -->
    <!--
    <property name="processors">1</property>
    <property name="processorExecutor">32</property>
    -->
    <!-- The default is type 0: DirectByteBufferPool | type 1 ByteBufferArena-->
    <property name="processorBufferPoolType">0</property>
    <!-- The default is 65535 64K be used for sql Maximum text length when parsing -->
    <!--<property name="maxStringLiteralLength">65535</property>-->
    <!--<property name="sequnceHandlerType">0</property>-->
    <!--<property name="backSocketNoDelay">1</property>-->
    <!--<property name="frontSocketNoDelay">1</property>-->
    <!--<property name="processorExecutor">16</property>-->
    <!--
    <property name="serverPort">8066</property> <property name="managerPort">9066</property>
    <property name="idleTimeout">300000</property> <property name="bindIp">0.0.0.0</property>
    <property name="frontWriteQueueSize">4096</property> <property name="processors">32</property> -->
    <!-- Distributed transaction switch ,0 Do not filter distributed transactions ,1 Filtering distributed transactions for ( If only global tables are involved in distributed transactions , No filtration ),2 Do not filter distributed transactions , But log distributed transactions -->
    <property name="handleDistributedTransactions">0</property>
    <!--
    off heap for merge/order/group/limit 1 Turn on 0 close
    -->
    <property name="useOffHeapForMerge">1</property>
    <!--
    Unit is m
    -->
    <property name="memoryPageSize">1m</property>
    <!--
    Unit is k
    -->
    <property name="spillsFileBufferSize">1k</property>
    <property name="useStreamOutput">0</property>
    <!--
    Unit is m
    -->
    <property name="systemReserveMemorySize">384m</property>
    <!-- Whether to adopt zookeeper Coordinated switching -->
    <property name="useZKSwitch">true</property>
    </system>
    <!-- overall situation SQL Firewall settings -->
    <!--
    <firewall>
    <whitehost>
    <host host="127.0.0.1" user="mycat"/>
    <host host="127.0.0.2" user="mycat"/>
    </whitehost>
    <blacklist check="false">
    </blacklist>
    </firewall>
    -->
    <user name="root">
    <property name="password">123456</property>
    <property name="schemas">TESTDB</property>
    <!-- Table level DML permissions -->
    <!--
    <privileges check="false">
    <schema name="TESTDB" dml="0110" >
    <table name="tb01" dml="0000"></table>
    <table name="tb02" dml="1111"></table>
    </schema>
    </privileges>
    -->
    </user>
    <user name="user">
    <property name="password">user</property>
    <property name="schemas">TESTDB</property>
    <property name="readOnly">true</property>
    </user>
    </mycat:server>

    rule.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- - - Licensed under the Apache License, Version 2.0 (the "License");
    - you may not use this file except in compliance with the License. - You
    may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 
    - - Unless required by applicable law or agreed to in writing, software -
    distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT
    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the
    License for the specific language governing permissions and - limitations
    under the License. -->
    <!DOCTYPE mycat:rule SYSTEM "rule.dtd">
    <mycat:rule xmlns:mycat="http://io.mycat/">
    <tableRule name="rule1">
    <rule>
    <columns>id</columns>
    <algorithm>func1</algorithm>
    </rule>
    </tableRule>
    <tableRule name="rule2">
    <rule>
    <columns>user_id</columns>
    <algorithm>func1</algorithm>
    </rule>
    </tableRule>
    <tableRule name="sharding-by-intfile">
    <rule>
    <columns>sharding_id</columns>
    <algorithm>hash-int</algorithm>
    </rule>
    </tableRule>
    <tableRule name="auto-sharding-long">
    <rule>
    <columns>id</columns>
    <algorithm>rang-long</algorithm>
    </rule>
    </tableRule>
    <tableRule name="mod-long">
    <rule>
    <columns>id</columns>
    <algorithm>mod-long</algorithm>
    </rule>
    </tableRule>
    <tableRule name="sharding-by-murmur">
    <rule>
    <columns>id</columns>
    <algorithm>murmur</algorithm>
    </rule>
    </tableRule>
    <tableRule name="crc32slot">
    <rule>
    <columns>id</columns>
    <algorithm>crc32slot</algorithm>
    </rule>
    </tableRule>
    <tableRule name="sharding-by-month">
    <rule>
    <columns>create_time</columns>
    <algorithm>partbymonth</algorithm>
    </rule>
    </tableRule>
    <tableRule name="latest-month-calldate">
    <rule>
    <columns>calldate</columns>
    <algorithm>latestMonth</algorithm>
    </rule>
    </tableRule>
    <tableRule name="auto-sharding-rang-mod">
    <rule>
    <columns>id</columns>
    <algorithm>rang-mod</algorithm>
    </rule>
    </tableRule>
    <tableRule name="jch">
    <rule>
    <columns>id</columns>
    <algorithm>jump-consistent-hash</algorithm>
    </rule>
    </tableRule>
    <function name="murmur"
    class="io.mycat.route.function.PartitionByMurmurHash">
    <property name="seed">0</property><!-- The default is 0 -->
    <property name="count">2</property><!-- Number of database nodes to fragment , Must specify , Otherwise, it can't be divided -->
    <property name="virtualBucketTimes">160</property><!-- An actual database node is mapped to so many virtual nodes , The default is 160 times , That is, the number of virtual nodes is the number of physical nodes 160 times -->
    <!-- <property name="weightMapFile">weightMapFile</property> Weight of nodes , Nodes without weights are 1. With properties Format of documents , From the 0 Start to count-1 That is, the node index is key, Take node weight value as value . Ownership value must be a positive integer , Otherwise, we should 1 Instead of -->
    <!-- <property name="bucketMapPath">/etc/mycat/bucketMapPath</property>
    Used to observe the distribution of physical nodes and virtual nodes during the test , If this property is specified , The virtual node murmur hash The mapping of values to physical nodes is output to this file by line , No default , If you don't specify , You don't export anything -->
    </function>
    <function name="crc32slot"
    class="io.mycat.route.function.PartitionByCRC32PreSlot">
    <property name="count">2</property><!-- Number of database nodes to fragment , Must specify , Otherwise, it can't be divided -->
    </function>
    <function name="hash-int"
    class="io.mycat.route.function.PartitionByFileMap">
    <property name="mapFile">partition-hash-int.txt</property>
    </function>
    <function name="rang-long"
    class="io.mycat.route.function.AutoPartitionByLong">
    <property name="mapFile">autopartition-long.txt</property>
    </function>
    <function name="mod-long" class="io.mycat.route.function.PartitionByMod">
    <!-- how many data nodes -->
    <property name="count">3</property>
    </function>
    <function name="func1" class="io.mycat.route.function.PartitionByLong">
    <property name="partitionCount">8</property>
    <property name="partitionLength">128</property>
    </function>
    <function name="latestMonth"
    class="io.mycat.route.function.LatestMonthPartion">
    <property name="splitOneDay">24</property>
    </function>
    <function name="partbymonth"
    class="io.mycat.route.function.PartitionByMonth">
    <property name="dateFormat">yyyy-MM-dd</property>
    <property name="sBeginDate">2015-01-01</property>
    </function>
    <function name="rang-mod" class="io.mycat.route.function.PartitionByRangeMod">
    <property name="mapFile">partition-range-mod.txt</property>
    </function>
    <function name="jump-consistent-hash" class="io.mycat.route.function.PartitionByJumpConsistentHash">
    <property name="totalBuckets">3</property>
    </function>
    </mycat:rule>

    start-up mycat

    docker run --name mycat -v /usr/local/mycat/schema.xml:/usr/local/mycat/conf/schema.xml -v /usr/local/mycat/rule.xml:/usr/local/mycat/conf/rule.xml -v /usr/local/mycat/server.xml:/usr/local/mycat/conf/server.xml --privileged=true -p 8066:8066 -p 9066:9066 -e MYSQL_ROOT_PASSWORD=123456 -d longhronshens/mycat-docker 

     

  2. To configure mycat mycat After normal startup, you can start to configure mycat About Mysql The cluster configuration of First of all schema.xml Configuration in :
     <schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100">// One schema A tag is a library of logic , It's our connection mycat The library you want to query , Corresponding to Mysql In the physics library database name: Library name checkSQLschema:mycat Yes sql Statement filtering strategy
    <table name="company" dataNode="dn1,dn2,dn3" rule="crc32slot" type="global" /> // One table It's a logic table , The name of the table is company,dataNode For library nodes , You need to configure multiple pieces , Separated by commas , Write one without splitting it up ,rule It's a fragmentation strategy , Corresponding to rule.xml Strategy in
    </schema>//type="global" For the global strategy , After personally testing the configuration of this property , Data will be inserted repeatedly into all db1,db2,db3 in , Fragmentation doesn't work 

    <dataNode name="dn1" dataHost="localhost1" database="db1" /> //database Corresponding to the physical database name Corresponding to the top schema Node dataNode attribute
    <dataNode name="dn2" dataHost="localhost1" database="db2" />
    <dataNode name="dn3" dataHost="localhost1" database="db3" />

    <dataHost name="localhost1" maxCon="1000" minCon="10" balance="1"
    writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100"> //writeType attribute

    Load balancing type , The current values are 3 Kind of :
    1. writeType="0",  All writes are sent to the first of the configuration writeHost, The first one is cut to the second one that still exists writeHost, After restart, the one that has been switched shall prevail , The switch is recorded in the configuration file :dnindex.properties .
    2. writeType="1", All writes are sent randomly to the configured writeHost. 
    3. writeType="2", Not realized .

    1. When balance=0 when , Do not turn on read-write separation , All read operations take place in the current writeHost On

      When balance=1 , All read operations are sent randomly to the current writeHost Corresponding readHost And spare writeHost General configuration read write separation balance The value is 1 that will do

    When balance=2, All reads are sent randomly to all writeHost,readHost On

    When balance=3 , All read operations are sent only to writeHost Of readHost On
    <heartbeat>select user()</heartbeat>
    <!-- can have multi write hosts -->
    <writeHost host="hostM1" url="192.168.209.130:3306" user="root"
    password="123456"> //130( Lord ) Write operations
    <readHost host="hostS1" url="192.168.209.131:3306" user="root" password="123456" /> //131( from ) Read operations
    <!-- can have multi read hosts -->
    </writeHost>
    <!-- <writeHost host="hostM2" url="localhost:3316" user="root" password="123456"/> -->
    </dataHost>

    And then there was server.xml Configuration of

     <user name="root">
    <property name="password">123456</property> //mycat User name and password for external services , Use Mycat after , Just put mycat As a mysql Just use it
    <property name="schemas">TESTDB</property> // The logical library name corresponds to schema.xml The name of
    <!-- Table level DML permissions -->
    <!--
    <privileges check="false">
    <schema name="TESTDB" dml="0110" >
    <table name="tb01" dml="0000"></table>
    <table name="tb02" dml="1111"></table>
    </schema>
    </privileges>
    -->
    </user>

    rule.xml

     <function name="crc32slot"
    class="io.mycat.route.function.PartitionByCRC32PreSlot">
    <property name="count">3</property><!-- Number of database nodes to fragment , Must specify , Otherwise, it can't be divided -->
    </function>

     

  3. To configure 130( Lord ),131( from ) database   stay 130( Lord ) Newly built db1,db2,db3 Three databases (mycat You can only create new tables , Unable to create new database , The watch also has to be schema.xml As specified in table)
  4. test mycat  my mycat And 130( Lord ) It's the same virtual machine , stay 130( Lord ) On restart Mycat, Make profile effective (schema.xml in Get rid of type="global" attribute )


    mycat The default port number for external services is 8066
    stay mycat Create a table :
    CREATE TABLE `company` (
    `id` BIGINT(20) NOT NULL AUTO_INCREMENT,
    `username` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT ' user name ',
    `password` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT ' password , Encrypted storage ',
    `phone` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT ' Register mobile number ',
    `email` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT ' Sign up for email ',
    `created` DATETIME(0) NOT NULL,
    `updated` DATETIME(0) NOT NULL,
    PRIMARY KEY (`id`)
    );

    stay Mycat Insert data :

    INSERT INTO company(id,username) VALUES('1',' Zhang Fei ');
    INSERT INTO company(id,username) VALUES('2',' Fan Qiao ');
    INSERT INTO company(id,username) VALUES('3',' Cao Cao ');
    INSERT INTO company(id,username) VALUES('4',' Liu bei ');
    INSERT INTO company(id,username) VALUES('5',' Pang Tong ');
    INSERT INTO company(id,username) VALUES('6',' Xu Zhu ');
    INSERT INTO company(id,username) VALUES('7',' zhaoyun ');
    INSERT INTO company(id,username) VALUES('8',' Guan yu ');
    INSERT INTO company(id,username) VALUES('9',' Guan yu 1');
    INSERT INTO company(id,username) VALUES('10',' Guan yu 2');
    INSERT INTO company(id,username) VALUES('11',' Guan yu 3');
    INSERT INTO company(id,username) VALUES('12',' Guan yu 4');
    INSERT INTO company(id,username) VALUES('13',' Guan yu 5');

     

Then check it out 130( Lord ) Database data :

db1:

db2:

 

mycat Execute query select * from company:


The data can be found out , No problem

The next in 131( from )db1 Insert a piece of data , At this time 130( Lord ) There is no such data in , Continue to mycat Execute query select * from company;


I found out what to do test data , Indicates that the read-write separation configuration is successful .

 

版权声明
本文为[Chen Yangtian]所创,转载请带上原文链接,感谢
https://javamana.com/2021/01/20210114135310487w.html

  1. Redis basic command
  2. Summary of MySQL articles
  3. 2、 Create k8s cluster in 5 seconds
  4. data自定义属性在jQuery中的用法
  5. Linux常见解压缩
  6. Detailed explanation of HBase basic principle
  7. 1、 Why and how to learn k8s
  8. Java advanced (29) -- HashMap set
  9. java中大文件上传
  10. Weblogic 2017-3248 analysis of Java Security
  11. Kubernetes official java client 8: fluent style
  12. Explain the function of thread pool and how to use it in Java
  13. Programming software tutorial video Encyclopedia: C + + / Java / Python / assembly / easy language (with tutorial)
  14. Description of dependency problem after javacv is updated to 1.5. X and how to reduce the size of dependency package
  15. Java reflection & dynamic agent
  16. Building Apache 2.4 + php7 + mysql8 in centos7 environment
  17. Summary of Java multithreading (1)
  18. Oracle AWR report generation
  19. Four magic functions of mybatis, don't step on the pit!
  20. A 16-year-old high school student successfully transplanted Linux to iPhone and posted a detailed guide
  21. Centos7 one click installation of JDK1.8 shell script
  22. Mounting of file system in Linux (centos7)
  23. How does serverless deal with the resource supply demand of k8s in the offline scenario
  24. Detailed explanation of HBase basic principle
  25. Spring security oauth2.0 authentication and authorization 4: distributed system authentication and authorization
  26. Redis performance Part 5 redis buffer
  27. JavaScript this keyword
  28. Summary of Java multithreading (3)
  29. Sentry(v20.12.1) K8S 云原生架构探索, SENTRY FOR JAVASCRIPT 手动捕获事件基本用法
  30. Sentry(v20.12.1) K8S 云原生架构探索, SENTRY FOR JAVASCRIPT 手动捕获事件基本用法
  31. (10) Spring from the beginning to the end
  32. Summary of Java multithreading (2)
  33. Spring source notes! From the introduction to the source code, let you really understand the source code
  34. A stormy sunny day
  35. Zookeeper (curator), the implementation of distributed lock
  36. Show the sky! Tencent T4's core Java Dictionary (framework + principle + Notes + map)
  37. Spring boot project, how to gracefully replace the blank value in the interface parameter with null value?
  38. Spring boot project, how to gracefully replace the blank value in the interface parameter with null value?
  39. docker+mysql集群+读写分离+mycat管理+垂直分库+负载均衡
  40. docker+mysql集群+读写分离+mycat管理+垂直分库+负载均衡
  41. To what extent can I go out to work?
  42. Java 使用拦截器无限转发/重定向无限循环/重定向次数过多报错(StackOverflowError) 解决方案
  43. Implementation of rocketmq message sending based on JMeter
  44. How to choose the ticket grabbing app in the Spring Festival? We have measured
  45. Implementation of rocketmq message sending based on JMeter
  46. My programmer's Road: self study java
  47. My programmer's Road: self study java
  48. All in one, one article talks about the use of virtual machine VirtualBox and Linux
  49. All in one, one article talks about the use of virtual machine VirtualBox and Linux
  50. Java 使用拦截器无限转发/重定向无限循环/重定向次数过多报错(StackOverflowError) 解决方案
  51. [Java training project] Java ID number recognition system
  52. How does serverless deal with the resource supply demand of k8s in the offline scenario
  53. Detailed explanation of HBase basic principle
  54. Explain the function of thread pool and how to use it in Java
  55. Kubernetes official java client 8: fluent style
  56. 010_MySQL
  57. Vibrant special purchases for the Spring Festival tiktok section, hundreds of good things to make the year more rich flavor.
  58. 010_MySQL
  59. Of the 4 million docker images, 51% have high-risk vulnerabilities
  60. Rocketmq CPP client visual studio 2019 compilation