91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

MHA的安裝搭建和測試

發布時間:2021-09-17 15:51:04 來源:億速云 閱讀:163 作者:chen 欄目:MySQL數據庫

這篇文章主要講解了“MHA的安裝搭建和測試”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“MHA的安裝搭建和測試”吧!

環境:

192.168.56.221     MHA1

192.168.56.222     MHA2

192.168.56.223     MHA3

192.168.56.224     MHA4

#221為master 222位slave 223為slave 224為管理節點

##1 安裝MHA軟件包

https://code.google.com/p/mysql-master-ha/

https://downloads.mariadb.com/MHA/

yum install -y perl-DBD-MySQL

yum install -y perl cpan

yum install -y perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager

常用rpm搜索網站:

http://rpm.pbone.net/  

perl-Log-Dispatch

perl-Parallel-ForkManager

[root@MHA1 ~]# rpm -ivh perl-Mail-Sender-0.8.16-1.el6.rf.noarch.rpm

warning: perl-Mail-Sender-0.8.16-1.el6.rf.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY

Preparing...                ########################################### [100%]

   1:perl-Mail-Sender       ########################################### [100%]

[root@MHA1 ~]# rpm -ivh perl-Mail-Sendmail-0.79_16-4.2.noarch.rpm

warning: perl-Mail-Sendmail-0.79_16-4.2.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 04b8b50a: NOKEY

Preparing...                ########################################### [100%]

   1:perl-Mail-Sendmail     ########################################### [100%]

[root@MHA1 ~]# yum localinstall perl-Log-Dispatch-2.27-1.el6.noarch.rpm

[root@MHA1 ~]# yum localinstall perl-Parallel-ForkManager-0.7.5-2.2.el6.rf.noarch.rpm

[root@MHA1 ~]# yum localinstall mha4mysql-node-0.54-0.el6.noarch.rpm   #所有節點安裝

[root@MHA1 ~]# yum localinstall mha4mysql-manager-0.55-0.el6.noarch.rpm  #管理節點安裝

##2 主從同步配置:

#主服務器

mysql> show variables like 'log_bin';

+---------------+-------+

| Variable_name | Value |

+---------------+-------+

| log_bin       | ON    |

+---------------+-------+

1 row in set (0.53 sec)

mysql> grant replication slave on *.* to 'rep'@'%' identified by '123456';   #建議所有mysql服務器配置,以防主從切換

