MHA configuration File Sample Description

Source: Internet
Author: User

Like most Linux applications, the correct use of MHA relies on a reasonable configuration file. The MHA configuration file is similar to the MySQL my.cnf file configuration, takes the sub-module, Param=value Way to configure, the configuration file is located in the management node, usually including each MySQL server hostname, MySQL username, password, working directory and so on. This article lists some examples of single-set MHA and the use of global configuration to manage multiple sets of MHA configuration files for your reference.

1, a single set of MHA configuration sample
manager_host$ cat/etc/app1.cnf

[Server default]
# Log in to MySQL database account and password, default to root, because need stop SLAVE, change MASTER, RESET SLAVE and so on.
User=root
Password=mysqlpass

# working directory on the manager #位于管理节点工作目录
Manager_workdir=/var/log/masterha/app1

# Manager log File #位于管理节点工作日志文件
Manager_log=/var/log/masterha/app1/app1.log

# working directory on MySQL servers
# The working directory where node is used to generate the log, if it does not exist, MHA node will be created automatically, assuming that the appropriate permissions are required, or node will terminate.
# The default directory is "/var/tmp".
Remote_workdir=/var/log/masterha/app1

#[servern] section, configure information for each node, scoped to individual nodes, and the order in which each node is written affects the order of the new master
#也可以通过配置candidate_master参数来影响哪个节点具有优先级成为新master
[Server1]
Hostname=host1

[Server2]
Hostname=host2

[Server3]
Hostname=host3

2, multiple sets of MHA configuration samples
If multiple sets of MHA are deployed in a production environment based on a single management node, you can configure the same or a common section by using a global configuration file to achieve simplified configuration for easy management purposes.
Assuming we have created/ETC/MASTERHA_DEFAULT.CNF, the MHA Manager script will first read the file and then read the specified configuration file.
This function is similar to/etc/profile and then read ~/.bash_profile
If you do not configure a global configuration file, you receive the following prompt:
[WARNING] Global configuration file/etc/masterha_default.cnf not found. Skipping.

A, global configuration file sample
such as:/ETC/MASTERHA_DEFAULT.CNF
[Server default]
User=root
Password=rootpass
Ssh_user=root

#mysql the location of the database Master node Binlog, which is used to read the Binlog event sequentially via SSH when the master node is dead
#该参数需要配置, the Binlog log location cannot be obtained automatically by the replication mechanism because the master node is dead
#以下为rpm安装方式缺省binlog位置, the corresponding adjustment should be made according to the situation
Master_binlog_dir=/var/lib/mysql
Remote_workdir=/data/log/masterha

#用于检测各节点间的连接性, here is a detailed reference to the MHA Parameters Description Section
secondary_check_script= masterha_secondary_check-s remote_host1-s Remote_host2
Ping_interval=3

#定义用于实现VIP漂移的脚本, followed by the Shutdown and report script
Master_ip_failover_script=/script/masterha/master_ip_failover
shutdown_script=/script/masterha/power_manager
report_script=/script/masterha/send_master_failover_mail

b, each MHA separate configuration sample
Here are 2 sets of MHA profiles for different applications, as follows
App1:
manager_host$ cat/etc/app1.cnf

[Server default]
Manager_workdir=/var/log/masterha/app1 #工作目录 Author:leshami
Manager_log=/var/log/masterha/app1/app1.log #日志文件 Blog:http://blog.csdn.net/leshami

[Server1]
Hostname=host1
Candidate_master=1

[Server2]
Hostname=host2
Candidate_master=1

[Server3]
Hostname=host3

[Server4]
Hostname=host4
No_master=1

APP2:
manager_host$ cat/etc/app2.cnf

[Server default]
Manager_workdir=/var/log/masterha/app2
Manager_log=/var/log/masterha/app2/app2.log

[Server1]
Hostname=host11
Candidate_master=1

[Server2]
Hostname=host12
Candidate_master=1

[Server3]
hostname=host13

[Server4]
hostname=host14
No_master=1

Note: For the above configuration, if the application configuration is different from the global configuration, the application configuration has the highest priority, that is the same item, the value of the applied configuration will replace the globally configured value

3. Binlog Server
This feature is supported by MHA version 0.56. That is, you can define the [binlogn] option. In this section, you can define Mysqlbinlog streaming servers.
If Gtid is turned on, MHA checks the Binlog server and binlog the server log before the other slave node logs, MHA will apply the difference log from the Binlog server before recovery
If Gtid is not turned on, MHA ignores Binlog servers. The following sample:

manager_host$ cat/etc/app1.cnf

[Server default]
# MySQL user and password
User=root
Password=mysqlpass

# working directory on the manager
Manager_workdir=/var/log/masterha/app1

# Manager log File
Manager_log=/var/log/masterha/app1/app1.log
# working directory on MySQL servers
Remote_workdir=/var/log/masterha/app1

[Server1]
Hostname=host1

[Server2]
Hostname=host2

[Server3]
Hostname=host3

[Binlog1]
Hostname=binlog_host1

[BINLOG2]
Hostname=binlog_host2

Reference: Writing an application configuration file

MHA configuration File Sample Description

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.