当前位置:网站首页>mycat配置
mycat配置
2022-04-23 08:16:00 【雅俗共赏zyyyyyy】
<!--schema用来定义mycat的逻辑库,表,分片规则,dataNode和dataHost-->
<mycat:schema xmlns:mycat="http://io.mycat/">
<schema name="这里写数据库名称" checkSQLschema="false" sqlMaxLimit="100">
<!--checkSQLschema用来检查是否通过数据库名.表名的方式来查询,若为true,则查询的sql会成为select * from 数据库名.表名;若为false,则sql为select * from 表名-->
<!--sqlMaxLimit用来实现limit,即使sql没有显示定义limit,设置该值后,sql效果等同于limit 100-->
<table name="这里写表名,是要分片的逻辑表" primaryKey="id" dataNode="要与dataNode的name属性一致,比如这里dn5" subTables="表名_$1-100,这个代表100张分片表,表名+下划线+数字" rule="分片规则名称,该规则名称在rule.xml定义,例如ysgs"/>
</schema>
<!--实体库相关-->
<dataNode name="dn5" dataHost="数据库实例,与dataHost的name属性一致,例如localhost4" database="实体数据库名称" />
<!--实例连接相关-->
<!--balance属性代表负载均衡策略:
balance=”0”, 不开启读写分离机制,所有读操作都发送到当前可用的writeHost上。
balance=”1”,全部的readHost与stand by writeHost参与select语句的负载均衡,简单的说,当双主双从模式(M1->S1,M2->S2,并且M1与 M2互为主备),正常情况下,M2,S1,S2都参与select语句的负载均衡。
balance=”2”,所有读操作都随机的在writeHost、readhost上分发。
balance=”3”,所有读请求随机的分发到wiriterHost对应的readhost执行,writerHost不负担读压力
-->
<!--dbDriver,指定连接后端数据库使用的Driver,目前可选的值有native和JDBC。使用native的话,因为这个值执行的是二进制的mysql协议,所以可以使用mysql和maridb。其他类型的数据库则需要使用JDBC驱动来支持-->
<!--switchType,-1代表不自动切换;1默认值,自动切换;2基于mysql主从状态切换;3基于集群切换-->
<dataHost name="localhost4" maxCon="指定每个读写实例连接池的最大连接,例如1000" minCon="指定每个读写实例连接池的最小连接,例如10" balance="0"
writeType="1" dbType="数据库类型,例如mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM1" url="数据库连接" user="用户名" password="密码">
</writeHost>
</dataHost>
</mycat:schema>
<!--rule.xml配置相关-->
<tableRule name="ysgs,这个对应上上面写的分片规则名称">
<rule>
<columns>以哪个列名作为分片基准</columns>
<algorithm>分片规则,murmur代表一致性hash,10种分片规则见其他博主博客,链接为[https://blog.csdn.net/zxp2624161989/article/details/107230370/](https://blog.csdn.net/zxp2624161989/article/details/107230370/)</algorithm>
</rule>
</tableRule>
<function name="murmur"
class="io.mycat.route.function.PartitionByMurmurHash">
<property name="seed">0</property><!-- 默认是0 -->
<property name="count">100</property><!-- 要分片的数据库节点数量,必须指定,否则没法分片 -->
<property name="virtualBucketTimes">160</property><!-- 一个实际的数据库节点被映射为这么多虚拟节点,默认是160倍,也就是虚拟节点数是物理节点数的160倍 -->
<!-- <property name="weightMapFile">weightMapFile</property> 节点的权重,没有指定权重的节点默认是1。以properties文件的格式填写,以从0开始到count-1的整数值也就是节点索引为key,以节点权重值为值。所有权重值必须是正整数,否则以1代替 -->
<!-- <property name="bucketMapPath">/etc/mycat/bucketMapPath</property>
用于测试时观察各物理节点与虚拟节点的分布情况,如果指定了这个属性,会把虚拟节点的murmur hash值与物理节点的映射按行输出到这个文件,没有默认值,如果不指定,就不会输出任何东西 -->
</function>
版权声明
本文为[雅俗共赏zyyyyyy]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_36933421/article/details/124349997
边栏推荐
- 《深度学习》学习笔记(八)
- Sword finger offer Day24 math (medium)
- 396. Rotate Function
- 匿名类型(C# 指南 基础知识)
- Green apple film and television system source code film and television aggregation film and television navigation film and television on demand website source code
- Transformer XL: attention language modelsbbeyond a fixed length context paper summary
- Stm32f103zet6 [development of standard library functions] - Introduction to library functions
- Search the complete navigation program source code
- okcc呼叫中心外呼系统智能系统需要用多大的盘存录音?
- JS中复制数组
猜你喜欢

Excle plus watermark

idea配置连接远程数据库MySQL,或者是Navicat连接远程数据库失败问题(已解决)

Shell script advanced

Talk about the basic but not simple stock data

ansible自動化運維詳解(一)ansible的安裝部署、參數使用、清單管理、配置文件參數及用戶級ansible操作環境構建
![[learning] audio and video development from scratch (9) -- nuplayer](/img/62/20b0d80088181fb6ff1fe842500c0a.png)
[learning] audio and video development from scratch (9) -- nuplayer

四张图弄懂matplotlib的一些基本用法

Campus transfer second-hand market source code download

QT reading and writing XML files

项目上传部分
随机推荐
Navicat remote connection MySQL
洋桃電子STM32物聯網入門30步筆記一、HAL庫和標准庫的區別
okcc呼叫中心外呼系统智能系统需要用多大的盘存录音?
洋桃电子STM32物联网入门30步笔记三、CubeMX图形化编程、设置开发板上的IO口
form表单 post提交 数据量大的问题
ELK生产实践
Using qlst excel file
The annotation is self-defined by implementing the parameter parser handlermethodargumentresolver interface
Idea: export Yapi interface using easyyapi plug-in
信息收集相关知识点及题解
洋桃电子STM32物联网入门30步笔记三、新建CubeIDE工程和设置讲解
RPC过程
An example of network communication based on TCP / IP protocol -- file transmission
JS中复制数组
Large amount of data submitted by form post
根据字节码获取类的绝对路径
数论求a^b(a,b为1e12级别)的因子之和
Anonymous type (c Guide Basics)
form中enctype属性
一个必看的微信小程序开发指南1-基础知识了解