日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

Mysql5.5部署MHA

發布時間:2023/12/31 数据库 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Mysql5.5部署MHA 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

MHA分管理節點和數據庫節點,數據庫節點由mysql主從或者主主從構成,當主庫掛掉后,管理節點會自動將從節點提升為主節點;管理節點的角色類似于oracle數據庫中的fast start failover中的observer,但mha上層可以通過keepalive部署VIP,程序連接數據庫使用VIP,從而實現后臺數據庫的故障切換透明化

MHA節點包含三個腳本,依賴perl模塊;
save_binary_logs:保存和復制當掉的主服務器二進制日志;
apply_diff_relay_logs:識別差異的relay log事件,并應用于其他salve服務器;
purge_relay_logs:清除relay log文件;
需要在所有mysql服務器上安裝MHA節點,MHA管理服務器也需要安裝。MHA管理節點模塊內部依賴MHA節點模塊;
MHA管理節點通過ssh連接管理mysql服務器和執行MHA節點腳本。MHA節點依賴perl的DBD::mysql模塊;

本文環境介紹,操作系統均為rhel5.4
主庫:192.168.123.13/dg53.yang.com
備庫:192.168.123.14/dg54.yang.com
管理節點:192.168.123.15/dg55.yang.com

在開始之前,請先配置好服務器間的時間同步和名稱解析

