91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Mycat中如何配置schmea.xml

發布時間:2021-11-06 13:50:54 來源:億速云 閱讀:296 作者:小新 欄目:MySQL數據庫

這篇文章主要為大家展示了“Mycat中如何配置schmea.xml”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“Mycat中如何配置schmea.xml”這篇文章吧。

1.基本環境

dn1 localhost1 192.168.6.121:3306---writehost
192.168.6.121:3307---readhost
192.168.6.121:3308
dn2 locahost2 192.168.6.120:3306---writehost
192.168.6.120:3307---readhost
192.168.6.121:3308
dn3 localhost3 192.168.6.119:3306---writehost
192.168.6.119:3307---readhost
192.168.6.119:3308



2.schemal配置

  1. <?xml version="1.0"?>

  2. <!DOCTYPE mycat:schema SYSTEM "schema.dtd">

  3. <mycat:schema xmlns:mycat="http://io.mycat/">


  4.         <schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1">     ---默認數據節點,若新建一張表company2未在配置文件中配置,則默認建立在dn1數據節點上(私有表)

  5.                 <!-- auto sharding by id (long) -->

  6.                 <table name="travelrecord" dataNode="dn1,dn2,dn3" rule="auto-sharding-long" />   ---分片表,根據對應的分片規則 分片到各個物理節點上


  7.                 <!-- global table is auto cloned to all defined data nodes ,so can join

  8.                         with any table whose sharding node is in the same data node -->


  9.                 <table name="company" primaryKey="ID" type="global" dataNode="dn1,dn2,dn3" />    ---全局表,每個節點上都有的表

  10.                                   ---等同于company

                                                ----等同于company2

  11.                 <table name="goods" primaryKey="ID" type="global" dataNode="dn1,dn2,dn3" />

  12.                 <!-- random sharding using mod sharind rule -->

  13.                 <table name="hotnews" primaryKey="ID" autoIncrement="true" dataNode="dn1,dn2,dn3"

  14.                            rule="mod-long" />

  15.                 <!-- <table name="dual" primaryKey="ID" dataNode="dnx,dnoracle2" type="global"

  16.                         needAddLimit="false"/> <table name="worker" primaryKey="ID" dataNode="jdbc_dn1,jdbc_dn2,jdbc_dn3"

  17.                         rule="mod-long" /> -->

  18.                 <table name="employee" primaryKey="ID" dataNode="dn1,dn2"

  19.                            rule="sharding-by-intfile" />

  20.                 <table name="customer" primaryKey="ID" dataNode="dn1,dn2"

  21.                            rule="sharding-by-intfile">

  22.                         <childTable name="orders" primaryKey="ID" joinKey="customer_id"

  23.                                                 parentKey="id">

  24.                                 <childTable name="order_items" joinKey="order_id"

  25.                                                         parentKey="id" />

  26.                         </childTable>

  27.                         <childTable name="customer_addr" primaryKey="ID" joinKey="customer_id"

  28.                                                 parentKey="id" />

  29.                 </table>

  30.                 <!-- <table name="oc_call" primaryKey="ID" dataNode="dn1$0-743" rule="latest-month-calldate"

  31.                         /> -->

  32.         </schema>

  33.         <!-- <dataNode name="dn1$0-743" dataHost="localhost1" database="db$0-743"

  34.                 /> -->


    1.         <dataNode name="dn1" dataHost="localhost1" database="examdb" />             ----數據節點對應的localhost以及真實的數據庫

    2.         <dataNode name="dn2" dataHost="localhost2" database="examdb" />

    3.         <dataNode name="dn3" dataHost="localhost3" database="examdb" />




    4.         <dataHost name="localhost1" maxCon="1000" minCon="10" balance="2"            ------localhosts對應的連接配置信息

    5.                           writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">

    6.                 <heartbeat>select user()</heartbeat>

    7.                 <!-- can have multi write hosts -->

    8.                 <writeHost host="hostM1" url="192.168.6.121:3306" user="root"

    9.                                    password="ESBecs00">

    10.                         <!-- can have multi read hosts -->

    11.                 </writeHost>


    12.         </dataHost>

    13.         


    14.         <dataHost name="localhost2" maxCon="1000" minCon="10" balance="2"

    15.                           writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">

    16.                 <heartbeat>select user()</heartbeat>

    17.                 <!-- can have multi write hosts -->

    18.                 <writeHost host="hostM1" url="192.168.6.120:3306" user="root"

    19.                                    password="ESBecs00">

    20.                         <!-- can have multi read hosts -->

    21.                 </writeHost>


    22.         </dataHost>


    23.         <dataHost name="localhost3" maxCon="1000" minCon="10" balance="2"

    24.                           writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">

    25.                 <heartbeat>select user()</heartbeat>

    26.                 <!-- can have multi write hosts -->

    27.                 <writeHost host="hostM1" url="192.168.6.119:3306" user="root"

    28.                                    password="ESBecs00">

    29.                         <!-- can have multi read hosts -->

    30.                 </writeHost>


    31.         </dataHost>

    32. </mycat:schema>

    33. ......未完待續


    全局表的查詢有負載均衡的作用

    1. mysql> select * from company;   ----本應該是相同的數據,改為不同的數據是為了展示負載均衡的效果

    2. +----+-------------+

    3. | id | name |

    4. +----+-------------+

    5. | 1 | this is 119 |

    6. +----+-------------+

    7. 1 row in set (0.01 sec)


    8. mysql> select * from company;

    9. +----+-------------+

    10. | id | name |

    11. +----+-------------+

    12. | 1 | this is 120 |

    13. +----+-------------+

    14. 1 row in set (0.01 sec)


    15. mysql> select * from company;

    16. +----+-------------+

    17. | id | name |

    18. +----+-------------+

    19. | 1 | this is 121 |

    20. +----+-------------+

    21. 1 row in set (0.00 sec)



    分片表和私有表如果不在一哥節點上就聯合查不到了!

    uc分片表,4101在第二個節點上
    act為私有表,4101在第一個節點上
    select * from uc_coupon where COUPON_ID=4101 ;   --單獨查,是有的
    select * from act_vote_info where id=4101;       ---單獨查,是有的
    select a.*,b.* from uc_coupon a,act_vote_info b where a.COUPON_ID=b.id and b.id=4101 limit 1;  --聯合查,查不到了,因為跨節點了!
    舉例:

    1. mysql> select * from order2;   ---分片表

    2. +----+----------+---------+---------------------+

    3. | ID | PROVINCE | SN | CREATE_TIME |

    4. +----+----------+---------+---------------------+

    5. | 2 | shanghai | 2BJ0001 | 2017-05-09 15:01:33 |    ---節點2上

    6. | 1 | beijing | 2BJ0001 | 2017-04-23 21:48:08 |     ---節點1上

    7. | 3 | tianjin | 2BJ0001 | 2017-05-09 15:01:45 |

    8. +----+----------+---------+---------------------+ 

    9. 3 rows in set (0.00 sec)


    10. mysql> select * from tt;    ---私有表 節點1上

    11. +------+------------+

    12. | id | name |

    13. +------+------------+

    14. | 2 | zhangsanli |

    15. | 1 | 12314 |

    16. +------+------------+

    17. 2 rows in set (0.00 sec)


    18. mysql> select a.*,b.* from tt a,order2 b where a.id=b.ID and b.id=2;   -----2和私有表不在一個節點上,查不出來

    19. Empty set (0.00 sec)


    20. mysql> select a.*,b.* from tt a,order2 b where a.id=b.ID and b.id=1;    -----1和私有表在一個節點上,所以查的出來

    21. +------+-------+----+----------+---------+---------------------+

    22. | id | name | ID | PROVINCE | SN | CREATE_TIME |

    23. +------+-------+----+----------+---------+---------------------+

    24. | 1 | 12314 | 1 | beijing | 2BJ0001 | 2017-04-23 21:48:08 |

    25. +------+-------+----+----------+---------+---------------------+

    26. 1 row in set (0.00 sec)


    同理:

    分片表和分片表條件數據如果不在一個節點上就聯合查不到了!
    1. mysql> select a.* ,b.* from order2 a,order3 b where a.id=b.id and a.id=2;    --單獨都是有數據的,但是id相等的分在不同的節點上,還是不能跨節點

    2. Empty set (0.00 sec)

    mysql> select * from order2;
    +----+----------+---------+---------------------+
    | ID | PROVINCE | SN      | CREATE_TIME         |
    +----+----------+---------+---------------------+
    |  2 | shanghai | 2BJ0001 | 2017-05-09 15:01:33 |
    |  1 | beijing  | 2BJ0001 | 2017-04-23 21:48:08 |
    |  3 | tianjing | 2BJ0001 | 2017-05-15 14:52:17 |
    +----+----------+---------+---------------------+
    3 rows in set (0.00 sec)


    mysql> select * from order3;
    +----+----------+---------+---------------------+
    | ID | PROVINCE | SN      | CREATE_TIME         |
    +----+----------+---------+---------------------+
    |  2 | beijing  | 2BJ0001 | 2017-05-15 14:56:27 |
    |  1 | tianjing | 2BJ0001 | 2017-05-15 14:56:35 |
    |  3 | shanghai | 2BJ0001 | 2017-05-15 14:56:17 |
    +----+----------+---------+---------------------+
    3 rows in set (0.00 sec)


    解決辦法:注解,詳細用法見文檔

    1. mysql> /*!mycat:catlet=demo.catlets.ShareJoin */ select b.sn,b.CREATE_TIME,a.CREATE_TIME from order2 a,order3 b where a.id=b.id;

    2. +---------------------+----+---------+---------------------+

    3. | CREATE_TIME | id | sn | CREATE_TIME |

    4. +---------------------+----+---------+---------------------+

    5. | 2017-04-23 21:48:08 | 1 | 2BJ0001 | 2017-05-15 14:56:35 |

    6. | 2017-05-09 15:01:33 | 2 | 2BJ0001 | 2017-05-15 14:56:27 |

    7. | 2017-05-15 14:52:17 | 3 | 2BJ0001 | 2017-05-15 14:56:17 |

    8. +---------------------+----+---------+---------------------+

以上是“Mycat中如何配置schmea.xml”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

丹巴县| 吉首市| 沙田区| 台州市| 准格尔旗| 延长县| 通州市| 右玉县| 安泽县| 辉县市| 泗水县| 明溪县| 子长县| 兴安县| 建湖县| 平陆县| 自治县| 洛浦县| 迭部县| 嘉兴市| 元朗区| 建昌县| 平武县| 土默特左旗| 东阿县| 崇礼县| 连江县| 湄潭县| 玉环县| 星子县| 永宁县| 河北省| 卢湾区| 阿拉善左旗| 天台县| 商都县| 准格尔旗| 中阳县| 漾濞| 苗栗市| 嘉鱼县|