当前位置:   article > 正文

MyCAT从入门到实战(MyCAT2注释配置)

mycat2

重置配置

/*+ mycat:resetConfig{} */;

用户相关

创建用户
  1. /*+ mycat:createUser{
  2. "username":"user",
  3. "password":"",
  4. "ip":"127.0.0.1",
  5. "transactionType":"xa"}
  6. */;

删除用户
/*+ mycat:dropUser{ "username":"user"} */;
显示用户
/*+ mycat:showUsers */;

数据源相关

建数据源
  1. /*+ mycat:createDataSource{
  2. "dbType":"mysql",
  3. "idleTimeout":60000,
  4. "initSqls":[],
  5. "initSqlsGetConnection":true,
  6. "instanceType":"READ_WRITE",
  7. "maxCon":1000,
  8. "maxConnectTimeout":3000,
  9. "maxRetryCount":5,
  10. "minCon":1,
  11. "name":"dc1",
  12. "password":"123456",
  13. "type":"JDBC",
  14. "url":"jdbc:mysql://127.0.0.1:3306?useUnicode=true&serverTimezone=UTC&characterEncoding=UTF-8",
  15. "user":"root",
  16. "weight":0}
  17. */;
 删除数据源
  1. /*+ mycat:dropDataSource{
  2. "dbType":"mysql",
  3. "idleTimeout":60000,
  4. "initSqls":[],
  5. "initSqlsGetConnection":true,
  6. "instanceType":"READ_WRITE",
  7. "maxCon":1000,
  8. "maxConnectTimeout":3000,
  9. "maxRetryCount":5,
  10. "minCon":1,
  11. "name":"dc1",
  12. "type":"JDBC",
  13. "weight":0}
  14. */;
显示数据源
/*+ mycat:showDataSources{} */;

集群相关

 创建集群
  1. 先创建两个数据源dc1和dc2,然后创建集群,dc1是主节点
  2. /*! mycat:createCluster{
  3. "clusterType":"MASTER_SLAVE",
  4. "heartbeat":{
  5. "heartbeatTimeout":1000,
  6. "maxRetry":3,
  7. "minSwitchTimeInterval":300,
  8. "slaveThreshold":0
  9. },
  10. "masters":[
  11. "dc1" //主节点
  12. ],
  13. "maxCon":200,
  14. "name":"c0",
  15. "readBalanceType":"BALANCE_ALL",
  16. "replicas":[
  17. "dc2" //从节点
  18. ],
  19. "switchType":"SWITCH"
  20. } */
删除集群
/*! mycat:dropCluster{ "name":"c0"} */;
显示集群
/*+ mycat:showClusters{} */

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/407224
推荐阅读
相关标签
  

闽ICP备14008679号