Mycat zookeeper norm zookeeper sharding-by-month

Source: Internet
Author: User
Tags dateformat

Mycat zookeeper norm zookeeper sharding-by-month

Sharding-by-month has been used when calling Dynamic Route

1. rule. xml

Please wait until (then again) until then again before again until then

  1. <TableRule name = "sharding-by-month">
  2. <Rule>
  3. <Columns> createtime </columns>
  4. <Algorithm> partbymonth </algorithm>
  5. </Rule>
  6. </TableRule>
  7. <Function name = "partbymonth"
  8. Class = "io. mycat. route. function. PartitionByMonth">
  9. <Property name = "dateFormat"> yyyy-MM-dd HH: mm: ss </property>
  10. <Property name = "sBeginDate"> 00:00:00 </property>
  11. </Function>
DateFormat: How many threads are there? SBeginDate? Br/>
2. schema. xml
Please wait until (then again) until then again before again until then
  1. <? Xml version = "1.0"?>
  2. <! DOCTYPE mycat: schema SYSTEM "schema. dtd">
  3. <Mycat: schema xmlns: mycat = "http://io.mycat/">

  4. <Schema name = "logdb" checkSQLschema = "false" sqlMaxLimit = "100">
  5. <Table name = "tb_log_t" primaryKey = "ID" autoIncrement = "true" dataNode = "dn1, dn2, dn3, dn4, dn5, dn6 "rule =" mod-long "/>
  6. <Table name = "tb_user_t" dataNode = "dn1, dn2, dn3, dn4, dn5, dn6" rule = "sharding-by-intfile-provcode"/>
  7. <Table name = "tb_user_detail_t" dataNode = "dn1, dn2, dn3, dn4, dn5, dn6" rule = "auto-sharding-long-userid"/>
  8. <Table name = "tb_user_murmur_t" dataNode = "dn1, dn2, dn3, dn4, dn5, dn6" rule = "sharding-by-murmur"/>
  9. <Table name = "tb_user_murmur_string_t" dataNode = "dn1, dn2, dn3, dn4, dn5, dn6" rule = "sharding-by-murmur-userid"/>
  10. <Table name = "tb_user_crc32slot_t" dataNode = "dn1, dn2, dn3, dn4, dn5, dn6" rule = "crc32slot"/>
  11. <Table name = "tb_user_partbymonth_t" dataNode = "dn $1-13" rule = "sharding-by-month"/>
  12. </Schema>
  13. <Schema name = "coss03" checkSQLschema = "false" sqlMaxLimit = "100" dataNode = "dnoss03"/>
  14. <DataNode name = "dn1" dataHost = "localhost1" database = "log01"/>
  15. <DataNode name = "dn2" dataHost = "localhost1" database = "log02"/>
  16. <DataNode name = "dn3" dataHost = "localhost1" database = "log03"/>
  17. <DataNode name = "dn4" dataHost = "localhost1" database = "log04"/>
  18. <DataNode name = "dn5" dataHost = "localhost1" database = "log05"/>
  19. <DataNode name = "dn6" dataHost = "localhost1" database = "log06"/>
  20. <DataNode name = "dn7" dataHost = "localhost1" database = "log01"/>
  21. <DataNode name = "dn8" dataHost = "localhost1" database = "log02"/>
  22. <DataNode name = "dn9" dataHost = "localhost1" database = "log03"/>
  23. <DataNode name = "dn10" dataHost = "localhost1" database = "log04"/>
  24. <DataNode name = "dn11" dataHost = "localhost1" database = "log05"/>
  25. <DataNode name = "dn12" dataHost = "localhost1" database = "log06"/>
  26. <DataNode name = "dn13" dataHost = "localhost1" database = "log01"/>
  27. <DataNode name = "dnoss03" dataHost = "localhost1" database = "oss03"/>
  28. <DataHost name = "localhost1" maxCon = "1000" minCon = "10" balance = "0"
  29. WriteType = "0" dbType = "mysql" dbDriver = "native" switchType = "1" slaveThreshold = "100">
  30. <Heartbeat> select user ()
  31. <! -- Can have multi write hosts -->
  32. <WriteHost host = "hostM1" url = "192.168.56.141: 3306" user = "root"
  33. Password = "mysql">
  34. <! -- Can have multi read hosts -->
  35. <ReadHost host = "hostS2" url = "192.168.56.142: 3306" user = "root" password = "mysql"/>
  36. </WriteHost>
  37. </DataHost>
  38. </Mycat: schema>
Name = "tb_user_partbymonth_t? Dn $1-13 "13 atatanode, datanode ogogog( log01 og06 ), 13 atatanode, 13? What do you call this? 015-01 success? 016-01, there are two major reasons for this problem. chema. xml cute.

3. Why? Br/> create table 'tb _ user_partbymonth_t '(
'Id' varchar (32) not null,
'Name' varchar (64) default null,
'Createtime' datetime DEFAULT CURRENT_TIMESTAMP
) ENGINE = InnoDB default charset = utf8;

Zookeeper editions)
Insert into tb_user_partbymonth_t (id, name, createtime) values ('a0001 ', 'name1', '2017-01-01 10:00:00 ');
Insert into tb_user_partbymonth_t (id, name, createtime) values ('a0002', 'name1', '2017-02-02 10:00:00 ');
Insert into tb_user_partbymonth_t (id, name, createtime) values ('a0003', 'name1', '2017-03-01 00:00:00 ');
Insert into tb_user_partbymonth_t (id, name, createtime) values ('a0004', 'name1', '2017-04-01 00:00:00 ');
Insert into tb_user_partbymonth_t (id, name, createtime) values ('a0005 ', 'name1', '2017-05-01 10:00:00 ');
Insert into tb_user_partbymonth_t (id, name, createtime) values ('a0006', 'name1', '2017-06-02 10:00:00 ');
Insert into tb_user_partbymonth_t (id, name, createtime) values ('a0007', 'name1', '2017-07-01 00:00:00 ');
Insert into tb_user_partbymonth_t (id, name, createtime) values ('a0008', 'name1', '2017-08-01 00:00:00 ');

Insert into tb_user_partbymonth_t (id, name, createtime) values ('a0009', 'name1', '2017-09-01 10:00:00 ');
Insert into tb_user_partbymonth_t (id, name, createtime) values ('a0010', 'name1', '2017-10-02 10:00:00 ');
Insert into tb_user_partbymonth_t (id, name, createtime) values ('a0011', 'name1', '2017-11-01 00:00:00 ');
Insert into tb_user_partbymonth_t (id, name, createtime) values ('a0012', 'name1', '2017-12-01 00:00:00 ');

Insert into tb_user_partbymonth_t (id, name, createtime) values ('a0013 ', 'name1', '2017-01-01 00:00:00 ');

-- The End --

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.