当前位置:网站首页>【mycat】mycat配置文件
【mycat】mycat配置文件
2022-07-24 05:19:00 【你怎么不笑了】
Mycat配置文件
1.服务(server)
服务相关配置,在conf路径下,默认配置即可

2.用户(user)
配置用户相关信息,在conf/users路径下
命令方式:{用户名}.user.json

vim root.user.json
{
"ip":null,
"password":"123456",
"transactionType":"xa",
"username":"root",
"isolation":3
}
# 字段含义
#ip:客户端访问ip,建议为空,填写后会对客户端的ip进行限制
#username:用户名
#password:密码
#isolation:初始化的事务隔离级别
READ_UNCOMMITTED:1
READ_COMMITTED:2
REPEATED_READ:3,默认
SERIALIZABLE:4
#transactionType:事务类型
proxy 本地事务,在涉及大于 1 个数据库的事务,commit 阶段失败会导致不一致,但是兼容性最好
xa 事务,需要确认存储节点集群类型是否支持 XA
3.数据源(datasource)
配置mycat连接的数据源信息,在conf/datasources路径下
命令方式:{数据源名称}.datasource.json

vim protorypeDs.datasource.json
{
"dbType": "mysql",
"idleTimeout": 60000,
"initSqls": [],
"initSqlsGetConnection": true,
"instanceType": "READ_WRITE",
"maxCon": 1000,
"maxConnectTimeout": 3000,
"maxRetryCount": 5,
"minCon": 1,
"name": "prototype",
"password": "123456",
"type": "JDBC",
"url":
"jdbc:mysql://127.0.0.1:3306/mysql?useUnicode=true&serverTimezone=UTC",
"user": "root",
"weight": 0,
"queryTimeout":30,//mills
}
#字段含义
# dbType:数据库类型,mysql
# name:用户名
# password:密码
# type:数据源类型,默认JDBC
# url:数据库访问地址
# idleTimeout:空闲连接超时时间
# initSqls:初始化SQL
# initSqlsGetConnection:对于jdbc每次获取连接是否都执行initSqls
# instanceType:配置实例只读还是读写,READ_WRITE,READ,WRITE
# weight:权重
# 连接相关配置
"maxCon": 1000,
"maxConnectTimeout": 3000,
"maxRetryCount": 5,
"minCon": 1
4.集群(cluster)
配置集群信息,在conf/clusters路径下
在mycat中,创建一个集群,就会对应生成一个cluster文件
命令方式:{集群名称}.cluster.json

vim prototype.cluster.json
{
"clusterType":"MASTER_SLAVE",
"heartbeat":{
"heartbeatTimeout":1000,
"maxRetryCount":3,//2021-6-4前是maxRetry,后更正为maxRetryCount
"minSwitchTimeInterval":300,
"slaveThreshold":0
},
"masters":[ //配置多个主节点,在主挂的时候会选一个检测存活的数据源作为主节点
"prototypeDs"
],
"replicas":[//配置多个从节点
"xxxx"
],
"maxCon":200,
"name":"prototype",
"readBalanceType":"BALANCE_ALL",
"switchType":"SWITCH",
"timer":{
//MySQL集群心跳周期,配置则开启集群心跳,Mycat主动检测主从延迟以及高可用主从切换
"initialDelay": 30,
"period":5,
"timeUnit":"SECONDS"
},
readBalanceName:"BALANCE_ALL",
writeBalanceName:"BALANCE_ALL",
}
#字段含义
# clusterType:集群类型,可选值SINGLE_NODE:单一节点,MASTER_SLAVE:普通主从,GARELA_CLUSTER:garela cluster/PXC集群,MHA:MHA 集群,MGR:MGR 集群
# readBalanceType:查询负载均衡策略
可选值:
BALANCE_ALL(默认值)
获取集群中所有数据源
BALANCE_ALL_READ
获取集群中允许读的数据源
BALANCE_READ_WRITE
获取集群中允许读写的数据源,但允许读的数据源优先
BALANCE_NONE
获取集群中允许写数据源,即主节点中选择
# switchType:切换类型
可选值:
NOT_SWITCH:不进行主从切换
SWITCH:进行主从切换
官网:mycat文档
5.逻辑库表(schema)
配置逻辑库表,实现分库分表,在conf/schemas路径
在mycat中创建一个逻辑库,就会对应生成一份schema文件
命令方式:{库名}.schema.json

vim mysql.schema.json
# 库配置
{
"schemaName": "mydb",
"targetName": "prototype"
}
# schemaName:逻辑库名
# targetName:目的数据源或集群,targetName自动从prototype目标加载test库下的物理表或者视图作为单表,prototype必须是mysql服务器
#单表配置
{
"schemaName": "mysql-test",
"normalTables": {
"role_edges": {
"createTableSQL":null,//可选
"locality": {
"schemaName": "mysql",//物理库,可选
"tableName": "role_edges",//物理表,可选
"targetName": "prototype"//指向集群,或者数据源
}
}
......
#详细配置见分库分表
边栏推荐
- MySQL之CRUD
- 自定义MVC 1.0
- Canvas Bezier Bezier curve
- Draw a circle and a square on the screen. The square is in front and the circle is behind. You can move the square through the keyboard. In the following cases, the square can only move within the cir
- mapboxgl + geoserver 配置本地地图教程
- Tree structure + node
- sunset: noontide靶机渗透-vulnhub
- How to use phpstudy to build WordPress website locally
- The bottom of decentralization is consensus -- Interpretation of Polkadot mixed consensus mechanism
- Insanity:1(Insanity-Hosting)靶机渗透 —Vulnhub
猜你喜欢

How to use phpstudy to build WordPress website locally

达梦数据库_LENGTH_IN_CHAR和CHARSET的影响情况

Canvas - round

Flink Format系列(1)-JSON

Oracle数据库的逻辑结构

Canvas - fill

Flink task, sub task, task slot and parallelism

Canvas Bezier Bezier curve

Analysis of Dao liquidity dual currency pledge mining development principle

jsp标签02
随机推荐
助力传统游戏转型GameFi,Web3Games推动游戏发展新航向
Useref create dynamic reference
PyCharm设置代码模板
Canvas - rotate
OpenGL draws a cone on the screen, which has four faces, each of which is a triangle. Add lighting and texture effects to the cone
Keywords_ 02break and continue
Development technical guide | the most complete technical documents, tutorials and courses of substrate and Polkadot
Flink重启策略
Public chain Sui layer1 network
Wechat applet reports an error request:fail -2:net:: err_ FAILED
Moonbeam Orbiters Program:为收集人参与 Moonbeam 和 Moonriver 提供新方式
Flink Task、Sub-Task、task slot和parallelism
整站下载器推荐
【数据挖掘】聚类分析的简要介绍
MySQL的分页你还在使劲的limit?
Function analysis of GeoServer rest API
How can the multiple-choice and single choice results of PHP be displayed in the foreground?
【vsphere高可用】主机和虚拟机故障监测工作原理
人生警示格言
Three -- orbitcontrols track controller