Query OK, 0 rows affected, 1 warning (0.17 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

#從服務器

vi my.cnf

[mysqld]

#slave

relay_log=/usr/local/mysql/logs/relay-log.log

master-info-repository=TABLE

relay-log-info-repository=TABLE

sync_master_info = 1    

sync_relay_log = 1   

sync_relay_log_info = 1

mysql> change master to master_host='192.168.56.221', master_port=3306, master_user='rep', master_password='123456', master_log_file='ray-bin.000003', master_log_pos=740;

Query OK, 0 rows affected, 2 warnings (0.05 sec)

mysql> start slave;

Query OK, 0 rows affected (0.03 sec)

mysql> show slave status\G

*************************** 1. row ***************************

               Slave_IO_State: Waiting for master to send event

                  Master_Host: 192.168.56.221

                  Master_User: rep

                  Master_Port: 3306

                Connect_Retry: 60

              Master_Log_File: ray-bin.000003

          Read_Master_Log_Pos: 740

               Relay_Log_File: relay-log.000003

                Relay_Log_Pos: 318

        Relay_Master_Log_File: ray-bin.000003

             Slave_IO_Running: Yes

            Slave_SQL_Running: Yes

              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: 740

              Relay_Log_Space: 519

              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: 0

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: 21

                  Master_UUID: 262ff2d5-2264-11e7-a823-080027a847bd

             Master_Info_File: mysql.slave_master_info

                    SQL_Delay: 0

          SQL_Remaining_Delay: NULL

      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates

           Master_Retry_Count: 86400

                  Master_Bind:

      Last_IO_Error_Timestamp:

     Last_SQL_Error_Timestamp:

               Master_SSL_Crl:

           Master_SSL_Crlpath:

           Retrieved_Gtid_Set:

            Executed_Gtid_Set:

                Auto_Position: 0

         Replicate_Rewrite_DB:

                 Channel_Name:

           Master_TLS_Version:

1 row in set (0.00 sec)

mysql> use mysql

Database changed

mysql> alter table slave_master_info engine=innodb;

Query OK, 0 rows affected (0.23 sec)

Records: 0  Duplicates: 0  Warnings: 0

mysql> alter table slave_relay_log_info engine=innodb;

Query OK, 0 rows affected (0.08 sec)

Records: 0  Duplicates: 0  Warnings: 0

mysql> alter table slave_worker_info engine=innodb;

Query OK, 0 rows affected (0.08 sec)

Records: 0  Duplicates: 0  Warnings: 0

##3 配置互信

[root@MHA1 ~]# ssh-keygen -t rsa  #所有節點

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

e2:1c:6a:a3:ae:e5:38:0e:e7:cd:21:50:a5:14:d2:3b root@MHA1

The key's randomart image is:

+--[ RSA 2048]----+

|..o..            |

| o.o             |

|  o.             |

| .E              |

|.  .  o S        |

| .   + o         |

|. + = o          |

|o* * o           |

|+== o            |

+-----------------+

[root@MHA1 ~]# ssh slave1 cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

[root@MHA1 ~]# ssh slave2 cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

[root@MHA1 ~]# ssh master cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

[root@MHA1 ~]# ssh MHAManager cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

[root@MHA1 ~]# scp /root/.ssh/authorized_keys slave1:/root/.ssh/authorized_keys

[root@MHA1 ~]# scp /root/.ssh/authorized_keys slave2:/root/.ssh/authorized_keys

[root@MHA1 ~]# scp /root/.ssh/authorized_keys MHAManager:/root/.ssh/authorized_keys

[root@MHA1 ~]# ssh slave1 date;ssh slave2 date;ssh master date;ssh MHAManager date;

Fri Apr 28 10:46:10 CST 2017

Fri Apr 28 10:46:14 CST 2017

Fri Apr 28 10:46:12 CST 2017

Fri Apr 28 10:46:13 CST 2017

[root@MHA1 ~]#

[root@MHA4 ~]# ssh slave1 date;ssh slave2 date;ssh master date;ssh MHAManager date;

Fri Apr 28 10:46:10 CST 2017

Fri Apr 28 10:46:14 CST 2017

Fri Apr 28 10:46:12 CST 2017

Fri Apr 28 10:46:13 CST 2017

[root@MHA4 ~]#

##4 slave服務器上設置只讀權限,并關閉自動清除執行完畢的中繼日志(relay log)

[mysqld]

read_only = 1

relay_log_purge = 0

mysql -uroot -p123456 -e "set global read_only=on;"

注意:

    設置只讀是防止人在slave服務器上誤寫入,保證主從數據一致

    關閉自動清除執行完畢的中級日志是:假如一臺從庫沒有接受完主庫的binlog,那么可以通過MHA把最新的slave上的中級日志發送到最老的slave上,識別差異中級日志并補齊數據

    如果想數據庫自動刪除執行完畢的日志,可以通過crontab實現,例如想要每天5點刪除中繼日志

    0 5 * * * /usr/local/mysql/bin/mysql -uroot -p123456 -e "set global relay_log_purge=1;flush logs;set global relay_log_purge=0;flush logs;"

##5 配置MHA監控、管理服務

#創建mha管理賬號

mysql> grant all privileges on *.* to 'mhaadmin'@'%' identified by '123456';

Query OK, 0 rows affected, 1 warning (0.54 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.23 sec)

#編輯MHA配置文件

############

#manager_workdir和remote_workdir用來定義MHA管理目錄,以便存放日志。

#user和password為MHA的管理賬號密碼

#repl_user和repl_password為復制的賬號密碼

#如果你的環境是鏈式復制架構,那么試著multi_tier_slave=1

#ping_interval=1每個一秒檢測一次

#ping_type、master_ip_failover_script和master_ip_online_change_script定義故障切換和在線切換

#secondary_check_script是為了防止網絡抖動誤切換,造成數據不一致。原理:當監控節點無法連接mysql主庫是,會視圖從其他從服務器去ping和連接mysql主庫,只有雙方都連接失敗,才認定mysql主庫宕機,如果有以防可以連接mysql主庫,則不發生切換

#ignore_fail=0缺省情況下,當某個Slave故障時(比如:不能通過MySQL/SSH連接,SQL線程因錯誤停止等),MHA不開啟故障切換;若設置為1,則對應的那個Slave出現故障時自動切換。

#candidate_master用于設置某個Slave是否可以優先成為Master。若設置為1,則對應的那個Slave可優先成為新的Master;若多個Slave均設置該參數為1,則成為Master的優先級按照[server_1]/[server_2]/…排序;

#master_binlog_dir=  MySQL主庫的binlog日志文件的全路徑,缺省為/var/lib/mysql,根據實際情況設置為真實的路徑。該參數適用于這么一種情況:Master實例故障,但OS系統運行正常,此時MHA可通過SSH登錄,然后讀取并拷貝必須的二進制日志事件(即差異的日志)。#可見該參數是必要而有用的,因為Master死掉后,MHA無法自動獲取binlog日志文件的路徑。另外,可用逗號隔開設置多個路徑。

#check_repl_delay 缺省情況下,如果某個Slave延遲超過100MB的relay logs,MHA則不會選擇該Slave成為新的Master,因為這需要太長的時間來恢復。若設置該參數為0,MHA在選擇新的Master時,會忽略復制延遲。

############

vi /etc/mha.cnf

[server default]

user=mhaadmin

password=123456

manager_workdir=/usr/local/mha

manager_log=/usr/local/mha/manager.log

remote_workdir=/usr/local/mha

ssh_user=root

ssh_port=22

repl_user=rep

repl_password=123456

ping_interval=1

ping_type=CONNECT

master_ip_failover_script=/usr/local/mha/scripts/master_ip_failover

master_ip_online_change_script=/usr/local/mha/scripts/master_ip_online_change

secondary_check_script=/usr/bin/masterha_secondary_check -s 192.168.56.222 -s 192.168.56.223 -s 192.168.56.224 --user=root --master_host=master --master_ip=192.168.56.221 --master_port=3306

[server1]

ignore_fail=0

check_repl_delay=1

hostname=MHA1

ip=192.168.56.221

ssh_port=22

port=3306

master_binlog_dir=/usr/local/mysql/logs/

candidate_master=1

[server2]

ignore_fail=0

check_repl_delay=1

hostname=MHA2

ip=192.168.56.222

ssh_port=22

port=3306

master_binlog_dir=/usr/local/mysql/logs/

candidate_master=1

[server3]

ignore_fail=0

check_repl_delay=1

hostname=MHA3

ip=192.168.56.223

ssh_port=22

port=3306

master_binlog_dir=/usr/local/mysql/logs/

candidate_master=1

##使用工具檢測ssh

[root@MHA4 logs]# masterha_check_ssh --conf=/etc/mha.cnf

Fri Apr 28 15:11:14 2017 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.

Fri Apr 28 15:11:14 2017 - [info] Reading application default configurations from /etc/mha.cnf..

Fri Apr 28 15:11:14 2017 - [info] Reading server configurations from /etc/mha.cnf..

Fri Apr 28 15:11:14 2017 - [info] Starting SSH connection tests..

Fri Apr 28 15:11:17 2017 - [debug]

Fri Apr 28 15:11:15 2017 - [debug]  Connecting via SSH from root@master(192.168.56.221:22) to root@slave1(192.168.56.222:22)..

Fri Apr 28 15:11:15 2017 - [debug]   ok.

Fri Apr 28 15:11:15 2017 - [debug]  Connecting via SSH from root@master(192.168.56.221:22) to root@slave2(192.168.56.223:22)..

Fri Apr 28 15:11:17 2017 - [debug]   ok.

Fri Apr 28 15:11:17 2017 - [debug]

Fri Apr 28 15:11:15 2017 - [debug]  Connecting via SSH from root@slave1(192.168.56.222:22) to root@master(192.168.56.221:22)..

Fri Apr 28 15:11:16 2017 - [debug]   ok.

Fri Apr 28 15:11:16 2017 - [debug]  Connecting via SSH from root@slave1(192.168.56.222:22) to root@slave2(192.168.56.223:22)..

Fri Apr 28 15:11:17 2017 - [debug]   ok.

Fri Apr 28 15:11:17 2017 - [debug]

Fri Apr 28 15:11:16 2017 - [debug]  Connecting via SSH from root@slave2(192.168.56.223:22) to root@master(192.168.56.221:22)..

Fri Apr 28 15:11:17 2017 - [debug]   ok.

Fri Apr 28 15:11:17 2017 - [debug]  Connecting via SSH from root@slave2(192.168.56.223:22) to root@slave1(192.168.56.222:22)..

Fri Apr 28 15:11:17 2017 - [debug]   ok.

Fri Apr 28 15:11:17 2017 - [info] All SSH connection tests passed successfully.

[root@MHA4 ~]# masterha_check_repl --conf=/etc/mha.cnf

Fri Apr 28 16:12:44 2017 - [info]   /usr/local/mha/scripts/master_ip_failover --command=status --ssh_user=root --orig_master_host=MHA1 --orig_master_ip=192.168.56.221 --orig_master_port=3306

Bareword "FIXME_xxx" not allowed while "strict subs" in use at /usr/local/mha/scripts/master_ip_failover line 93.

Execution of /usr/local/mha/scripts/master_ip_failover aborted due to compilation errors.

Fri Apr 28 16:12:44 2017 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln216]  Failed to get master_ip_failover_script status with return code 255:0.

Fri Apr 28 16:12:44 2017 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln386] Error happend on checking configurations.  at /usr/bin/masterha_check_repl line 48

Fri Apr 28 16:12:44 2017 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln482] Error happened on monitoring servers.

Fri Apr 28 16:12:44 2017 - [info] Got exit code 1 (Not master dead).

MySQL Replication Health is NOT OK!

解決方案:

[root@MHA4 ~]# grep master_ip_failover /etc/mha.cnf

#master_ip_failover_script=/usr/local/mha/scripts/master_ip_failover

#再次檢查主從復制

[root@MHA4 ~]# masterha_check_repl --conf=/etc/mha.cnf

Fri Apr 28 16:21:55 2017 - [info] Slaves settings check done.

Fri Apr 28 16:21:55 2017 - [info]

MHA1 (current master)

+--MHA2

+--MHA3

Fri Apr 28 16:21:55 2017 - [info] Checking replication health on MHA2..

Fri Apr 28 16:21:55 2017 - [info]  ok.

Fri Apr 28 16:21:55 2017 - [info] Checking replication health on MHA3..

Fri Apr 28 16:21:55 2017 - [info]  ok.

Fri Apr 28 16:21:55 2017 - [warning] master_ip_failover_script is not defined.

Fri Apr 28 16:21:55 2017 - [warning] shutdown_script is not defined.

Fri Apr 28 16:21:55 2017 - [info] Got exit code 0 (Not master dead).

MySQL Replication Health is OK.

#檢查mha  Manager狀態

[root@MHA4 ~]# masterha_check_status --conf=/etc/mha.cnf

mha is stopped(2:NOT_RUNNING).

注意:如果正常,會顯示"PING_OK",否則會顯示"NOT_RUNNING",這代表MHA監控沒有開啟。

#開啟Manager服務

[root@MHA4 ~]# nohup masterha_manager --conf=/etc/mha.cnf --remove_dead_master_conf --ignore_last_failover < /dev/null > /usr/local/mha/manager.log 2>&1 &

[1] 5073

啟動參數介紹:

--remove_dead_master_conf      該參數代表當發生主從切換后,老的主庫的ip將會從配置文件中移除。

--manger_log                            日志存放位置

--ignore_last_failover                 在缺省情況下,如果MHA檢測到連續發生宕機,且兩次宕機間隔不足8小時的話,則不會進行Failover,之所以這樣限制是為了避免ping-pong效應。該參數代表忽略上次MHA觸發切換產生的文件,默認情況下,MHA發生切換后會在日志目錄,也就是上面我設置的/data產生app1.failover.complete文件,下次再次切換的時候如果發現該目錄下存在該文件將不允許觸發切換,除非在第一次切換后收到刪除該文件,為了方便,這里設置為--ignore_last_failover。

[root@MHA4 ~]# masterha_check_status --conf=/etc/mha.cnf

mha (pid:5073) is running(0:PING_OK), master:MHA1

[root@MHA4 ~]# tail -f /usr/local/mha/manager.log

##停止MHA Manager服務

[root@MHA4 ~]# masterha_stop --conf=/etc/mha.cnf

Stopped mha successfully.

[1]+  Exit 1                  nohup masterha_manager --conf=/etc/mha.cnf --remove_dead_master_conf --ignore_last_failover < /dev/null > /usr/local/mha/manager.log 2>&1

[root@MHA4 ~]#

## 6 MHA 管理和切換VIP

[root@MHA1 ~]# /sbin/ifconfig eth2:1 192.168.56.225

[root@MHA1 ~]# ifconfig

eth2      Link encap:Ethernet  HWaddr 08:00:27:8B:0A:CE  

          inet addr:192.168.56.221  Bcast:192.168.56.255  Mask:255.255.255.0

          inet6 addr: fe80::a00:27ff:fe8b:ace/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:3348 errors:0 dropped:0 overruns:0 frame:0

          TX packets:2758 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:316425 (309.0 KiB)  TX bytes:292848 (285.9 KiB)

eth2:1    Link encap:Ethernet  HWaddr 08:00:27:8B:0A:CE  

          inet addr:192.168.56.225  Bcast:192.168.56.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:4 errors:0 dropped:0 overruns:0 frame:0

          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:240 (240.0 b)  TX bytes:240 (240.0 b)

#編輯master_ip_failover_script腳本

#!/usr/bin/env perl


use strict;

use warnings FATAL => 'all';


use Getopt::Long;


my (

    $command,          $ssh_user,        $orig_master_host, $orig_master_ip,

    $orig_master_port, $new_master_host, $new_master_ip,    $new_master_port

);


my $vip = '192.168.56.225/24';

my $key = '1';

my $ssh_start_vip = "/sbin/ifconfig eth2:$key $vip";

my $ssh_stop_vip = "/sbin/ifconfig eth2:$key down";


GetOptions(

    'command=s'          => \$command,

    'ssh_user=s'         => \$ssh_user,

    'orig_master_host=s' => \$orig_master_host,

    'orig_master_ip=s'   => \$orig_master_ip,

    'orig_master_port=i' => \$orig_master_port,

    'new_master_host=s'  => \$new_master_host,

    'new_master_ip=s'    => \$new_master_ip,

    'new_master_port=i'  => \$new_master_port,

);


exit &main();


sub main {


    print "\n\nIN SCRIPT TEST====$ssh_stop_vip==$ssh_start_vip===\n\n";


    if ( $command eq "stop" || $command eq "stopssh" ) {


        my $exit_code = 1;

        eval {

            print "Disabling the VIP on old master: $orig_master_host \n";

            &stop_vip();

            $exit_code = 0;

        };

        if ($@) {

            warn "Got Error: $@\n";

            exit $exit_code;

        }

        exit $exit_code;

    }

    elsif ( $command eq "start" ) {


        my $exit_code = 10;

        eval {

            print "Enabling the VIP - $vip on the new master - $new_master_host \n";

            &start_vip();

            $exit_code = 0;

        };

        if ($@) {

            warn $@;

            exit $exit_code;

        }

        exit $exit_code;

    }

    elsif ( $command eq "status" ) {

        print "Checking the Status of the script.. OK \n";

        exit 0;

    }

    else {

        &usage();

        exit 1;

    }

}


sub start_vip() {

    `ssh $ssh_user\@$new_master_host \" $ssh_start_vip \"`;

}

sub stop_vip() {

     return 0  unless  ($ssh_user);

    `ssh $ssh_user\@$orig_master_host \" $ssh_stop_vip \"`;

}


sub usage {

    print

    "Usage: master_ip_failover --command=start|stop|stopssh|status --orig_master_host=host --orig_master_ip=ip --orig_master_port=port --new_master_host=host --new_master_ip=ip --new_master_port=port\n";

}


##7 測試MHA 故障切換和日志追趕

#主服務器

[root@MHA1 ~]# pkill -9 mysqld

[root@MHA4 ~]# tail -f /usr/local/mha/manager.log

......

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

mha: MySQL Master failover MHA1 to MHA2 succeeded

Master MHA1 is down!

Check MHA Manager logs at MHA4:/usr/local/mha/manager.log for details.

Started automated(non-interactive) failover.

Invalidated master IP address on MHA1.

The latest slave MHA2(192.168.56.222:3306) has all relay logs for recovery.

Selected MHA2 as a new master.

MHA2: OK: Applying all logs succeeded.

MHA2: OK: Activated master IP address.

MHA3: This host has the latest relay log events.

Generating relay diff files from the latest slave succeeded.

MHA3: OK: Applying all logs succeeded. Slave started, replicating from MHA2.

MHA2: Resetting slave info succeeded.

Master failover to MHA2(192.168.56.222:3306) completed successfully.

切換完成后,MHA的manager服務就會停止,這是需要把MHA的配置文件中的server選項調整,把主服務器放在server1的內容下。把secondary_check_script內容修改。

[root@MHA4 ~]# vi /etc/mha.cnf

[server default]

manager_log=/usr/local/mha/manager.log

manager_workdir=/usr/local/mha

master_ip_failover_script=/usr/local/mha/scripts/master_ip_failover

master_ip_online_change_script=/usr/local/mha/scripts/master_ip_online_change

password=123456

ping_interval=1

ping_type=CONNECT

remote_workdir=/usr/local/mha

repl_password=123456

repl_user=rep

secondary_check_script=/usr/bin/masterha_secondary_check -s 192.168.56.221 -s 192.168.56.223 -s 192.168.56.224 --user=root --master_host=MHA2 --master_ip=192.168.56.222--master_port=3306

ssh_port=22

ssh_user=root

user=mhaadmin

[server1]

candidate_master=1

check_repl_delay=1

hostname=MHA2

ignore_fail=0

ip=192.168.56.222

master_binlog_dir=/usr/local/mysql/logs/

port=3306

ssh_port=22

[server2]

candidate_master=1

check_repl_delay=1

hostname=MHA1

ignore_fail=0

ip=192.168.56.221

master_binlog_dir=/usr/local/mysql/logs/

port=3306

ssh_port=22

[server3]

candidate_master=1

check_repl_delay=1

hostname=MHA3

ignore_fail=0

ip=192.168.56.223

master_binlog_dir=/usr/local/mysql/logs/

port=3306

ssh_port=22

#修改當原主庫的配置文件把slave參數開放,修改當前主庫配置文件把slave參數注釋掉,重啟mysql服務器

#slave

#relay_log=/usr/local/mysql/logs/relay-log.log

#master-info-repository=TABLE

#relay-log-info-repository=TABLE

#sync_master_info = 1

#sync_relay_log = 1

#sync_relay_log_info = 1

#read_only = 1

relay_log_purge = 0

[root@MHA2 ~]# /etc/init.d/mysqld restart                              

Shutting down MySQL............                            [  OK  ]

Starting MySQL.                                                  [  OK  ]

#檢查MHA的配置文件和啟動MHA服務

[root@MHA4 ~]# masterha_check_ssh --conf=/etc/mha.cnf

Wed May  3 13:38:32 2017 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.

Wed May  3 13:38:32 2017 - [info] Reading application default configurations from /etc/mha.cnf..

Wed May  3 13:38:32 2017 - [info] Reading server configurations from /etc/mha.cnf..

Wed May  3 13:38:32 2017 - [info] Starting SSH connection tests..

Wed May  3 13:38:33 2017 - [debug]

Wed May  3 13:38:32 2017 - [debug]  Connecting via SSH from root@MHA2(192.168.56.221:22) to root@MHA2(192.168.56.222:22)..

Wed May  3 13:38:33 2017 - [debug]   ok.

Wed May  3 13:38:33 2017 - [debug]  Connecting via SSH from root@MHA2(192.168.56.221:22) to root@MHA3(192.168.56.223:22)..

Wed May  3 13:38:33 2017 - [debug]   ok.

Wed May  3 13:38:33 2017 - [debug]

Wed May  3 13:38:33 2017 - [debug]  Connecting via SSH from root@MHA3(192.168.56.223:22) to root@MHA2(192.168.56.222:22)..

Wed May  3 13:38:33 2017 - [debug]   ok.

Wed May  3 13:38:33 2017 - [debug]  Connecting via SSH from root@MHA3(192.168.56.223:22) to root@MHA2(192.168.56.221:22)..

Wed May  3 13:38:33 2017 - [debug]   ok.

Wed May  3 13:38:33 2017 - [info] All SSH connection tests passed successfully.

[root@MHA4 ~]# masterha_check_repl --conf=/etc/mha.cnf

Wed May  3 13:38:56 2017 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.

Wed May  3 13:38:56 2017 - [info] Reading application default configurations from /etc/mha.cnf..

Wed May  3 13:38:56 2017 - [info] Reading server configurations from /etc/mha.cnf..

Wed May  3 13:38:56 2017 - [info] MHA::MasterMonitor version 0.55.

Wed May  3 13:38:56 2017 - [error][/usr/share/perl5/vendor_perl/MHA/Server.pm, ln241]  Getting relay log directory or current relay logfile from replication table failed on MHA2(192.168.56.222:3306)!

Wed May  3 13:38:56 2017 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln386] Error happend on checking configurations.  at /usr/share/perl5/vendor_perl/MHA/ServerManager.pm line 269

Wed May  3 13:38:56 2017 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln482] Error happened on monitoring servers.

Wed May  3 13:38:56 2017 - [info] Got exit code 1 (Not master dead).

MySQL Replication Health is NOT OK!

注意主庫的slave參數relay-log等參數已經開啟,所以檢查不過,注釋掉重啟就可以了

感謝各位的閱讀,以上就是“MHA的安裝搭建和測試”的內容了,經過本文的學習后,相信大家對MHA的安裝搭建和測試這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

mha
AI

江川县| 启东市| 桃源县| 滁州市| 宾阳县| 吴忠市| 修文县| 永新县| 晋中市| 峨眉山市| 高州市| 东城区| 宁南县| 翁牛特旗| 怀集县| 昌江| 阜城县| 上饶县| 赫章县| 松原市| 仙游县| 沙洋县| 高要市| 孟津县| 蕲春县| 炎陵县| 宿松县| 利津县| 太仆寺旗| 山阴县| 汉沽区| 玛纳斯县| 米脂县| 林州市| 长治县| 镇安县| 建阳市| 华亭县| 阳信县| 清河县| 宣城市|