当前位置:网站首页>【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"//指向集群,或者数据源
}
}
......
#详细配置见分库分表
边栏推荐
- There are three ways to create in Polkadot - parallel chain, parallel thread, and smart contract
- 自定义MVC 2.0
- 【vsphere高可用】虚拟机的重置和重启
- Review the whole process of the 5th Polkadot Hackathon entrepreneurship competition, and uncover the secrets of the winning projects!
- select_ Render small phenomena
- php的多选、单选结果怎么在前台显示?
- Inventory Poka ecological potential project | cross chain characteristics to promote the prosperity of multi track
- Function_ generalization
- Node connects to MySQL and uses Navicat for visualization
- Principle of fusdt liquidity pledge mining development logic system
猜你喜欢

Mapboxgl + GeoServer configuration local map tutorial

sunset: noontide靶机渗透-vulnhub

网页播放rtsp视频流
![[Baidu map API] the version of the map JS API you are using is too low and no longer maintained. In order to ensure the normal use of the basic functions of the map, please upgrade to the latest versi](/img/d5/b0e4cc4155673d6042a0e39de4eddf.png)
[Baidu map API] the version of the map JS API you are using is too low and no longer maintained. In order to ensure the normal use of the basic functions of the map, please upgrade to the latest versi

How to use phpstudy to build WordPress website locally

助力传统游戏转型GameFi,Web3Games推动游戏发展新航向

select_ Render small phenomena

The profound meaning of unlimited ecological development in Poka -- Multidimensional Interpretation of parallel chain

如何强制卸载Google浏览器,不用担心Google打开为白板,亲测有效。

ODS、数据集市、数据仓库的异同点
随机推荐
【vsphere高可用】虚拟机的重置和重启
微信小程序返回携带参数或触发事件
通用分页2.0
Principle of fusdt liquidity pledge mining development logic system
在 Polkadot 中进行创建的三种方式 —— 平行链、平行线程、智能合约
Public chain Sui layer1 network
haclabs: no_ Name (hl.ova) target penetration vulnhub
Substrate technology and ecology June memorabilia | Polkadot decoded came to a successful conclusion, and the hacker song winning project injected new forces into the ecosystem
Tree structure + node
首届波卡黑客松项目「Manta Network」的进击之路
Function analysis of GeoServer rest API
Create a new UMI project, error: rendered more hooks or rendered fewer hooks
数据仓库与数仓建模
4. Draw a red triangle and a yellow square on the screen. Triangle in the back, small; Square in front, big. Using the fusion technology, the triangle can be seen through the square, and the source an
Mobile software development ISO simple wechat
Open Web3, once unpopular decentralized identity (did)
Review the whole process of the 5th Polkadot Hackathon entrepreneurship competition, and uncover the secrets of the winning projects!
mysql数据库的授权访问
音乐 NFT 为什么火了?Polkadot 或将成为发展音乐 NFT 的最佳选择
微信小程序map的使用