Lorentzca3 

DB(MySQL)

mhaconsul使







: 2

MySQL: 

: keepalivedvip





: 3

MySQL: mha

: consuldns使







2OS




keepalived



keepalivedpriorityvip




MySQL



3

3


3


1

2


233

mha使


mhaDB

DBDB(便)











mha使vagrantvm5vm5

keepalivedconsul使


consul(nginx)




stretcher + consul + capistrano 使 | feedforce Engineers' blog


consuldnsdnsmha DB consul








api(mha)

3使

keepalived


hashicorp


consul使 

mhavmdocker使

mhaconsul


mhaconsul使

mhaconsul

master_ip_failover_script


mha

/etc/mha.cnf
master_ip_failover_script=/path/to/script_name

DBmha()
/path/to/script_name --command=start \
--ssh_user=sshuser \
--orig_master_host=10.0.0.100 \
--orig_master_ip=10.0.0.100 \
--orig_master_port=3306 \
--new_master_host=10.0.0.101 \
--new_master_ip=10.0.0.101 \
--new_master_port=3306 \
--new_master_user='masteruser' \
--new_master_password='password' \
--ssh_options='\
-o ServerAliveInterval=60 \
-o ServerAliveCountMax=20 \
-o StrictHostKeyChecking=no \
-o ConnectionAttempts=5 \
-o PasswordAuthentication=no \
-o BatchMode=yes \
-i /path/to/ssh/privkey'





FIXME_xxx;consul(10.0.0.50)apiDBmha(new_master_ip)
  ## Update master ip on the catalog database, etc
- FIXME_xxx;
+ system("curl -s -X PUT -d \'{ \"Node\": \"master\", \"Address\": \"$new_master_ip\" }\' http://10.0.0.50:8500/v1/catalog/register");

DBFIXMEDB
  ## Creating an app user on the new master
- print "Creating app user on the new master..\n";
- FIXME_xxx_create_user( $new_master_handler->{DBh} );
- $new_master_handler->enable_log_bin_local();
- $new_master_handler->disconnect();
+ #print "Creating app user on the new master..\n";
+ #FIXME_xxx_create_user( $new_master_handler->{DBh} );
+ #$new_master_handler->enable_log_bin_local();
+ #$new_master_handler->disconnect();

consuldns


consulDB
$ dig @10.0.0.50 -p 8600 master.node.consul +short
10.0.0.100

 
*.consuldnsmasq使consulDNS

*.consul


*.consul10.0.0.508600
$ cat /etc/dnsmasq.d/consul.conf
server=/consul/10.0.0.50#8600

resolv.conf


/etc/dnsmasq.conf#strict-order

dnsmasq

$ cat /etc/resolv.conf
nameserver 127.0.0.1
nameserver 8.8.8.8




  dnsmasq(127.0.0.1)  *.consulconsul(10.0.0.50)8.8.8.8


*.consul
$ dig master.node.consul +short
10.0.0.100








consulDB

参考リンク

  • このエントリーをはてなブックマークに追加
Feedforce Developer Blog

新しいブログへ移行しました!こちらもよろしくお願いします。