zoukankan      html  css  js  c++  java
  • MYCAT全局序列

    1、本地文件方式

    sequnceHandlerType = 0

      /root/data/program/mycat/conf/server.xml   <property name="sequnceHandlerType">0</property>

    配置sequence_conf.properties

      /root/data/program/mycat/conf/sequence_conf.properties  

      USERS.HISIDS=
      USERS.MINID=1001
      USERS.MAXID=100000000
      USERS.CURID=1000

      说明:这里的USERS是server.xml中配置的table name的大写,千万千万注意

    <schema name="db_user" checkSQLschema="false" sqlMaxLimit="100">
            <table name="data_dictionary" type="global" dataNode="db_user_dataNode1,db_user_dataNode2" primaryKey="dataDictionaryID"/>
            <table name="users" dataNode="db_user_dataNode$1-2"  rule="mod-userID-long" primaryKey="userID">
                <childTable name="user_address"  joinKey="userID" parentKey="userID" primaryKey="addressID"/>
            </table>
    </schema>

    使用next value for MYCATSEQ_XXX

      INSERT INTO users(userID,phoneNum) values(next value for MYCATSEQ_USERS,'13612345678');

    效果

    2、数据库方式

    sequnceHandlerType = 1

      /root/data/program/mycat/conf/server.xml   <property name="sequnceHandlerType">1</property>

    配置/root/data/program/mycat/conf/sequence_db_conf.properties

      USERS=db_user_dataNode2

    在指定的schema中加入mycat_sequence表
      <table name = "mycat_sequence" dataNode ="db_user_dataNode2" />

    <schema name="db_user" checkSQLschema="false" sqlMaxLimit="100">
            <table name="data_dictionary" type="global" dataNode="db_user_dataNode1,db_user_dataNode2" primaryKey="dataDictionaryID"/>
            <table name="users" dataNode="db_user_dataNode$1-2"  rule="mod-userID-long" primaryKey="userID">
                <childTable name="user_address"  joinKey="userID" parentKey="userID" primaryKey="addressID"/>
            </table>
    
            <table name = "mycat_sequence" dataNode ="db_user_dataNode2" />
        </schema>

    使用next value for MYCATSEQ_XXX或者指定autoIncrement

     insert into users(userID,phoneNum)values(next value for MYCATSEQ_USERS,'2222222');

    另一种方式:指定 autoIncrement="true"

    <schema name="db_user" checkSQLschema="false" sqlMaxLimit="100">
            <table name="data_dictionary" type="global" dataNode="db_user_dataNode1,db_user_dataNode2" primaryKey="dataDictionaryID"/>
            <table name="users" dataNode="db_user_dataNode$1-2"  rule="mod-userID-long" primaryKey="userID" autoIncrement="true">
                <childTable name="user_address"  joinKey="userID" parentKey="userID" primaryKey="addressID"/>
            </table>
    
            <table name = "mycat_sequence" dataNode ="db_user_dataNode2" />
        </schema>

    insert into users(phoneNum)values("8888");

    3、本地时间戳方式

    ID= 64 位二进制 (42(毫秒)+5(机器 ID)+5(业务编码)+12(重复累加)

    sequnceHandlerType = 2

      /root/data/program/mycat/conf/server.xml   <property name="sequnceHandlerType">2</property>

    配置sequence_time_conf.properties

      默认配置即可

    指定autoIncrement

      只能指定autoIncrement

    <schema name="db_user" checkSQLschema="false" sqlMaxLimit="100">
            <table name="data_dictionary" type="global" dataNode="db_user_dataNode1,db_user_dataNode2" primaryKey="dataDictionaryID"/>
            <table name="users" dataNode="db_user_dataNode$1-2"  rule="mod-userID-long" primaryKey="userID" autoIncrement="true">
                <childTable name="user_address"  joinKey="userID" parentKey="userID" primaryKey="addressID"/>
            </table>
    
            <table name = "mycat_sequence" dataNode ="db_user_dataNode2" />
        </schema>

  • 相关阅读:
    【Docker】-NO.131.Docker.1 -【Docker】
    【HBase】-NO.140.HBase.1 -【HBase】
    【Vagrant】-NO.130.Vagrant.1 -【Vagrant】
    【技巧】-NO.123.数据处理技巧
    【Common】-NO.122.common.1
    【心得】-NO.114.面试.1 -【To HR And Interviewer】
    【JVM】-NO.113.JVM.1 -【JDK11 HashMap详解-4-resize()】
    【JVM】-NO.114.JVM.1 -【JDK11 HashMap详解-3-put-treeifyBin()-AVL】
    【JVM】-NO.115.JVM.1 -【JDK11 HashMap详解-4-伸展树、B树】
    【JVM】-NO.116.JVM.1 -【JDK11 HashMap详解-5-红黑树】
  • 原文地址:https://www.cnblogs.com/ph7seven/p/9865990.html
Copyright © 2011-2022 走看看