一:在數據庫節點安裝mha node

  • [root@dg53?~]#?rpm?-ivh?http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm ?
  • Retrieving?http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm ?
  • warning:?/var/tmp/rpm-xfer.yqwfYT:?Header?V3?DSA?signature:?NOKEY,?key?ID?217521f6 ?
  • Preparing...????????????????###########################################?[100%] ?
  • ???1:epel-release???????????###########################################?[100%] ?
  • ?
  • [root@dg53?~]#?ls?/etc/yum.repos.d/ ?
  • base.repo??epel.repo??epel-testing.repo??rhel-debuginfo.repo ?
  • [root@dg53?~]#?yum?-y?install?perl-DBD-MySQL??ncftp ?
  • [root@dg53?~]#??wget?http://mysql-master-ha.googlecode.com/files/mha4mysql-node-0.52.tar.gz?-P?/usr/local/src/tarbag/ ?
  • [root@dg53?~]#?cd?/usr/local/src/tarbag/ ?
  • [root@dg53?tarbag]#?tar?-zxvpf?mha4mysql-node-0.52.tar.gz?-C?../software/ ?
  • [root@dg53?tarbag]#?cd?../software/mha4mysql-node-0.52/ ?
  • [root@dg53?mha4mysql-node-0.52]#?perl?Makefile.PL? ?
  • [root@dg53?mha4mysql-node-0.52]#?make?&&?make?install?
  • 二:管理節點
    1:按照步驟一安裝mha node

    2:安裝mha manager

  • [root@dg55?~]#?yum?-y?install?perl-Config-Tiny?perl-Params-Validate?perl-Log-Dispatch?perl-Parallel-ForkManager ?
  • [root@dg55?~]#?wget?http://mysql-master-ha.googlecode.com/files/mha4mysql-manager-0.52.tar.gz?-P?/usr/local/src/tarbag/ ?
  • [root@dg55?~]#?cd?/usr/local/src/tarbag/ ?
  • [root@dg55?tarbag]#?tar?-zxvpf?mha4mysql-manager-0.52.tar.gz?-C?../software/ ?
  • [root@dg55?tarbag]#?cd?../software/mha4mysql-manager-0.52/ ?
  • [root@dg55?mha4mysql-manager-0.52]#?perl?Makefile.PL ?
  • [root@dg55?mha4mysql-manager-0.52]#?make?&&?make?install?
  • 3:編輯配置文件

  • [root@dg55?mha4mysql-manager-0.52]#?mkdir?/etc/masterha ?
  • [root@dg55?mha4mysql-manager-0.52]#?mkdir?-p?/masterha/app1 ?
  • [root@dg55?mha4mysql-manager-0.52]#?cp?samples/conf/*?/etc/masterha/ ?
  • [root@dg55?mha4mysql-manager-0.52]#?cat?/etc/masterha/app1.cnf? ?
  • [server?default] ?
  • manager_workdir=/masterha/app1 ?
  • manager_log=/masterha/app1/manager.log ?
  • user=root?
  • password=123456?
  • ssh_user=root?
  • repl_user=r_test?
  • repl_password=123456?
  • ping_interval=1?
  • shutdown_script=""?
  • #master_ip_failover_script="/usr/local/bin/master_ip_failover"?
  • master_ip_online_change_script=""?
  • report_script=""?
  • [server1] ?
  • hostname=192.168.123.13 ?
  • master_binlog_dir="/mydata"?
  • candidate_master=1?
  • [server2] ?
  • hostname=192.168.123.14 ?
  • master_binlog_dir="/mydata"?
  • candidate_master=1?
  • 4:配置manager節點和node節點以及node節點間的ssh公鑰信任

  • [root@dg55?~]#?ssh-keygen?-t?rsa ?
  • [root@dg55?~]#?ssh-copy-id?-i?/root/.ssh/id_rsa.pub?root@192.168.123.13 ?
  • [root@dg55?~]#?ssh-copy-id?-i?/root/.ssh/id_rsa.pub?root@192.168.123.14 ?
  • ?
  • [root@dg55?~]#?ssh?192.168.123.13?"ifconfig?|grep?'inet?addr'?|head?-1" ?
  • ??????????inet?addr:192.168.123.13??Bcast:192.168.123.255??Mask:255.255.255.0 ?
  • [root@dg55?~]#?ssh?192.168.123.14?"ifconfig?|grep?'inet?addr'?|head?-1" ?
  • ??????????inet?addr:192.168.123.14??Bcast:192.168.123.255??Mask:255.255.255.0?
  • 5:測試ssh連接

  • [root@dg55?~]#?masterha_check_ssh?--conf=/etc/masterha/app1.cnf? ?
  • Wed?Jun??6?11:11:25?2012?-?[warning]?Global?configuration?file?/etc/masterha_default.cnf?not?found.?Skipping. ?
  • Wed?Jun??6?11:11:25?2012?-?[info]?Reading?application?default?configurations?from?/etc/masterha/app1.cnf.. ?
  • Wed?Jun??6?11:11:25?2012?-?[info]?Reading?server?configurations?from?/etc/masterha/app1.cnf.. ?
  • Wed?Jun??6?11:11:25?2012?-?[info]?Starting?SSH?connection?tests.. ?
  • Wed?Jun??6?11:11:25?2012?-?[debug]? ?
  • Wed?Jun??6?11:11:25?2012?-?[debug]??Connecting?via?SSH?from?root@192.168.123.13(192.168.123.13)?to?root@192.168.123.14(192.168.123.14).. ?
  • Wed?Jun??6?11:11:25?2012?-?[debug]???ok. ?
  • Wed?Jun??6?11:11:26?2012?-?[debug]? ?
  • Wed?Jun??6?11:11:25?2012?-?[debug]??Connecting?via?SSH?from?root@192.168.123.14(192.168.123.14)?to?root@192.168.123.13(192.168.123.13).. ?
  • Wed?Jun??6?11:11:26?2012?-?[debug]???ok. ?
  • Wed?Jun??6?11:11:26?2012?-?[info]?All?SSH?connection?tests?passed?successfully.?
  • 6:測試主從復制情況,默認使用root用戶連接

  • mysql>?select?user,host,password?from?mysql.user; ?
  • +--------+----------------+-------------------------------------------+ ?
  • |?user???|?host???????????|?password??????????????????????????????????| ?
  • +--------+----------------+-------------------------------------------+ ?
  • |?root???|?localhost??????|???????????????????????????????????????????|? ?
  • |?root???|?dg53.yang.com??|???????????????????????????????????????????|? ?
  • |?root???|?127.0.0.1??????|???????????????????????????????????????????|? ?
  • |?root???|?::1????????????|???????????????????????????????????????????|? ?
  • |????????|?localhost??????|???????????????????????????????????????????|? ?
  • |????????|?dg53.yang.com??|???????????????????????????????????????????|? ?
  • |?r_test?|?192.168.123.14?|?*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9?|? ?
  • +--------+----------------+-------------------------------------------+ ?
  • 7?rows?in?set?(0.08?sec) ?
  • ?
  • mysql>?use?mysql; ?
  • Database?changed ?
  • ?
  • mysql>?update?user?set?host='192.168.123.%'?where?user='r_test'; ?
  • Query?OK,?1?row?affected?(0.05?sec) ?
  • Rows?matched:?1??Changed:?1??Warnings:?0 ?
  • ?
  • mysql>?commit; ?
  • Query?OK,?0?rows?affected?(0.01?sec) ?
  • ?
  • mysql>?update?user?set?host='192.168.123.%'?where?host='localhost'?and?user='root'?and?password=''; ?
  • Query?OK,?0?rows?affected?(0.00?sec) ?
  • Rows?matched:?1??Changed:?1??Warnings:?0 ?
  • ?
  • mysql>?update?user?set?password=PASSWORD('123456')?where?user='root'?and?host='192.168.123.%'; ?
  • Query?OK,?0?rows?affected?(0.00?sec) ?
  • Rows?matched:?1??Changed:?0??Warnings:?0 ?
  • ?
  • mysql>?flush?privileges; ?
  • Query?OK,?0?rows?affected?(0.02?sec) ?
  • ?
  • [root@dg53?~]#?whereis?mysqlbinlog ?
  • mysqlbinlog:?/usr/bin/mysqlbinlog ?
  • ?
  • [root@dg53?~]#?mv?/usr/bin/mysql*?/tmp ?
  • [root@dg54?~]#?mv?/usr/bin/mysql*?/tmp ?
  • [root@dg53?~]#?ln?-s?/usr/local/mysql5.5.25/bin/*?/usr/local/bin/ ?
  • [root@dg54?~]#?ln?-s?/usr/local/mysql5.5.25/bin/*?/usr/local/bin/ ?
  • ?
  • [root@dg55?~]#?masterha_check_repl?--conf=/etc/masterha/app1.cnf? ?
  • Wed?Jun??6?12:39:03?2012?-?[warning]?Global?configuration?file?/etc/masterha_default.cnf?not?found.?Skipping. ?
  • Wed?Jun??6?12:39:03?2012?-?[info]?Reading?application?default?configurations?from?/etc/masterha/app1.cnf.. ?
  • Wed?Jun??6?12:39:03?2012?-?[info]?Reading?server?configurations?from?/etc/masterha/app1.cnf.. ?
  • Wed?Jun??6?12:39:03?2012?-?[info]?MHA::MasterMonitor?version?0.52. ?
  • Wed?Jun??6?12:39:03?2012?-?[info]?Dead?Servers: ?
  • Wed?Jun??6?12:39:03?2012?-?[info]?Alive?Servers: ?
  • Wed?Jun??6?12:39:03?2012?-?[info]???192.168.123.13(192.168.123.13:3306) ?
  • Wed?Jun??6?12:39:03?2012?-?[info]???192.168.123.14(192.168.123.14:3306) ?
  • Wed?Jun??6?12:39:03?2012?-?[info]?Alive?Slaves: ?
  • Wed?Jun??6?12:39:03?2012?-?[info]???192.168.123.14(192.168.123.14:3306)??Version=5.5.25-log?(oldest?major?version?between?slaves)?log-bin:enabled ?
  • Wed?Jun??6?12:39:03?2012?-?[info]?????Replicating?from?192.168.123.13(192.168.123.13:3306) ?
  • Wed?Jun??6?12:39:03?2012?-?[info]?????Primary?candidate?for?the?new?Master?(candidate_master?is?set) ?
  • Wed?Jun??6?12:39:03?2012?-?[info]?Current?Alive?Master:?192.168.123.13(192.168.123.13:3306) ?
  • Wed?Jun??6?12:39:03?2012?-?[info]?Checking?slave?configurations.. ?
  • Wed?Jun??6?12:39:03?2012?-?[warning]??read_only=1?is?not?set?on?slave?192.168.123.14(192.168.123.14:3306). ?
  • Wed?Jun??6?12:39:03?2012?-?[warning]??relay_log_purge=0?is?not?set?on?slave?192.168.123.14(192.168.123.14:3306). ?
  • Wed?Jun??6?12:39:03?2012?-?[info]?Checking?replication?filtering?settings.. ?
  • Wed?Jun??6?12:39:03?2012?-?[info]??binlog_do_db=?bbs,test,?binlog_ignore_db=?mysql?
  • Wed?Jun??6?12:39:03?2012?-?[info]??Replication?filtering?check?ok. ?
  • Wed?Jun??6?12:39:03?2012?-?[info]?Starting?SSH?connection?tests.. ?
  • Wed?Jun??6?12:39:05?2012?-?[info]?All?SSH?connection?tests?passed?successfully. ?
  • Wed?Jun??6?12:39:05?2012?-?[info]?Checking?MHA?Node?version.. ?
  • Wed?Jun??6?12:39:05?2012?-?[info]??Version?check?ok. ?
  • Wed?Jun??6?12:39:05?2012?-?[info]?Checking?SSH?publickey?authentication?and?checking?recovery?script?configurations?on?the?current?master.. ?
  • Wed?Jun??6?12:39:05?2012?-?[info]???Executing?command:?save_binary_logs?--command=test?--start_file=mysql-bin.000011?--start_pos=4?--binlog_dir=/mydata?--output_file=/var/tmp/save_binary_logs_test?--manager_version=0.52? ?
  • Wed?Jun??6?12:39:05?2012?-?[info]???Connecting?to?root@192.168.123.13(192.168.123.13)..? ?
  • ??Creating?/var/tmp?if?not?exists..????ok. ?
  • ??Checking?output?directory?is?accessible?or?not.. ?
  • ???ok. ?
  • ??Binlog?found?at?/mydata,?up?to?mysql-bin.000011 ?
  • Wed?Jun??6?12:39:06?2012?-?[info]?Master?setting?check?done. ?
  • Wed?Jun??6?12:39:06?2012?-?[info]?Checking?SSH?publickey?authentication?and?checking?recovery?script?configurations?on?all?alive?slave?servers.. ?
  • Wed?Jun??6?12:39:06?2012?-?[info]???Executing?command?:?apply_diff_relay_logs?--command=test?--slave_user=root?--slave_host=192.168.123.14?--slave_ip=192.168.123.14?--slave_port=3306?--workdir=/var/tmp?--target_version=5.5.25-log?--manager_version=0.52?--relay_log_info=/mydata/relay-log.info??--slave_pass=xxx?
  • Wed?Jun??6?12:39:06?2012?-?[info]???Connecting?to?root@192.168.123.14(192.168.123.14)..? ?
  • ??Checking?slave?recovery?environment?settings.. ?
  • ????Opening?/mydata/relay-log.info?...?ok. ?
  • ????Relay?log?found?at?/mydata,?up?to?dg54-relay-bin.000019 ?
  • ????Temporary?relay?log?file?is?/mydata/dg54-relay-bin.000019 ?
  • ????Testing?mysql?connection?and?privileges..?done. ?
  • ????Testing?mysqlbinlog?output..?done. ?
  • ????Cleaning?up?test?file(s)..?done. ?
  • Wed?Jun??6?12:39:06?2012?-?[info]?Slaves?settings?check?done. ?
  • Wed?Jun??6?12:39:06?2012?-?[info]? ?
  • 192.168.123.13?(current?master) ?
  • ?+--192.168.123.14 ?
  • ?
  • Wed?Jun??6?12:39:06?2012?-?[info]?Checking?replication?health?on?192.168.123.14.. ?
  • Wed?Jun??6?12:39:06?2012?-?[info]??ok. ?
  • Wed?Jun??6?12:39:06?2012?-?[warning]?master_ip_failover_script?is?not?defined. ?
  • Wed?Jun??6?12:39:06?2012?-?[warning]?shutdown_script?is?not?defined. ?
  • Wed?Jun??6?12:39:06?2012?-?[info]?Got?exit?code?0?(Not?master?dead). ?
  • ?
  • MySQL?Replication?Health?is?OK.?
  • 7:啟動管理節點進程

  • [root@dg55?~]#?nohup?masterha_manager?--conf=/etc/masterha/app1.cnf?>?/tmp/mha_manager.log??<?/dev/null?2>&1?& ?
  • [1]?25516 ?
  • [root@dg55?~]#?masterha_check_status?--conf=/etc/masterha/app1.cnf? ?
  • app1?(pid:25516)?is?running(0:PING_OK),?master:192.168.123.13?
  • 三:測試failover過程
    1:當前主庫為192.168.123.13,關閉主庫

  • mysql>?show?slave?hosts; ?
  • +-----------+------+------+-----------+ ?
  • |?Server_id?|?Host?|?Port?|?Master_id?| ?
  • +-----------+------+------+-----------+ ?
  • |?????????2?|??????|?3306?|?????????1?| ?
  • +-----------+------+------+-----------+ ?
  • 1?row?in?set?(0.00?sec) ?
  • ?
  • [root@dg53?~]#?service?mysqld?stop ?
  • Shutting?down?MySQL...[??OK??]?
  • 2:在管理節點上觀察日志輸出

    [root@dg55 ~]# tail -f /masterha/app1/manager.log
    Wed Jun? 6 14:50:48 2012 - [info]
    192.168.123.13 (current master)
    ?+--192.168.123.14

    Wed Jun? 6 14:50:48 2012 - [warning] master_ip_failover_script is not defined.
    Wed Jun? 6 14:50:48 2012 - [warning] shutdown_script is not defined.
    Wed Jun? 6 14:50:48 2012 - [info] Set master ping interval 1 seconds.
    Wed Jun? 6 14:50:48 2012 - [warning] secondary_check_script is not defined. It is highly recommended setting it to check master reachability from two or more routes.
    Wed Jun? 6 14:50:48 2012 - [info] Starting ping health check on 192.168.123.13(192.168.123.13:3306)..
    Wed Jun? 6 14:50:48 2012 - [info] Ping succeeded, sleeping until it doesn't respond..

    Wed Jun? 6 14:51:32 2012 - [warning] Got error on MySQL ping: 2006 (MySQL server has gone away)
    Wed Jun? 6 14:51:32 2012 - [info] HealthCheck: SSH to 192.168.123.13 is reachable.
    Wed Jun? 6 14:51:33 2012 - [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL server at 'reading initial communication packet', system error: 111)
    Wed Jun? 6 14:51:33 2012 - [warning] Connection failed 1 time(s)..
    Wed Jun? 6 14:51:34 2012 - [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL server at 'reading initial communication packet', system error: 111)
    Wed Jun? 6 14:51:34 2012 - [warning] Connection failed 2 time(s)..
    Wed Jun? 6 14:51:35 2012 - [warning] Got error on MySQL connect: 2013 (Lost connection to MySQL server at 'reading initial communication packet', system error: 111)
    Wed Jun? 6 14:51:35 2012 - [warning] Connection failed 3 time(s)..
    Wed Jun? 6 14:51:35 2012 - [warning] Master is not reachable from health checker!
    Wed Jun? 6 14:51:35 2012 - [warning] Master 192.168.123.13(192.168.123.13:3306) is not reachable!
    Wed Jun? 6 14:51:35 2012 - [warning] SSH is reachable.
    Wed Jun? 6 14:51:35 2012 - [info] Connecting to a master server failed. Reading configuration file /etc/masterha_default.cnf and /etc/masterha/app1.cnf again, and trying to connect to all servers to check server status..
    Wed Jun? 6 14:51:35 2012 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
    Wed Jun? 6 14:51:35 2012 - [info] Reading application default configurations from /etc/masterha/app1.cnf..
    Wed Jun? 6 14:51:35 2012 - [info] Reading server configurations from /etc/masterha/app1.cnf..
    Wed Jun? 6 14:51:35 2012 - [info] Dead Servers:
    Wed Jun? 6 14:51:35 2012 - [info]?? 192.168.123.13(192.168.123.13:3306)
    Wed Jun? 6 14:51:35 2012 - [info] Alive Servers:
    Wed Jun? 6 14:51:35 2012 - [info]?? 192.168.123.14(192.168.123.14:3306)
    Wed Jun? 6 14:51:35 2012 - [info] Alive Slaves:
    Wed Jun? 6 14:51:35 2012 - [info]?? 192.168.123.14(192.168.123.14:3306)? Version=5.5.25-log (oldest major version between slaves) log-bin:enabled
    Wed Jun? 6 14:51:35 2012 - [info]???? Replicating from 192.168.123.13(192.168.123.13:3306)
    Wed Jun? 6 14:51:35 2012 - [info]???? Primary candidate for the new Master (candidate_master is set)
    Wed Jun? 6 14:51:35 2012 - [info] Checking slave configurations..
    Wed Jun? 6 14:51:35 2012 - [warning]? read_only=1 is not set on slave 192.168.123.14(192.168.123.14:3306).
    Wed Jun? 6 14:51:35 2012 - [warning]? relay_log_purge=0 is not set on slave 192.168.123.14(192.168.123.14:3306).
    Wed Jun? 6 14:51:35 2012 - [info] Checking replication filtering settings..
    Wed Jun? 6 14:51:35 2012 - [info]? Replication filtering check ok.
    Wed Jun? 6 14:51:35 2012 - [info] Master is down!
    Wed Jun? 6 14:51:35 2012 - [info] Terminating monitoring script.
    Wed Jun? 6 14:51:35 2012 - [info] Got exit code 20 (Master dead).
    Wed Jun? 6 14:51:35 2012 - [info] MHA::MasterFailover version 0.52.
    Wed Jun? 6 14:51:35 2012 - [info] Starting master failover.
    Wed Jun? 6 14:51:35 2012 - [info]
    Wed Jun? 6 14:51:35 2012 - [info] * Phase 1: Configuration Check Phase..
    Wed Jun? 6 14:51:35 2012 - [info]
    Wed Jun? 6 14:51:35 2012 - [info] Dead Servers:
    Wed Jun? 6 14:51:35 2012 - [info]?? 192.168.123.13(192.168.123.13:3306)
    Wed Jun? 6 14:51:35 2012 - [info] Checking master reachability via mysql(double check)..
    Wed Jun? 6 14:51:35 2012 - [info]? ok.
    Wed Jun? 6 14:51:35 2012 - [info] Alive Servers:
    Wed Jun? 6 14:51:35 2012 - [info]?? 192.168.123.14(192.168.123.14:3306)
    Wed Jun? 6 14:51:35 2012 - [info] Alive Slaves:
    Wed Jun? 6 14:51:35 2012 - [info]?? 192.168.123.14(192.168.123.14:3306)? Version=5.5.25-log (oldest major version between slaves) log-bin:enabled
    Wed Jun? 6 14:51:35 2012 - [info]???? Replicating from 192.168.123.13(192.168.123.13:3306)
    Wed Jun? 6 14:51:35 2012 - [info]???? Primary candidate for the new Master (candidate_master is set)
    Wed Jun? 6 14:51:35 2012 - [info] ** Phase 1: Configuration Check Phase completed.
    Wed Jun? 6 14:51:35 2012 - [info]
    Wed Jun? 6 14:51:35 2012 - [info] * Phase 2: Dead Master Shutdown Phase..
    Wed Jun? 6 14:51:35 2012 - [info]
    Wed Jun? 6 14:51:35 2012 - [info] Forcing shutdown so that applications never connect to the current master..
    Wed Jun? 6 14:51:35 2012 - [warning] master_ip_failover_script is not set. Skipping invalidating dead master ip address.
    Wed Jun? 6 14:51:35 2012 - [warning] shutdown_script is not set. Skipping explicit shutting down of the dead master.
    Wed Jun? 6 14:51:35 2012 - [info] * Phase 2: Dead Master Shutdown Phase completed.
    Wed Jun? 6 14:51:35 2012 - [info]
    Wed Jun? 6 14:51:35 2012 - [info] * Phase 3: Master Recovery Phase..
    Wed Jun? 6 14:51:35 2012 - [info]
    Wed Jun? 6 14:51:35 2012 - [info] * Phase 3.1: Getting Latest Slaves Phase..
    Wed Jun? 6 14:51:35 2012 - [info]
    Wed Jun? 6 14:51:35 2012 - [info] The latest binary log file/position on all slaves is mysql-bin.000021:107
    Wed Jun? 6 14:51:35 2012 - [info] Latest slaves (Slaves that received relay log files to the latest):
    Wed Jun? 6 14:51:35 2012 - [info]?? 192.168.123.14(192.168.123.14:3306)? Version=5.5.25-log (oldest major version between slaves) log-bin:enabled
    Wed Jun? 6 14:51:35 2012 - [info]???? Replicating from 192.168.123.13(192.168.123.13:3306)
    Wed Jun? 6 14:51:35 2012 - [info]???? Primary candidate for the new Master (candidate_master is set)
    Wed Jun? 6 14:51:35 2012 - [info] The oldest binary log file/position on all slaves is mysql-bin.000021:107
    Wed Jun? 6 14:51:35 2012 - [info] Oldest slaves:
    Wed Jun? 6 14:51:35 2012 - [info]?? 192.168.123.14(192.168.123.14:3306)? Version=5.5.25-log (oldest major version between slaves) log-bin:enabled
    Wed Jun? 6 14:51:35 2012 - [info]???? Replicating from 192.168.123.13(192.168.123.13:3306)
    Wed Jun? 6 14:51:35 2012 - [info]???? Primary candidate for the new Master (candidate_master is set)
    Wed Jun? 6 14:51:35 2012 - [info]
    Wed Jun? 6 14:51:35 2012 - [info] * Phase 3.2: Saving Dead Master's Binlog Phase..
    Wed Jun? 6 14:51:35 2012 - [info]
    Wed Jun? 6 14:51:35 2012 - [info] Fetching dead master's binary logs..
    Wed Jun? 6 14:51:35 2012 - [info] Executing command on the dead master 192.168.123.13(192.168.123.13:3306): save_binary_logs --command=save --start_file=mysql-bin.000021? --start_pos=107 --binlog_dir=/mydata --output_file=/var/tmp/saved_master_binlog_from_192.168.123.13_3306_20120606145135.binlog --handle_raw_binlog=1 --disable_log_bin=0 --manager_version=0.52
    ? Creating /var/tmp if not exists..??? ok.
    ?Concat binary/relay logs from mysql-bin.000021 pos 107 to mysql-bin.000021 EOF into /var/tmp/saved_master_binlog_from_192.168.123.13_3306_20120606145135.binlog ..
    ? Dumping binlog format description event, from position 0 to 107.. ok.
    ? Dumping effective binlog data from /mydata/mysql-bin.000021 position 107 to tail(126).. ok.
    ?Concat succeeded.
    Wed Jun? 6 14:51:36 2012 - [info] scp from root@192.168.123.13:/var/tmp/saved_master_binlog_from_192.168.123.13_3306_20120606145135.binlog to local:/masterha/app1/saved_master_binlog_from_192.168.123.13_3306_20120606145135.binlog succeeded.
    Wed Jun? 6 14:51:36 2012 - [info] HealthCheck: SSH to 192.168.123.14 is reachable.
    Wed Jun? 6 14:51:37 2012 - [info]
    Wed Jun? 6 14:51:37 2012 - [info] * Phase 3.3: Determining New Master Phase..
    Wed Jun? 6 14:51:37 2012 - [info]
    Wed Jun? 6 14:51:37 2012 - [info] Finding the latest slave that has all relay logs for recovering other slaves..
    Wed Jun? 6 14:51:37 2012 - [info] All slaves received relay logs to the same position. No need to resync each other.
    Wed Jun? 6 14:51:37 2012 - [info] Searching new master from slaves..
    Wed Jun? 6 14:51:37 2012 - [info]? Candidate masters from the configuration file:
    Wed Jun? 6 14:51:37 2012 - [info]?? 192.168.123.14(192.168.123.14:3306)? Version=5.5.25-log (oldest major version between slaves) log-bin:enabled
    Wed Jun? 6 14:51:37 2012 - [info]???? Replicating from 192.168.123.13(192.168.123.13:3306)
    Wed Jun? 6 14:51:37 2012 - [info]???? Primary candidate for the new Master (candidate_master is set)
    Wed Jun? 6 14:51:37 2012 - [info]? Non-candidate masters:
    Wed Jun? 6 14:51:37 2012 - [info]? Searching from candidate_master slaves which have received the latest relay log events..
    Wed Jun? 6 14:51:37 2012 - [info] New master is 192.168.123.14(192.168.123.14:3306)
    Wed Jun? 6 14:51:37 2012 - [info] Starting master failover..
    Wed Jun? 6 14:51:37 2012 - [info]
    From:
    192.168.123.13 (current master)
    ?+--192.168.123.14

    To:
    192.168.123.14 (new master)
    Wed Jun? 6 14:51:37 2012 - [info]
    Wed Jun? 6 14:51:37 2012 - [info] * Phase 3.3: New Master Diff Log Generation Phase..
    Wed Jun? 6 14:51:37 2012 - [info]
    Wed Jun? 6 14:51:37 2012 - [info]? This server has all relay logs. No need to generate diff files from the latest slave.
    Wed Jun? 6 14:51:37 2012 - [info] Sending binlog..
    Wed Jun? 6 14:51:37 2012 - [info] scp from local:/masterha/app1/saved_master_binlog_from_192.168.123.13_3306_20120606145135.binlog to root@192.168.123.14:/var/tmp/saved_master_binlog_from_192.168.123.13_3306_20120606145135.binlog succeeded.
    Wed Jun? 6 14:51:37 2012 - [info]
    Wed Jun? 6 14:51:37 2012 - [info] * Phase 3.4: Master Log Apply Phase..
    Wed Jun? 6 14:51:37 2012 - [info]
    Wed Jun? 6 14:51:37 2012 - [info] *NOTICE: If any error happens from this phase, manual recovery is needed.
    Wed Jun? 6 14:51:37 2012 - [info] Starting recovery on 192.168.123.14(192.168.123.14:3306)..
    Wed Jun? 6 14:51:37 2012 - [info]? Generating diffs succeeded.
    Wed Jun? 6 14:51:37 2012 - [info] Waiting until all relay logs are applied.
    Wed Jun? 6 14:51:37 2012 - [info]? done.
    Wed Jun? 6 14:51:37 2012 - [info] Getting slave status..
    Wed Jun? 6 14:51:37 2012 - [info] This slave(192.168.123.14)'s Exec_Master_Log_Pos equals to Read_Master_Log_Pos(mysql-bin.000021:107). No need to recover from Exec_Master_Log_Pos.
    Wed Jun? 6 14:51:37 2012 - [info] Connecting to the target slave host 192.168.123.14, running recover script..
    Wed Jun? 6 14:51:37 2012 - [info] Executing command: apply_diff_relay_logs --command=apply --slave_user=root --slave_host=192.168.123.14 --slave_ip=192.168.123.14? --slave_port=3306 --apply_files=/var/tmp/saved_master_binlog_from_192.168.123.13_3306_20120606145135.binlog --workdir=/var/tmp --target_version=5.5.25-log --timestamp=20120606145135 --handle_raw_binlog=1 --disable_log_bin=0 --manager_version=0.52 --slave_pass=xxx
    Wed Jun? 6 14:51:37 2012 - [info]
    Applying differential binary/relay log files /var/tmp/saved_master_binlog_from_192.168.123.13_3306_20120606145135.binlog on 192.168.123.14:3306. This may take long time...
    Applying log files succeeded.
    Wed Jun? 6 14:51:37 2012 - [info]? All relay logs were successfully applied.
    Wed Jun? 6 14:51:37 2012 - [info] Getting new master's binlog name and position..
    Wed Jun? 6 14:51:37 2012 - [info]? mysql-bin.000023:107
    Wed Jun? 6 14:51:37 2012 - [info]? All other slaves should start replication from here. Statement should be: CHANGE MASTER TO MASTER_HOST='192.168.123.14', MASTER_PORT=3306, MASTER_LOG_FILE='mysql-bin.000023', MASTER_LOG_POS=107, MASTER_USER='r_test', MASTER_PASSWORD='xxx';
    Wed Jun? 6 14:51:37 2012 - [warning] master_ip_failover_script is not set. Skipping taking over new master ip address.
    Wed Jun? 6 14:51:37 2012 - [info] ** Finished master recovery successfully.
    Wed Jun? 6 14:51:37 2012 - [info] * Phase 3: Master Recovery Phase completed.
    Wed Jun? 6 14:51:37 2012 - [info]
    Wed Jun? 6 14:51:37 2012 - [info] * Phase 4: Slaves Recovery Phase..
    Wed Jun? 6 14:51:37 2012 - [info]
    Wed Jun? 6 14:51:37 2012 - [info] * Phase 4.1: Starting Parallel Slave Diff Log Generation Phase..
    Wed Jun? 6 14:51:37 2012 - [info]
    Wed Jun? 6 14:51:37 2012 - [info] Generating relay diff files from the latest slave succeeded.
    Wed Jun? 6 14:51:37 2012 - [info]
    Wed Jun? 6 14:51:37 2012 - [info] * Phase 4.2: Starting Parallel Slave Log Apply Phase..
    Wed Jun? 6 14:51:37 2012 - [info]
    Wed Jun? 6 14:51:37 2012 - [info] All new slave servers recovered successfully.
    Wed Jun? 6 14:51:37 2012 - [info]
    Wed Jun? 6 14:51:37 2012 - [info] * Phase 5: New master cleanup phease..
    Wed Jun? 6 14:51:37 2012 - [info]
    Wed Jun? 6 14:51:37 2012 - [info] Resetting slave info on the new master..
    Wed Jun? 6 14:51:37 2012 - [info] Master failover to 192.168.123.14(192.168.123.14:3306) completed successfully.
    Wed Jun? 6 14:51:37 2012 - [info]

    ----- Failover Report -----

    app1: MySQL Master failover 192.168.123.13 to 192.168.123.14 succeeded

    Master 192.168.123.13 is down!

    Check MHA Manager logs at dg55.yang.com:/masterha/app1/manager.log for details.

    Started automated(non-interactive) failover.
    The latest slave 192.168.123.14(192.168.123.14:3306) has all relay logs for recovery.
    Selected 192.168.123.14 as a new master.
    192.168.123.14: OK: Applying all logs succeeded.
    Generating relay diff files from the latest slave succeeded.
    192.168.123.14: Resetting slave info succeeded.
    Master failover to 192.168.123.14(192.168.123.14:3306) completed successfully.

    3:在原從庫192.168.123.14上查看結果

  • mysql>?show?master?status; ?
  • +------------------+----------+--------------+------------------+ ?
  • |?File?????????????|?Position?|?Binlog_Do_DB?|?Binlog_Ignore_DB?| ?
  • +------------------+----------+--------------+------------------+ ?
  • |?mysql-bin.000023?|??????107?|?bbs,test?????|?mysql????????????| ?
  • +------------------+----------+--------------+------------------+ ?
  • 1?row?in?set?(0.00?sec) ?
  • ?
  • mysql>?show?slave?status\G; ?
  • ***************************?1.?row?*************************** ?
  • ???????????????Slave_IO_State:? ?
  • ??????????????????Master_Host:?192.168.123.13 ?
  • ??????????????????Master_User:?r_test ?
  • ??????????????????Master_Port:?3306 ?
  • ????????????????Connect_Retry:?60 ?
  • ??????????????Master_Log_File:? ?
  • ??????????Read_Master_Log_Pos:?4 ?
  • ???????????????Relay_Log_File:?dg54-relay-bin.000001 ?
  • ????????????????Relay_Log_Pos:?4 ?
  • ????????Relay_Master_Log_File:? ?
  • ?????????????Slave_IO_Running:?No ?
  • ????????????Slave_SQL_Running:?No ?
  • ??????????????Replicate_Do_DB:? ?
  • ??????????Replicate_Ignore_DB:? ?
  • ???????????Replicate_Do_Table:? ?
  • ???????Replicate_Ignore_Table:? ?
  • ??????Replicate_Wild_Do_Table:? ?
  • ??Replicate_Wild_Ignore_Table:? ?
  • ???????????????????Last_Errno:?0 ?
  • ???????????????????Last_Error:? ?
  • ?????????????????Skip_Counter:?0 ?
  • ??????????Exec_Master_Log_Pos:?0 ?
  • ??????????????Relay_Log_Space:?126 ?
  • ??????????????Until_Condition:?None ?
  • ???????????????Until_Log_File:? ?
  • ????????????????Until_Log_Pos:?0 ?
  • ???????????Master_SSL_Allowed:?No ?
  • ???????????Master_SSL_CA_File:? ?
  • ???????????Master_SSL_CA_Path:? ?
  • ??????????????Master_SSL_Cert:? ?
  • ????????????Master_SSL_Cipher:? ?
  • ???????????????Master_SSL_Key:? ?
  • ????????Seconds_Behind_Master:?NULL ?
  • Master_SSL_Verify_Server_Cert:?No ?
  • ????????????????Last_IO_Errno:?0 ?
  • ????????????????Last_IO_Error:? ?
  • ???????????????Last_SQL_Errno:?0 ?
  • ???????????????Last_SQL_Error:? ?
  • ??Replicate_Ignore_Server_Ids:? ?
  • ?????????????Master_Server_Id:?1 ?
  • 1?row?in?set?(0.00?sec) ?
  • ?
  • ERROR:? ?
  • No?query?specified?
  • 備注:本文只簡單記錄了mha的環境部署過程,更多高級的內容,例如配合keepalive使用VIP,讓客戶端連接數據庫透明化以及手動failover和master_ip_failover_script腳本,半同步復制等功能后續將繼續研究!

    參考文章,感謝作者分享
    http://who0168.blog.51cto.com/253401/699030
    http://huoding.com/2011/12/18/139
    http://www.vmcd.org/2012/04/mysql-high-availability-mha/

    創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

    總結

    以上是生活随笔為你收集整理的Mysql5.5部署MHA的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

    主站蜘蛛池模板: 自拍偷拍三级 | 欧美综合图区 | 亚洲精品中文字幕成人片 | 久久久久久久久久91 | 国产成人在线观看 | 精品国自产拍在线观看 | 乱视频在线观看 | 肉嫁高柳家 高清 | 特级西西444www高清大胆免费看 | 欧美精品一二三四区 | 婷婷激情成人 | 日韩人妻精品在线 | 国产a一区 | 综合热久久 | 午夜色网站 | 日韩在线中文 | 国模无码一区二区三区 | 精品一区在线视频 | a级免费毛片 | 国内性视频 | 天天插天天爽 | 欧美日韩中文字幕 | 露脸丨91丨九色露脸 | 性欧美一级 | 伊人黄 | 污的视频在线观看 | 丰满秘书被猛烈进入高清播放在 | 国产在线观看一区 | 欧美一区二区三区激情视频 | 久久大综合 | 欧美资源在线 | ts人妖在线观看 | 亚洲狠狠婷婷综合久久久久图片 | 91久久久久 | 色综合自拍| 一区二区在线视频免费观看 | 日韩精品一区二区三区四区 | 成品短视频泡芙 | 大陆明星乱淫(高h)小说 | 久草福利免费 | 成人av播放| 欧美a大片| 精品中文一区二区三区 | 熟女少妇内射日韩亚洲 | 日韩欧美福利视频 | 爱的色放在线 | jizz欧美性20| 人人爽夜夜爽 | 丰满岳妇乱一区二区三区 | 日本欧美韩国国产精品 | 亚洲激情小视频 | 中文字幕第九页 | 亚洲激情在线观看视频 | 最近中文字幕mv免费高清在线 | 不卡视频一区 | 最近最经典中文mv字幕 | 国产精品久久在线 | 高柳家在线观看 | 亚洲欧美日韩精品永久在线 | 六月婷婷色 | 色诱视频在线观看 | 日本一级片在线观看 | 1区2区视频 | 在线播放精品视频 | 国产免费一区二区三区在线观看 | 青青草成人av | 亚洲一区亚洲二区 | 欧美一区二区在线视频观看 | 黄色工厂这里只有精品 | 黄色片视频免费在线观看 | 亚洲国产精品久久久久爰性色 | 欧美日韩精品中文字幕 | 亚洲乱亚洲 | 老地方在线观看免费动漫 | 成人免费一区二区三区 | 极品三级| 中国丰满老妇xxxxx交性 | 噼里啪啦免费观看 | 自拍一区在线 | 亚洲三级电影网站 | 日日综合网 | 牛牛av在线 | www久久久 | 日韩中文字幕av在线 | 久草精品视频在线观看 | 久久人人爽人人爽人人片av免费 | 久草老司机 | 午夜免费视频观看 | 国产av 一区二区三区 | 欧美精品导航 | 久操伊人网 | av在线影片| 香港日本韩国三级网站 | 小草av| 四季av一区二区凹凸精品 | 久久av一区二区三 | www.欧美精品 | 久久三级| 黄色网在线看 |