mycat1.6.5分片(字符串拆分hash)
https://blog.csdn.net/webnum/article/details/78313525
分片规则:字符串拆分hash
一、conf/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">
- <table name="partition_by_string" primaryKey="ord_no" dataNode="dn$0-2"
- rule="partition-by-string" />
- </schema>
- <dataNode name="dn0" dataHost="dh-1" database="db0"/>
- <dataNode name="dn1" dataHost="dh-1" database="db1"/>
- <dataNode name="dn2" dataHost="dh-1" database="db2"/>
- <dataHost name="dh-1" maxCon="1000" minCon="10" balance="0"
- writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
- <heartbeat>select user()</heartbeat>
- <writeHost host="hostM1" url="localhost:3306" user="root"
- password="123456">
- </writeHost>
- </dataHost>
- </mycat:schema>
二、conf/rule.xml文件
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mycat:rule SYSTEM "rule.dtd">
- <mycat:rule xmlns:mycat="http://io.mycat/">
- <tableRule name="partition-by-string">
- <rule>
- <columns>ord_no</columns>
- <algorithm>partition-by-string</algorithm>
- </rule>
- </tableRule>
- <function name="partition-by-string"
- class="io.mycat.route.function.PartitionByString">
- <property name="partitionLength">512</property> <!-- zero-based -->
- <property name="partitionCount">2</property>
- <property name="hashSlice">-6:0</property>
- </function>
- </mycat:rule>
三、规则文件信息
无
四、测试用到的sql
- =============按照ord_no字段 字符串hash ================
- CREATE TABLE partition_by_string (ord_no varchar(20) NULL,`db_nm` varchar(20) NULL);
- INSERT INTO `partition_by_string` (ord_no,db_nm) VALUES (171022237582, database());
- INSERT INTO `partition_by_string` (ord_no,db_nm) VALUES (171022553756, database());
- select * from partition_by_string;
五、注意事项
分片数量必须小于等于dataNode数
六、参数说明
length代表字符串hash求模基数,count分区数,其中length*count=1024
hashSlice hash预算位,即根据子字符串中int值 hash运算
0 代表 str.length(), -1 代表 str.length()-1,大于0只代表数字自身
可以理解为substring(start,end),start为0则只表示0
例1:值“45abc”,hash预算位0:2 ,取其中45进行计算
例2:值“aaaabbb2345”,hash预算位-4:0 ,取其中2345进行计算
mycat1.6.5分片(字符串拆分hash)的更多相关文章
- 2016/4/5 Ajax ①用户名 密码 登陆 注册 ② 判断用户名是否已存在 ③点击按钮出现民族选项下拉菜单 ④DBDA类 加入Ajaxquery方法 数组变字符串 字符串拆分
①登陆 注册 查表匹配 0405Ajax.php ②判断用户名是否存在 <!DOCTYPE html> <html lang="en"> ...
- UTF-8编码的字符串拆分成单字、获取UTF-8字符串的字符个数的代码及原理
一.字符编码简介 1. ASCII码 在计算机内部,所有的信息最终都表示为一个二进制的字符串.每一个二进制位(bit)有0和1两种状态,因此八个二进制位就可以组合出256种状态,这被称为一个字节(by ...
- SQL2000/2005字符串拆分为列表通用函数
------------------------------------------------------------------ -- Author : htl258(Tony) -- Dat ...
- redis 2 字符串 和 hash
string是最简单的类型,一个key对应一个value,string类型是二进制安全的.redis的string可以包含任何数据,比如JPG图片或者序列化的对象 操作 set 设置key ...
- sql之cursor的简介和字符串拆分(split)与游标的使用
字符串拆分(split)与游标的使用 CREATE TABLE Plates ( ,), ) NOT NULL, [BusinessId] INT NOT NULL, ) ),),), SELECT ...
- SQL 字符串拆分
字符串拆分: ALTER FUNCTION [dbo].[f_Split](@sText nvarchar(max),@split NVARCHAR(20)) RETURNS @t TABLE (id ...
- php将长字符串拆分为指定最大宽度的字符串数组
/** * 将字符串拆分为指定最大宽度的字符串数组.单字节字符宽度为1,多字节字符通常宽度为2 * @param string $msg 要拆分的字符串 * @param int $width 结果数 ...
- 截取字符(pos,copy,Leftstr,MidStr,RightStr)以逗号为准把字符串拆分,判断字符串是否有数字、字母(大小写), 去掉字符串空格
1.copy(a,b,c) 举个例子: str := “123456”;str1 := Copy(Str,2,3);结果就是 str1 等于 234.Copy有3个参数,第一个是你要处理的字符串,第二 ...
- Java字符串拆分和字符串连接
Java字符串拆分/连接 public class LierString{ //------------------------------------------------------------ ...
随机推荐
- bzoj 3730 震波 —— 动态点分治+树状数组
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3730 建点分树,每个点记两个树状数组,存它作为重心管辖的范围内,所有点到它的距离情况和到它在 ...
- 开启现有android项目
开启工程 在屏幕上方的选单列上,选择「File->New->Project」, 会弹出「New Project」对话视窗.Eclipse 是通用的编辑环境,可根据你所安装的不同扩充套件而支 ...
- windows服务和进程的区别和联系
Windows Service 是主要用于服务器环境而长期运行的应用程序, 这类程序不需要有用户界面或者任何模拟输出. 任何的用户消息通常都是记录在Windows 事件日志里.Windows Serv ...
- canvas实现平铺
代码: /** * Created by Administrator on 2016/1/30. */ function draw(id){ var canvas = document.getElem ...
- <正则吃饺子> :关于使用pd创建表时需要注意的地方
公司项目使用pd设计数据库表.之前用过,但是年代比较久远了,有些细节忘记了,今天重新使用时候,生疏了,现在稍微记录下吧. 1.pd创建表的使用,可以直接从网上搜索,博文比较多,如 “pd 设计数据库表 ...
- Mysql 数据库时间更新字段
关于时间更新: 创建时间: CURRENT_TIMESTAMP 更新时间: 勾选根据时间戳更新
- 串口发送Hex数组
void MainWindow::String2Hex(QString str, QByteArray &senddata) { int hexdata,lowhexdata; ; int l ...
- struts2 json返回试验
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-/ ...
- Spring, Hibernate and Oracle Stored Procedures
一篇英文博文,写的是利用hibernate处理存储过程中的游标等等: Motivation: While there are a few resources available online for ...
- 杭电acm 1022题
Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot o ...