-
Notifications
You must be signed in to change notification settings - Fork 478
jamie12221 edited this page Nov 29, 2020
·
1 revision
注解使用SQL注释方式表达,可以用于动态更新Mycat配置并且把配置持久化
重置配置
/*+ mycat:resetConfig{} */
创建用户
/*+ mycat:createUser{
"username":"user",
"password":"",
"ip":"127.0.0.1",
"transactionType":"xa"
} */
删除用户
/*+ mycat:dropUser{
"username":"user"} */
显示用户
/*+ mycat:showUsers */
修改表序列号为雪花算法
/*+ mycat:setSequence{"name":"db1_travelrecord","time":true} */;
创建数据源
/*+ mycat:createDataSource{
"dbType":"mysql",
"idleTimeout":60000,
"initSqls":[],
"initSqlsGetConnection":true,
"instanceType":"READ_WRITE",
"maxCon":1000,
"maxConnectTimeout":3000,
"maxRetryCount":5,
"minCon":1,
"name":"dr0",
"password":"123456",
"type":"JDBC",
"url":"jdbc:mysql://127.0.0.1:3306?useUnicode=true&serverTimezone=UTC&characterEncoding=UTF-8",
"user":"root",
"weight":0
} */;
删除数据源
/*+ mycat:dropDataSource{
"dbType":"mysql",
"idleTimeout":60000,
"initSqls":[],
"initSqlsGetConnection":true,
"instanceType":"READ_WRITE",
"maxCon":1000,
"maxConnectTimeout":3000,
"maxRetryCount":5,
"minCon":1,
"name":"newDs",
"type":"JDBC",
"weight":0
} */;
显示数据源
/*+ mycat:showDataSources{} */
创建集群
/*! mycat:createCluster{
"clusterType":"MASTER_SLAVE",
"heartbeat":{
"heartbeatTimeout":1000,
"maxRetry":3,
"minSwitchTimeInterval":300,
"slaveThreshold":0
},
"masters":[
"dw0"
],
"maxCon":2000,
"name":"c0",
"readBalanceType":"BALANCE_ALL",
"replicas":[
"dr0"
],
"switchType":"SWITCH"
} */;
删除集群
/*! mycat:dropCluster{
"name":"testAddCluster"
} */;
显示集群
/*+ mycat:showClusters{} */
创建Schema
/*+ mycat:createSchema{
"customTables":{},
"globalTables":{},
"normalTables":{},
"schemaName":"test_add_Schema",
"shadingTables":{},
"targetName":"prototype"
} */;
创建单表
/*+ mycat:createTable{
"normalTable":{
"createTableSQL":"create table normal(id int)",
"dataNode":{
"schemaName":"testSchema",
"tableName":"normal",
"targetName":"prototype"
}
},
"schemaName":"testSchema",
"tableName":"normal"
} */;
创建全局表
/*+ mycat:createTable{
"globalTable":{
"createTableSQL":"create table global(id int)",
"dataNodes":[
{
"targetName":"prototype"
}
]
},
"schemaName":"testSchema",
"tableName":"global"
} */;
创建范围分表
/*+ mycat:createTable{
"schemaName":"testSchema",
"shadingTable":{
"createTableSQL":"create table sharding(id int)",
"dataNode":{
"schemaNames":"testSchema",
"tableNames":"sharding",
"targetNames":"prototype"
},
"function":{
"clazz":"io.mycat.router.mycat1xfunction.PartitionConstant",
"properties":{
"defaultNode":"0",
"columnName":"id"
}
}
},
"tableName":"sharding"
} */;
显示session引用的IO缓冲块计数
/*+ mycat:showBufferUsage{}*/
显示用户
/*+ mycat:showUsers{}*/
显示schema
/*+ mycat:showSchemas{}*/
显示调度器
/*+ mycat:showSchedules{}*/
显示心跳配置
/*+ mycat:showHeartbeats{}*/
显示心跳状态
/*+ mycat:showHeartbeatStatus{}*/
显示实例状态
/*+ mycat:showInstances{}*/
显示Reactor状态
/*+ mycat:showReactors{}*/
显示线程池状态
/*+ mycat:showThreadPools{}*/
显示表
/*+ mycat:showTables{"schemaName":"mysql"}*/
显示mycat连接
/*+ mycat:showConnections{}*/