当前位置:网站首页>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
边栏推荐
猜你喜欢

Talk about the basic but not simple stock data

第一性原理 思维导图

excle加水印

idea底栏打开services

396. Rotate Function

信息收集相关知识点及题解

Yangtao electronic STM32 Internet of things entry 30 step notes II. Cube ide download, installation, sinicization and setting

vmware 搭建ES8的常见错误

【路科V0】验证环境2——验证环境组件

跨域配置报错: When allowCredentials is true, allowedOrigins cannot contain the special value “*“
随机推荐
RPC过程
Navicat远程连接mysql
LINQ学习系列-----1.4 匿名对象
[C语言] 文件操作《一》
DOM 学习之—添加+-按钮
Failed to convert a NumPy array to a Tensor(Unsupported Object type int)
npm安装yarn
Data deletion and modification (MySQL)
SYS_ CONNECT_ BY_ Path (column, 'char') combined with start with connect by prior
什么是RPC
Qtablewidget header customization and beautification developed by pyqt5 (with source code download)
How to encrypt devices under the interconnection of all things
Redis master-slave server problem
Transformer XL: attention language modelsbbeyond a fixed length context paper summary
Sword finger offer Day24 math (medium)
flask项目跨域拦截处理以及dbm数据库学习【包头文创网站开发】
swagger文档导出自定义v2/api-docs拦截
RCC introduction of Hal Library
ajax防止缓存方法
ansible自动化运维详解(一)ansible的安装部署、参数使用、清单管理、配置文件参数及用户级ansible操作环境构建