8.1 时间戳方式全局序列的配置

配置表tb的id列为时间戳方式全局序列,并按id列分片

1)schema.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE dble:schema SYSTEM "schema.dtd">
        <schema name="myschema" dataNode="dn1">
                <table name="tb"  dataNode="dn1,dn2" rule="rule-tb" primaryKey="id" autoIncrement="true"/>
        </schema>
        <dataNode name="dn1" dataHost="host_1" database="dble" /> 
        <dataNode name="dn2" dataHost="host_2" database="dble" />
        <dataHost name="host_1" maxCon="1000" minCon="1000" balance="0" switchType="1"  slaveThreshold="100">
        <heartbeat>select user()</heartbeat>
        <writeHost host="hostM1" url="172.100.10.101:3306" user="test1" password="test1"></writeHost>
        </dataHost>
        <dataHost name="host_2" maxCon="1000" minCon="1000" balance="0" switchType="1"  slaveThreshold="100">
        <heartbeat>select user()</heartbeat>
        <writeHost host="hostM2" url="172.100.10.102:3306" user="test1" password="test1"></writeHost>
        </dataHost>
<dble:schema xmlns:dble="http://dble.cloud/">

2)rule.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE dble:rule SYSTEM "rule.dtd">
          <tableRule name="rule-tb">
              <rule>
                  <columns>id</columns>
                  <algorithm>mod</algorithm>
              </rule>
          </tableRule>
          <function name="mod" class="Hash">
                <property name="partitionCount">2</property>
                <property name="partitionLength">1</property>
        </function>
<dble:rule xmlns:dble="http://dble.cloud/">

3)server.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE dble:server SYSTEM "server.dtd">
    <system>
        <property name="sequnceHandlerType">2</property>
        <property name="processors">4</property>
        <property name="backendProcessors">4</property>
        <property name="processorExecutor">8</property>
        <property name="backendProcessorExecutor">4</property>
        <property name="sqlExecuteTimeout">3000000</property>
    </system>
    <user name="abc">
        <property name="password">abc</property>
        <property name="schemas">myschema</property>
        <property name="benchmark">1000000</property>
    </user>
     <user name="test">
         <property name="password">test</property>
         <property name="manager">true</property>
      </user>
<dble:server xmlns:dble="http://dble.cloud/">

4)sequence_time_conf.properties

WORKID=01
DATAACENTERID=01
START_TIME=2010-10-01 09:42:54

配置要点:

  • schema.xml:
<table name="tb"  dataNode="dn1,dn2" rule="rule-tb" primaryKey="id" autoIncrement="true"/>
  • server.xml:
<property name="sequnceHandlerType">2</property>
  • sequence_time_conf.properties(默认配置同上): 如果使用集群,WORKID,DATAACENTERID的配置必须使该dble实例在dble集群中唯一,且必须为[0,31]之间的整数

results matching ""

    No results matching ""