It's still the same , Just follow my steps ,100% 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 .

docker+mysql colony + Read / write separation +mycat management + Vertical sub database + More articles on Load Balancing

  1. MySQL User defined implementation of cluster read-write separation

    be based on MySQL Router High availability , Read / write separation , Load balancing and so on ,MySQL Router It's a very lightweight middleware . Look at the MySQL Router Principle , It's not complicated , The principle is not hard to understand , ...

  2. Mysql Cluster read / write separation (Amoeba)

    Amoeba Here's the principle :Amoeba Detailed introduction Experimental environment Master.Amoeba--IP:192.168.1.5 Slave---IP:192.168.1.10 install JDK JDK Download address :http ...

  3. Use mysql-proxy Fast implementation mysql colony Read / write separation

    At present, the more common mysql There are two kinds of separation between reading and writing : 1. Based on the internal implementation of program code : Right... In the code select Operations are distributed to the slave Library : Other operations are performed by the main library : This kind of method is also the most widely used in production environment , Well known as DISCUZ X2. Advantage is ...

  4. To learn Mysql data 13:Mysql Master slave copy , Read / write separation , Strategy and practice of sub table and sub database

    One .MySQL Expand the specific implementation With the continuous expansion of business scale , We need to choose the right solution to cope with the growth of data scale , To cope with the increasing access pressure and data volume . The expansion of database mainly includes : Business split . Master slave copy . Read / write separation . Database sub base ...

  5. MySQL Cluster series 2: adopt keepalived Achieve dual master cluster read and write separation

    On the basis of the previous section , By adding keepalived Read and write separation . First, turn off the firewall install keepalived keepalived 2 All machines have to be installed rpm .el6.x86_64/ Note that the above should be replaced with your kernel ...

  6. fourteen 、linux-MySQL Database cluster read-write separation and high availability 、 Backup, etc

    One . Database clustering and high availability Two .mysql Read and write separation mysql There are many ways to achieve read-write separation : 1) Code language (php\python\java etc. ) The layer realizes the separation of reading and writing , Look for development to implement . 2) Reading and writing can be realized by software tools ...

  7. Mysql Read / write separation And high availability and high performance load balancing

    What is separation of reading and writing , To put it bluntly mysql The server reads and writes separately , Of course, this requires two servers ,master Responsible for writing ,slave Responsible for reading , Of course, we can use multiple slave, In this way, we also achieve high availability and ...

  8. LVS Three methods of cluster implementation IP Load balancing technology

    LVS There are three kinds of IP Load balancing technology :VS/NAT,VS/DR,VS/TUN. VS/NAT The architecture of is as shown in the figure . There is a scheduler in front of a set of servers , They are through Switch/HUB Connected . These servers Provide the same network service ...

  9. docker build Mysql colony

    docker Basic instructions : Update package yum -y update install Docker virtual machine (centos 7) yum install -y docker function . restart . close Docker virtual machine servic ...

  10. High availability 、 Load balanced mysql Clustering solutions

    High availability . Load balanced mysql Clustering solutions One .mysql Market share Two .mysql Why is it so popular 3、 ... and .mysql The advantages and disadvantages of database system Four . Network server requirements 5、 ... and . What is? mysql The cluster of 6、 ... and . what ...

Random recommendation

  1. GCD- Two network request synchronization problems

    Sometimes there is such a demand when the network requests Two interfaces request data , Then we can do the final data processing . But because network requests are step-by-step . We don't know when the two requests will be completed . Usually in the face of such a demand will naturally think of Multithreading ah . Show real ...

  2. linux grep

    grep ( The abbreviation comes from Globally search a Regular Expression and Print) It's a powerful text search Cable tools , It can search for text using regular expressions , And print out the matching lines .Uni ...

  3. Sublime Lightweight editor

    For those who are engaged in Computer Science , An easy-to-use editor is equivalent to a sharp tool in hand ! It can be said that , It's no mistake to cut wood , A knife grinder ! Hands have artifact , Walk around ! sublime, Remember, it seems to support cross platform The mood in my hometown http://pan.baidu.com/s ...

  4. stay Eclipse Add... To the new menu JSP

    In development , You may choose a different perspective , Let's say Java EE The perspective is an example . Right click on the project , choice new command , There's no new one in the menu JSP The option to . thus , If you want to build a new JSP, Can only choose Other command , On the inside ...

  5. [ turn ]php Picture captcha generation Front and back verification

    In this paper, from :https://www.cnblogs.com/xiaoyezi/p/3541195.html I have been doing a php Small projects , On the generation of picture verification code generation and background verification , Sum up what you use ...

  6. codeforces498C

    Array and Operations CodeForces - 498C You have written on a piece of paper an array of n positive i ...

  7. Basic berkeley socket functions

    gethostbyname() DNS を through して.Domain の Information を GET する. example えば IP Address なんだ. げん type : #include <netdb.h ...

  8. win php install oracle11 g

    1. download plsql and oracle11g plsql Simple installation , It's a normal installation .oracle11 g No need to install , Now let me explain win 64 Bit system configuration oracle: (1). First of all, I used warpse ...

  9. modify Docker Default storage location method

    In daily use, because our root directory is usually small , If you want to store a large number of container images, it is easy to cause the root directory to be full docker The default data directory is /var/lib/docker If we want to move the data directory, we can follow the instructions below . ...

  10. The string array contains json transformation

    [{'a':'1','b':'2'},{'c':'3','d':'4'}]" solve import net.sf.json.JSONArray; import net.sf.json.JSON ...