ChaosXu / nerv

A new wheel for build PaaS
Apache License 2.0
5 stars 6 forks source link

MySQL HA #2

Open ChaosXu opened 7 years ago

ChaosXu commented 7 years ago

例如 缩容: 首先,给10台mysql安装缩容软件,配置好,跑起来。然后观察各mysql的复制进度,到一定程度(进度大致匹配,延迟小于某个阈值),锁住LVS(或者通知上层Route) 这样应用不会有流量写到各mysql, 然后等待各mysql的复制完毕,停止复制,通知LVS更改IP列表(原来10台可用的mysql地址改成缩容后的一台或两台)。缩容结束。

ChaosXu commented 7 years ago

MySQL HA: 方案:

  1. 两台MySQL ,一主一备
  2. 所有服务器部署keepalived,配置MySQL检测脚本(先尝试重启,失败关闭keepalived,以便切换到备机)
  3. 主启动,备启动keepalived,但不启动mysql

工作:

  1. 编写模板 2.编写MySQL资源类 3.编写MySQL脚本:
    1. create脚本:部署mysql,keepalived
    2. setup脚本:配置mysql,keepalived 模板: { "nodes":[ { "name":"mysql_master", "type": "/nerv/db/MySQL", "dependences" :[ { "type":"contained", "target":"host_master", } ] }, { "name":"mysql_backup", "type": "/nerv/db/MySQL", "dependences" :[ { "type":"contained", "target":"host_backup", } ] }, { "name":"host_master" "type": "/nerv/cluster/Host" }, { "name":"host_backup" "type": "/nerv/cluster/Host" } ] }