MHA配置文件

MHA 配置文件

创建application配置文件

示例

manager_host$ cat /etc/app1.cnf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[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

所有参数必须遵循”param = value”语法。 例如,以下参数设置不正确。

1
2
3
4
[server1]
hostname=host1
# incorrect: must be "no_master=1" 应该写成no_master=1
no_master

[server default]区块内的参数对所有[serverN]生效,[serverN]应该配置每个server特定的参数

创建global配置文件

如果你计划使用一个MHA Manager管理两个或更多的applications(多个主从对),可以创建一个global配置文件管理通用参数.MHA Manager默认会去/etc/masterha_default.cnf读取global配置文件

global配置文件示例:

Global configuration file (/etc/masterha_default.cnf)

1
2
3
4
5
6
7
8
9
10
11
[server default]
user=root
password=rootpass
ssh_user=root
master_binlog_dir= /var/lib/mysql
remote_workdir=/data/log/masterha
secondary_check_script= masterha_secondary_check -s remote_host1 -s remote_host2
ping_interval=3
master_ip_failover_script=/script/masterha/master_ip_failover
shutdown_script= /script/masterha/power_manager
report_script= /script/masterha/send_master_failover_mail

以上参数在两个application间是公用的

每个application需要单独指定一个配置文件.以下示例为app1(host1-4)和app2(host11-14)的配置文件

app1:

manager_host$ cat /etc/app1.cnf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[server default]
manager_workdir=/var/log/masterha/app1
manager_log=/var/log/masterha/app1/app1.log
[server1]
hostname=host1
candidate_master=1
[server2]
hostname=host2
candidate_master=1
[server3]
hostname=host3
[server4]
hostname=host4
no_master=1

以上配置单独指定了app1的manager_workdir和manager_log等信息.对于管理多个application的情况,应当单独为每个app设置manager_workdir和manager_log

app2:

manager_host$ cat /etc/app2.cnf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[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

如果你同时在global配置文件和application配置文件中设置了同一个参数,那么后者(application)会覆盖前者.

Binlog server

从MHA 0.56版本开始,MHA支持新区块[binlogN].在binlog区块你可以定义mysqlbinlog streaming servers.当MHA使用基于GTID的failover,MHA会检查binlog servers,如果binlog server的日志>其他从库,MHA会从binlog server获取binlog event应用到slave.当MHA使用基于传统复制的failover,MHA会忽略binlog servers.

下面是示例配置

manager_host$ cat /etc/app1.cnf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[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

Powered by Hexo and Hexo-theme-hiker

Copyright © 2013 - 2018 Fan() All Rights Reserved.

访客数 : | 访问量 :

#