In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
# MHA deployment #
1. Server
192.168.56.21 mydb1 # Master
192.168.56.22 mydb2 # Slave
192.168.56.23 mydb3 # MHA manager
two。 All machines modify vim / etc/hosts
192.168.56.21 mydb1
192.168.56.22 mydb2
192.168.56.23 mydb3
3. Set SSH public key password-free login
# root user Action (/ root), pwd
Mkdir / .ssh
Chmod 700. ssh
Cd / .ssh
Ssh-keygen-t rsa # always enter
Ls-al
Cat ~ / .ssh/id_rsa.pub > > ~ / .ssh/authorized_keys
Ls-al
Chmod 600 ~ / .ssh/authorized_keys
Cd..
Scp-r. SSH 192.168.56.22:/root/
Scp-r. SSH 192.168.56.23:/root/
Ssh mydb1
Ssh mydb2
Ssh mydb3
4. Download mha4mysql-manager and mha4mysql-node
Https://github.com/yoshinorim/mha4mysql-manager
Https://github.com/yoshinorim/mha4mysql-node
5. Install perl-DBD-MySQL on three nodes (node and manager) and use the CD as the Yum source. # includes three packages: Perl-DBD-MySQL,mysql-libs,perl-DBI
Yum install perl-DBD-MySQL
Yum install perl-DBI
Yum install mysql-libs
6. Install node on three nodes (including management nodes)
Yum-y install perl-CPAN downloads the dependent package libraries required by perl
Perl-MCPAN-e "install inc::Module::Install finds and installs the packages needed by Makefile.PL in the dependency package library. The specific program is use inc::Module::Install.
Reference https://perlmaven.com/cant-locate-inc-module-install-in-inc
The package actually downloaded above is Module-Install-1.18.tar.gz.
/ / perl-MCPAN-e shell
/ / perl-MCPAN-e "install Module::Depends"
Reference http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece7631046893b4c4380147d8c8c4668d4e419ce3b4c413037bfa6663f405a8e906b6075ab4f5bbdf06270670123b598c8d40895ac925f75ce786a6459db0144dc42f39a5125b07fcd0caef14ef0ba8169cfef9480810a44cb23127af7e78a2a424bdd6f814f6df4a6e85f135d07bb9d6b39ae&p=8b2a971cc89401ff57ee967c525285&newp=80769a478a8702c308e2977c0f43cc231610db2151d7d0106b82c825d7331b001c3bbfb423241a05d8ce7c6d04aa4b5feaf4357534072ba3dda5c91d9fb4c57479d463771c&user=baidu&fm=sc&query=inc/Module/Install%2Epm+in+%40INC&qid=e9eec041000013a8&p1=10
Tar xzvf mha4mysql-node-0.56.tar.gz
Cd mha4mysql-node-0.56
Perl Makefile.PL
Note that after installing the perl install module, it can finally be executed normally. After executing PL, the system will verify which packages missing. At this time, you can install fewer packages according to his prompts.
Make & & make install
7. Install manager on the management node
/ / you can check the package name installed on this machine first.
Rpm-qa perl-Config-Tiny perl-Params-Validate perl-MIME-Types perl-Email-Date-Format perl-Mail-Sender perl-Mail-Sendmail perl-TimeDate perl-MailTools perl-MIME-Lite perl-Log-Dispatch perl-Parallel-ForkManager
A total of 11 bags
Rpm-qa perl-Config-Tiny perl-Params-Validate perl-MIME-Types perl-Email-Date-Format perl-Mail-Sender perl-Mail-Sendmail perl-TimeDate perl-MailTools perl-MIME-Lite perl-Log-Dispatch perl-Parallel-ForkManager | xargs rpm-ivh
The above command installs directly
Rpm-ivh perl-Config-Tiny-2.12-1.el5.rf.noarch.rpm
Rpm-ivh perl-Params-Validate-0.95-1.el5.rf.i386.rpm
Rpm-ivh perl-MIME-Types-1.28-2.el6.noarch.rpm
Rpm-ivh perl-Email-Date-Format-1.002-5.el6.noarch.rpm
Rpm-ivh perl-Mail-Sender-0.8.16-3.el6.noarch.rpm
Rpm-ivh perl-Mail-Sendmail-0.79-12.el6.noarch.rpm
Rpm-ivh perl-TimeDate-1.16-11.1.el6.noarch.rpm
Rpm-ivh perl-MailTools-2.04-4.el6.noarch.rpm
Rpm-ivh perl-MIME-Lite-3.027-2.el6.noarch.rpm
Rpm-ivh perl-Log-Dispatch-2.26-1.el5.rf.noarch.rpm
Rpm-ivh perl-Parallel-ForkManager-0.7.5-2.2.el5.rf.noarch.rpm
If you don't have any bread, download and install it directly from the yum source
Yum install perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager perl-Time-HiRes-y
Yum install perl-Time-HiRes # CD yum source
Tar xzvf mha4mysql-manager-0.56.tar.gz
Cd mha4mysql-manager-0.56
Perl Makefile.PL
Make & & make install
8 configure master-slave synchronous GTID mode
The init.sh script is used here, which can automatically build a master-slave GTID server on a single machine. There is something wrong with this script when there is no mysql user on the machine. After the script is initialized,
The modification is
Show grants for 'rpl_user@127.0.0.1'
Set up repl users on the main database
Grant replication slave on *. * to rpl_user@% identified by '1234'
Remove the excess rpl_user from the library, and note that the permission must be removed before the user can be deleted
Revoke replication slave on *. * from rpl_user@127.0.0.1
Revoke replication slave on *. * from 'rpl_user'@'%'
Drop user' rpl_user'@'%'
9 change the default password of root user
At the beginning of installing mysql, root users do not have a password, for fear of affecting mha, so establish a root user password
Use mysql
Mysql > (previous version) update user set password=password ("123456") where user= "root"
(5.7.11) update user set authentication_string=password ("123456") where user= "root"
Flush privileges
Ln-s / usr/local/mysql_5.7/bin/mysql / usr/bin / / soft link calls the mysql command
# Common commands #
/ usr/local/bin/masterha_check_ssh-- conf=/u01/mha/etc/app.cnf
/ usr/local/bin/masterha_check_repl-- conf=/u01/mha/etc/app.cnf
/ usr/local/bin/masterha_manager-conf=/u01/mha/etc/app.cnf &
/ u01/mha/etc/masterha_check_status-- conf=/u01/mha/etc/app.cnf
/ usr/local/bin/masterha_stop-- conf=/u01/mha/etc/app.cnf
Masterha_check_ssh-- conf=/u01/mha/etc/app.cnf / / monitors whether the ssh is normal
Masterha_check_repl-- conf=/u01/mha/etc/app.cnf / / monitors whether master-slave replication is normal
MHA masterha_check_repl detection process
# switch # #
I. failover failover
1. Simulated main library downtime
[root@mydb3~] # ssh mydb1 "killall-r mysqld"
two。 Looking at the management node log, you can see that VIP has drifted.
[root@mydb3 ~] # cat / u01/mha/log/manager.log | grep-I vip
3. Verify that the VIP is on the node mydb2
[root@mydb3 ~] # ssh mydb2 "ifconfig | grep 56.201-B1"
4. View the management node MHA switch log
[root@mydb3 ~] # tail / u01/mha/log/manager.log
5. New master (old slave)
Show master status\ G
6. New slave (old:master)
(1) Open MySQL
Mysqld_safe-- defaults-file=/u01/my3306/my.cnf &
(2) check the database
Show master status\ G
Show slave status\ G
(3) check the log file and location of the main database in the log of the management node
Cat / u01/mha/etc/app/manager.log | grep-I change
(4) connect master in slave
CHANGE MASTER TO
MASTER_HOST='192.168.56.21'
MASTER_PORT=3306
MASTER_LOG_FILE='mysql-bin.000005'
MASTER_LOG_POS=120
MASTER_USER='rep'
MASTER_PASSWORD='rep123'
7. Start the management node
/ usr/local/bin/masterha_manager-conf=/u01/mha/etc/app.cnf &
/ usr/local/bin/masterha_manager-conf=/u01/mha/etc/app.cnf-ignore_last_failover &
II. Switchover online handoff
1.master: close event_scheduler (i.e. 192.168.56.21)
Set global event_scheduler=off
2.manager: shuts down the management process (i.e. 192.168.56.23)
/ usr/local/bin/masterha_stop-- conf=/u01/mha/etc/app.cnf
3.manager: checking configuration fil
/ u01/mha/etc/app.cnf has not been modified and destroyed. If you break it, you need to re-edit the correct configuration file: / u01/mha/etc/app.cnf
Cp / u01/mha/etc/app.cnf.bak / u01/mha/etc/app.cnf
4. Start switching:
/ u01/mha/etc/masterha_master_switch-master_state=alive-conf=/u01/mha/etc/app.cnf
5.new master (old slave)
Mysql > show master status\ G
* * 1. Row *
File: binlog.000021
Position: 299
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set:
1 row in set (0.00 sec)
6.new slave (old master)
CHANGE MASTER TO
MASTER_HOST='192.168.56.22'
MASTER_PORT=3306
MASTER_LOG_FILE='binlog.000021'
MASTER_LOG_POS=299
MASTER_USER='rep'
MASTER_PASSWORD='rep123'
Mysql > start slave
Query OK, 0 rows affected (0.01 sec)
Mysql > show slave status\ G
* * 1. Row *
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.56.12
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: binlog.000017
Read_Master_Log_Pos: 299
Relay_Log_File: relaylog.000002
Relay_Log_Pos: 280
Relay_Master_Log_File: binlog.000017
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
7. Start the management node
/ u01/mha/etc/masterha_manager-conf=/u01/mha/etc/app.cnf &
/ u01/mha/etc/masterha_manager-conf=/u01/mha/etc/app.cnf-remove_dead_master_conf-ignore_last_failover
Https://www.cnblogs.com/zhoujinyi/p/3808673.html
# configuration file #
Vim / u01/mha/etc/app.cnf
[server default]
User = root
Password = 123456
Ssh_user = root
Repl_user = rpl_user
Repl_password = rpl_pass
Ping_interval = 1
Ping_type = SELECT
Manager_workdir=/u01/mha/etc/app
Manager_log=/u01/mha/log/manager.log
Remote_workdir=/u01/mha/etc/app
Master_binlog_dir= "/ u01/mysql_5.7/s1/log/binlog"
# master_ip_failover_script= "/ u01/mha/etc/master_ip_failover"
# master_ip_online_change_script= "/ u01/mha/etc/master_ip_failover"
Shutdown_script= ""
Report_script= ""
# check_repl_delay=0
[server1]
Hostname=iZ2zehy7gff0kpg1swp1czZ
Port=33091
Master_binlog_dir= "/ apps/dbdat/mysql5_data33091/log"
Candidate_master=1
Ignore_fail=1
[server2]
Hostname=iZ2zehy7gff0kpg1swp1czZ
Port=33092
Master_binlog_dir= "/ u01/mysql_5.7/s2/log/binlog"
Candidate_master=1
Ignore_fail=1
Vim / u01/mha/etc/master_ip_failover
#! / 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.201Universe 2400; # Virtual IP
My $key = "1"
My $int = "eth0"
My $ssh_start_vip = "/ sbin/ifconfig $int:$key $vip"
My $ssh_stop_vip = "/ sbin/ifconfig $int:$key down"
My $arp_effect = "/ sbin/arping-Uq-s192.168.56.201-I $int 192.168.56.1-c 3"; # Virtual IP and gat
Eway
# my $test = "echo successfull > / tmp/test.txt"
$ssh_user = "root"
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") {
# $orig_master_host, $orig_master_ip, $orig_master_port are passed.
# If you manage master ip address at global catalog database
# invalidate orig_master_ip here.
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") {
# all arguments are passed.
# If you manage master ip address at global catalog database
# activate new_master_ip here.
# You can also grant write access (create user, set read_only=0, etc) here.
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"
# `ssh $ssh_user\ @ cluster1\ "$ssh_start_vip\" `
& status ()
Exit 0
}
Else {
& usage ()
Exit 1
}
}
# A simple system call that enable the VIP on the new master
Sub start_vip () {
`ssh $ssh_user\ @ $new_master_host\ "$ssh_start_vip\" `
`ssh $ssh_user\ @ $new_master_host\ "$arp_effect\" `
# `ssh $ssh_user\ @ $new_master_host\ "$test\" `
}
# A simple system call that disable the VIP on the old_master
Sub stop_vip () {
`ssh $ssh_user\ @ $orig_master_host\ "$ssh_stop_vip\" `
}
Sub status () {
Print `ssh $ssh_user\ @ $orig_master_host\ "ip add show $int\" `
}
Sub usage {
"Usage: master_ip_failover-- command=start | stop | stopssh | status-- orig_master_host=host-- orig_maste
R_ip=ip-orig_master_port=port-new_master_host=host-new_master_ip=ip-new_master_port=port\ n "
}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.