search
HomeDatabaseMysql TutorialMHA安装及等效性配置

MHA安装及等效性配置

Jun 07, 2016 pm 04:13 PM
CanInstallunderstandmanagenodeConfiguration

MHA由MHA节点(可以理解为子节点)及MHA管理节点2部分组成。因此对于MHA的安装,相应的也分为2个部分,即安装MHA节点,安装MHA管理节点。本文基于CentOS 5.9 64bit简要描述了MHA的安装,同时也描述了在配置MHA时需要完成的等效性配置。供大家参考。 1、MHA的组

MHA由MHA节点(可以理解为子节点)及MHA管理节点2部分组成。因此对于MHA的安装,相应的也分为2个部分,即安装MHA节点,安装MHA管理节点。本文基于CentOS 5.9 64bit简要描述了MHA的安装,同时也描述了在配置MHA时需要完成的等效性配置。供大家参考。

1、MHA的组成
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 do not run always, but are invoked from MHA manager programs when needed (at configuration check, failover, etc). Both MHA 【本文来自鸿网互联 (http://www.68idc.cn)】Manager and MHA Node are written in Perl.

2、安装MHA Node
MHA Node has scripts and dependent perl modules that do 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 install MHA Node to all MySQL servers (both master and slave). You also need to install MHA Node on 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 be able to install easily.

###本次安装环境
# cat /etc/issue
CentOS release 5.9 (Final)
Kernel \r on an \m

###本次的演示环境
# more /etc/hosts
192.168.1.6 dbsrv1 #DB master
192.168.1.7 dbsrv2 #DB slave1
192.168.1.8 dbsrv3 #DB slave2
192.168.1.82 mysql-manager #DB manager node

###以下安装包,建议node和manger都安装
# yum install perl-DBD-MySQL
# yum install perl-Config-Tiny
# yum install perl-Log-Dispatch
# yum install perl-Parallel-ForkManager

###如果yum时相关相关包时,无法获取到,建议配置epel后再安装,需要注意对应的相关版本号。
# wget http://mirrors.ustc.edu.cn/fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm
# rpm -Uvh epel-release-5-4.noarch.rpm

###以下安装包从网络上搜集整理,大家可根据情形自行决定是否安装
# yum -y install perl-Config-IniFiles ncftp perl-Params-Validate perl-CPAN perl-Test-Mock-LWP.noarch \
> perl-LWP-Authen-Negotiate.noarch perl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker

# ls -hltr
total 172K
-rw-r--r-- 1 root root 112K Dec 5 15:46 mha4mysql-manager-0.56.tar.gz
-rw-r--r-- 1 root root 49K Dec 5 15:46 mha4mysql-node-0.56.tar.gz

# tar -xvf mha4mysql-node-0.56.tar.gz
# cd mha4mysql-node-0.56
# perl Makefile.PL
# make && make install

###验证安装后的几个文件
[root@dbsrv1 bin]# ls apply_diff_relay_logs save_binary_logs filter_mysqlbinlog purge_relay_logs
apply_diff_relay_logs filter_mysqlbinlog purge_relay_logs save_binary_logs

3、安装MHA Manager
MHA Manager has 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. Do not forget to install MHA Node.
MHA Node package
DBD::mysql
Config::Tiny
Log::Dispatch
Parallel::ForkManager
Time::HiRes (included from Perl v5.7.3)

###以下部分为管理节点上的安装,注,管理节点也要安装MHA Node,此处省略
# tar -xvf mha4mysql-manager-0.56.tar.gz
# perl Makefile.PL
# make && make install

# ls /usr/bin/mast*
/usr/bin/masterha_check_repl /usr/bin/masterha_conf_host /usr/bin/masterha_master_switch
/usr/bin/masterha_check_ssh /usr/bin/masterha_manager /usr/bin/masterha_secondary_check
/usr/bin/masterha_check_status /usr/bin/masterha_master_monitor /usr/bin/masterha_stop

4、配置等效性
###为各节点配置hosts文件
# for i in 6 7 8;do scp /etc/hosts 192.168.1.$i:/etc/;done

[root@mysql-manager #]$ whoami
root
###配置等效性
[root@mysql-manager ~]# ssh-keygen
[root@mysql-manager ~]# ls -a ./.ssh/
. .. id_rsa id_rsa.pub
[root@mysql-manager ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.6
[root@mysql-manager ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.7
[root@mysql-manager ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.8

###使用上面的方法在其余的几个节点如法炮制后验证等效性
[root@dbsrv2 ~]# ssh dbsrv1 date;ssh dbsrv2 date;ssh dbsrv3 date; ssh mysql-manager date;

###在管理节点端使用MHA命令验证等效性
[root@mysql-manager ~]# masterha_check_ssh --conf=/etc/app1.cnf
Mon Feb 16 15:12:43 2015 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Mon Feb 16 15:12:43 2015 - [info] Reading application default configuration from /etc/app1.cnf..
Mon Feb 16 15:12:43 2015 - [info] Reading server configuration from /etc/app1.cnf..
Mon Feb 16 15:12:43 2015 - [info] Starting SSH connection tests..
Mon Feb 16 15:12:45 2015 - [debug]
Mon Feb 16 15:12:43 2015 - [debug] Connecting via SSH from mysql@192.168.1.6(192.168.1.6:22) to mysql@192.168.1.7(192.168.1.7:22)..
Mon Feb 16 15:12:44 2015 - [debug] ok.
Mon Feb 16 15:12:44 2015 - [debug] Connecting via SSH from mysql@192.168.1.6(192.168.1.6:22) to mysql@192.168.1.8(192.168.1.8:22)..
Mon Feb 16 15:12:44 2015 - [debug] ok.
Mon Feb 16 15:12:45 2015 - [debug]
Mon Feb 16 15:12:44 2015 - [debug] Connecting via SSH from mysql@192.168.1.7(192.168.1.7:22) to mysql@192.168.1.6(192.168.1.6:22)..
Mon Feb 16 15:12:44 2015 - [debug] ok.
Mon Feb 16 15:12:44 2015 - [debug] Connecting via SSH from mysql@192.168.1.7(192.168.1.7:22) to mysql@192.168.1.8(192.168.1.8:22)..
Mon Feb 16 15:12:44 2015 - [debug] ok.
Mon Feb 16 15:12:45 2015 - [debug]
Mon Feb 16 15:12:44 2015 - [debug] Connecting via SSH from mysql@192.168.1.8(192.168.1.8:22) to mysql@192.168.1.6(192.168.1.6:22)..
Mon Feb 16 15:12:45 2015 - [debug] ok.
Mon Feb 16 15:12:45 2015 - [debug] Connecting via SSH from mysql@192.168.1.8(192.168.1.8:22) to mysql@192.168.1.7(192.168.1.7:22)..
Mon Feb 16 15:12:45 2015 - [debug] ok.
Mon Feb 16 15:12:45 2015 - [info] All SSH connection tests passed successfully.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Explain the ACID properties (Atomicity, Consistency, Isolation, Durability).Explain the ACID properties (Atomicity, Consistency, Isolation, Durability).Apr 16, 2025 am 12:20 AM

ACID attributes include atomicity, consistency, isolation and durability, and are the cornerstone of database design. 1. Atomicity ensures that the transaction is either completely successful or completely failed. 2. Consistency ensures that the database remains consistent before and after a transaction. 3. Isolation ensures that transactions do not interfere with each other. 4. Persistence ensures that data is permanently saved after transaction submission.

MySQL: Database Management System vs. Programming LanguageMySQL: Database Management System vs. Programming LanguageApr 16, 2025 am 12:19 AM

MySQL is not only a database management system (DBMS) but also closely related to programming languages. 1) As a DBMS, MySQL is used to store, organize and retrieve data, and optimizing indexes can improve query performance. 2) Combining SQL with programming languages, embedded in Python, using ORM tools such as SQLAlchemy can simplify operations. 3) Performance optimization includes indexing, querying, caching, library and table division and transaction management.

MySQL: Managing Data with SQL CommandsMySQL: Managing Data with SQL CommandsApr 16, 2025 am 12:19 AM

MySQL uses SQL commands to manage data. 1. Basic commands include SELECT, INSERT, UPDATE and DELETE. 2. Advanced usage involves JOIN, subquery and aggregate functions. 3. Common errors include syntax, logic and performance issues. 4. Optimization tips include using indexes, avoiding SELECT* and using LIMIT.

MySQL's Purpose: Storing and Managing Data EffectivelyMySQL's Purpose: Storing and Managing Data EffectivelyApr 16, 2025 am 12:16 AM

MySQL is an efficient relational database management system suitable for storing and managing data. Its advantages include high-performance queries, flexible transaction processing and rich data types. In practical applications, MySQL is often used in e-commerce platforms, social networks and content management systems, but attention should be paid to performance optimization, data security and scalability.

SQL and MySQL: Understanding the RelationshipSQL and MySQL: Understanding the RelationshipApr 16, 2025 am 12:14 AM

The relationship between SQL and MySQL is the relationship between standard languages ​​and specific implementations. 1.SQL is a standard language used to manage and operate relational databases, allowing data addition, deletion, modification and query. 2.MySQL is a specific database management system that uses SQL as its operating language and provides efficient data storage and management.

Explain the role of InnoDB redo logs and undo logs.Explain the role of InnoDB redo logs and undo logs.Apr 15, 2025 am 12:16 AM

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

What are the key metrics to look for in an EXPLAIN output (type, key, rows, Extra)?What are the key metrics to look for in an EXPLAIN output (type, key, rows, Extra)?Apr 15, 2025 am 12:15 AM

Key metrics for EXPLAIN commands include type, key, rows, and Extra. 1) The type reflects the access type of the query. The higher the value, the higher the efficiency, such as const is better than ALL. 2) The key displays the index used, and NULL indicates no index. 3) rows estimates the number of scanned rows, affecting query performance. 4) Extra provides additional information, such as Usingfilesort prompts that it needs to be optimized.

What is the Using temporary status in EXPLAIN and how to avoid it?What is the Using temporary status in EXPLAIN and how to avoid it?Apr 15, 2025 am 12:14 AM

Usingtemporary indicates that the need to create temporary tables in MySQL queries, which are commonly found in ORDERBY using DISTINCT, GROUPBY, or non-indexed columns. You can avoid the occurrence of indexes and rewrite queries and improve query performance. Specifically, when Usingtemporary appears in EXPLAIN output, it means that MySQL needs to create temporary tables to handle queries. This usually occurs when: 1) deduplication or grouping when using DISTINCT or GROUPBY; 2) sort when ORDERBY contains non-index columns; 3) use complex subquery or join operations. Optimization methods include: 1) ORDERBY and GROUPB

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor