MySQL MHA high Availability installation configuration

Source: Internet
Author: User
Tags failover install perl

Installation

Bmildren edited this page on Jan 2016 · 1 revision

Pages -

    • Home

    • Advantages

    • Architecture

    • Commercialsupport

    • Configuration

    • Downloads

    • FAQ

    • Gtid_based_failover

    • Howmhaworks

    • Installation

    • Masterha_check_repl

    • Masterha_check_status

    • Masterha_conf_host

    • Masterha_manager

    • Masterha_master_switch

    • Show More pages ...

Clone this wiki locally

    • Installation

      • Downloading MHA Node and MHA Manager

      • Installing MHA Node

      • Installing MHA Manager

Installation

MHA consists of MHA Manager and MHA Node packages. MHA Manager runs on a manager server, and MHA Node runs on each MySQL server. MHA Node Programs does not run all, but is invoked from MHA manager programs when needed (at configuration check, Failov  Er, etc). Both MHA Manager and MHA Node is written in Perl.

Downloading MHA Node and MHA Manager

MHA Node and MHA Manager can is downloaded from the "Downloads" section. These is stable packages.

If you want to try development The source trees, check out GitHub source trees. MHA Manager is hosted here, and MHA Node are hosted here.

Installing MHA Node

MHA Node has scripts and dependent Perl modules that does the following.

    • Save_binary_logs:saving and copying Dead master ' s binary logs

    • apply_diff_relay_logs:identifying Differential relay log events and applying all necessary log events

    • Purge_relay_logs:purging Relay log files

You need to the install MHA Node to all MySQL servers (both master and slave). You also need to install MHA node in a Management Server because MHA Manager modules internally depend on MHA node modules  .  MHA Manager internally connects to managed MySQL servers via SSH and executes MHA Node scripts. MHA Node does not depend on any external Perl modules except Dbd::mysql so you should is able to install easily.

On Rhel/centos distribution, you can install the MHA Node RPM package as below.

# installed Dbd::mysql, install it like below, or install from source.# yum install perl-dbd-mysql## Get MHA Node rpm Package from "Downloads" section.# RPM-IVH mha4mysql-node-x.y-0.noarch.rpm

On Ubuntu/debian distribution, you can install the MHA Node Deb package as below.

# installed Dbd::mysql, install it like below, or install from source.# apt-get install Libdbd-mysql-perl # # Get MHA Node deb package from "Downloads" section.# dpkg-i mha4mysql-node_x.y_all.deb

You can also the install MHA Node from source.

# # Install Dbd::mysql if not installed$ tar-zxf mha4mysql-node-x.y.tar.gz$ perl makefile.pl$ make$ sudo make Install
Installing MHA Manager

MHA Manager have administrative command line programs such as Masterha_manager, Masterha_master_switch, etc, and dependent  Perl modules. MHA Manager depends on the following Perl modules. You need to install them before installing MHA Manager. Don't forget to install MHA Node.

    • MHA Node Package

    • Dbd::mysql

    • Config::tiny

    • Log::D Ispatch

    • Parallel::forkmanager

    • Time::hires (included from Perl v5.7.3)

On Rhel/centos distribution, you can install the MHA Manager RPM package as below.

# # Install Dependent Perl modules# yum install perl-dbd-mysql# yum install perl-config-tiny# yum install Perl-log-dispatch  # yum Install perl-parallel-forkmanager## install MHA Node, since MHA Manager uses some modules provided by MHA node.# rpm -IVH mha4mysql-node-x.y-0.noarch.rpm## Finally You can install MHA manager# RPM-IVH mha4mysql-manager-x.y-0.noarch.rpm

On Ubuntu/debian distribution, you can install the MHA Manager Deb package as below.

# # Install dependent Perl modules# apt-get install libdbd-mysql-perl# apt-get install libconfig-tiny-perl# apt-get Install liblog-dispatch-perl# apt-get Install libparallel-forkmanager-perl## install MHA Node, since MHA Manager uses some module s provided by MHA node.# dpkg-i mha4mysql-node_x.y_all.deb## Finally You can install MHA manager# dpkg-i Mha4mysql-manag Er_X.Y_all.deb

You can also the install MHA Manager from source.

# # Install dependent Perl modules# MHA Node (see above) # config::tiny## perl-mcpan-e "Install config::tiny" # Log::D Ispat ch## perl-mcpan-e "Install Log::D ispatch" # parallel::forkmanager # perl-mcpan-e "Install Parallel::forkmanager" # # Ins talling MHA manager$ tar-zxf mha4mysql-manager-x.y.tar.gz$ perl makefile.pl$ make$ sudo make install

Configuration

Bmildren edited this page on Jan 2016 · 1 revision

Pages -

    • Home

    • Advantages

    • Architecture

    • Commercialsupport

    • Configuration

    • Downloads

    • FAQs

    • Gtid_based_failover

    • Howmhaworks

    • Installation

    • Masterha_check_repl

    • Masterha_check_status

    • Masterha_conf_host

    • Masterha_manager

    • Masterha_master_switch

    • Show More pages ...

Clone this wiki locally

    • Writing an application configuration file

    • Writing a global configuration file

    • Binlog Server

Writing an application configuration file

To do MHA work, you had to create a configuration file and set parameters. Parameters include hostname of each MySQL server, MySQL username and password, working directory name, etc. The whole parameters is described at Parameters page.

The below is an example configuration file.

manager_host$ cat /etc/app1.cnf

[Server default]# MySQL user and passworduser=rootpassword=mysqlpass# working directory on the managermanager_workdir=/ var/log/masterha/app1# Manager Log filemanager_log=/var/log/masterha/app1/app1.log# working directory on MySQL Serversremote_workdir=/var/log/masterha/app1[server1]hostname=host1[server2]hostname=host2[server3]hostname= Host3

All parameters must follow "param=value" syntax. For example, the below parameter setting is incorrect.

[server1]hostname=host1# incorrect:must be "no_master=1" no_master

Application-scope parameters should is written in [server default] block. [serverN]in blocks, you should set Local-scope parameters. Hostname are mandatory local-scope parameter so have to be written H Ere. Block name should start from "server". Internally server configurations is sorted by block name, and sorted order matters when MHA decides new master (see FAQ F or details).

Writing a global configuration file

If you plan to manage-B or more MySQL applications ((master, Slaves) pairs) from a single manager server, creating a Glo Bal configuration file makes it much easier to configure. Once you write parameters in the "global" configuration file, you don't need to set parameters for each application. If you create a file at/etc/masterha_default.cnf, MHA Manager scripts automatically reads the file as a global Configurat Ion file.

You can set application scope parameters in the global configuration file. For example, if MySQL administrative user and password is identical on all MySQL servers, you can set "user" and "Passwor D "here.

Global Configuration Example:

Global configuration file (/etc/masterha_default.cnf)

[Server default]user=rootpassword=rootpassssh_user=rootmaster_binlog_dir=/var/lib/mysqlremote_workdir=/data/log /masterhasecondary_check_script= masterha_secondary_check-s remote_host1-s Remote_host2ping_interval=3master_ip_ failover_script=/script/masterha/master_ip_failovershutdown_script=/script/masterha/power_managerreport_script =/script/masterha/send_master_failover_mail

These parameters is applied to all applications monitored by MHA Manager running on the host.

Application configuration file should be written separately. The below example is Configuraing App1 (host1-4) and APP2 (HOST11-14).

App1:

manager_host$ cat /etc/app1.cnf

[Server Default]manager_workdir=/var/log/masterha/app1manager_log=/var/log/masterha/app1/app1.log[server1] HOSTNAME=HOST1CANDIDATE_MASTER=1[SERVER2]HOSTNAME=HOST2CANDIDATE_MASTER=1[SERVER3]HOSTNAME=HOST3[SERVER4] Hostname=host4no_master=1

In the above case, MHA Manager generates working files (including status files) Under/var/log/masterha/app1, and generate s log file At/var/log/masterha/app1/app1.log. You need to set the unique Directory/file names when monitoring other applications.

APP2:

manager_host$ cat /etc/app2.cnf

[Server Default]manager_workdir=/var/log/masterha/app2manager_log=/var/log/masterha/app2/app2.log[server1] HOSTNAME=HOST11CANDIDATE_MASTER=1[SERVER2]HOSTNAME=HOST12CANDIDATE_MASTER=1[SERVER3]HOSTNAME=HOST13[SERVER4] Hostname=host14no_master=1

If you set same parameters on both global configuration file and application configuration file, the latter (application C onfiguration) is used.

Binlog Server

Starting from MHA version 0.56, MHA supports new section [binlogN] . In binlog sections, you can define Mysqlbinlog streaming servers. When MHA does GTID based failover, MHA checks Binlog servers, and if Binlog servers is ahead of other slaves, MHA applies Differential Binlog events to the new master before recovery. When MHA does Non-gtid based (traditional) failover, MHA ignores Binlog servers.

Below is an example configuration.

manager_host$ cat /etc/app1.cnf

[Server default]# MySQL user and passworduser=rootpassword=mysqlpass# working directory on the managermanager_workdir=/ var/log/masterha/app1# Manager Log filemanager_log=/var/log/masterha/app1/app1.log# working directory on MySQL Serversremote_workdir=/var/log/masterha/app1[server1]hostname=host1[server2]hostname=host2[server3]hostname= Host3[binlog1]hostname=binlog_host1[binlog2]hostname=binlog_host2

Transferred from: Https://github.com/yoshinorim/mha4mysql-manager/wiki


MySQL MHA high Availability installation configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.