codecamp

Mycat2 集群 cluster

集群配置

{
    "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"
    }
}

c0.cluster.json

{集群名字}.cluster.json 保存在clusters文件夹 clusterType

  • SINGLE_NODE:单一节点
  • MASTER_SLAVE:普通主从
  • GARELA_CLUSTER:garela cluster/PXC集群
  • MHA:(v1.16提供,实验)
  • MGR:(v1.16提供,实验)

MHAMGR集群会在心跳过程中根据READ_ONLY状态判断当前节点是否从节点(READ_ONLY=ON),主节点(READ_ONLY=OFF)动态更新主从节点信息,这样可以支持多主,单主.但是实际上生产上建议暂时使用单主模式,或者多主作为单主使用

Mycat2 使用zookeeper部署多个Mycat2
Mycat2 数据源 datasource
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }