当前位置:网站首页>【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"//指向集群,或者数据源
}
}
......
#详细配置见分库分表
边栏推荐
- Flink state使用
- Function Closure
- MySQL 批量插入demo
- Mapboxgl + GeoServer configuration local map tutorial
- Penetration testing knowledge - industry terminology
- Hex to RGB
- Restore UI design draft
- Canvas - round
- Flink 生产环境配置建议
- MySQL queries the last four digits of the mobile phone number. How to write the first few digits?
猜你喜欢

Flink 生产环境配置建议

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

Imitate Baidu API of Baidu map page of a website

jsp标签02

黑龙江省SVG格式地图的创建及生成

自定义MVC 3.0

Hurry in!! Take you to understand what is multi file, and easily master the usage of extern and static C language keywords!!!

Fusdt流动性质押挖矿开发逻辑系统原理

Pycharm configures LAN access, and the LAN cannot access the solution

Flink Task、Sub-Task、task slot和parallelism
随机推荐
量化合约夹子套利机器人系统逻辑开发原理分析
vulnhub-SolidState: 1靶机渗透测试
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
WASM VS EVM,波卡的选择预示了公链未来
PyCharm设置代码模板
MySQL queries the last four digits of the mobile phone number. How to write the first few digits?
数据仓库与数仓建模
3. Draw a five sided cone with a square bottom on the screen. The bottom of the cone is on the xoz plane and the top of the cone is on the Y axis. Use the following figure to map the texture of the fo
jsp标签
Keywords_ 02break and continue
7. Draw a Bezier curve on the screen and smooth the curve with anti aliasing technology.
微信小程序报错request:fail -2:net::ERR_FAILED
Wechat applet reports an error request:fail -2:net:: err_ FAILED
select_ Render small phenomena
Vulnhub funbox: rookie (funbox2) target penetration
LP双币流动性质押挖矿系统逻辑开发分析
mysql查询手机号码后四位,前几位怎么写?
Flink 时间流处理
Why is music NFT popular? Polkadot may become the best choice for developing music NFT
The profound meaning of unlimited ecological development in Poka -- Multidimensional Interpretation of parallel chain