Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Construction of MHA

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Environmental preparation:

DB:mysql-5.7.16

MHA:mha4mysql-manager-0.56.tar.gz 、 mha4mysql-node-0.56.tar.gz 、 daemontools-0.76.tar.gz

Role ipmonitor 10.99.121.206master 10.99.121.209slave 10.99.121.210slave 10.99.121.213

Master and slave:

Create replication and monitoring users on the master (10.99.121.206)

GRANT REPLICATION SLAVE ON *. * TO 'repluser'@'%' IDENTIFIED BY' 123qweistent grant all privileges on *. * to 'monitor'@'%' identified by' 123qwe`

On the slave (10.99.121.210, 10.99.121.213) configuration

Change master tomaster_host='10.99.121.209',master_port=3306,master_user='repluser',master_password='123qwe',master_log_file='binlog.000002',master_log_pos=1009;set global read_only=on

2, install perl dependency, mha-node on all node

Master slave install epel and perl-DBD-MySQLrpm-ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpmyum install perl-DBD-MySQL-yyum install-y perl-develyum install-y perl-CPANmaster slave install MHA nodetar xf mha4mysql-node-0.56.tar.gzcd mha4mysql-node-0.56perl Makefile.PLmake & & make install

The following script files are generated in the / usr/local/bin directory after the installation is complete:

Apply_diff_relay_logs / / identify differential relay log events and apply their differential events to other slave

Filter_mysqlbinlog / / remove unnecessary ROLLBACK events (MHA no longer uses this tool)

Purge_relay_logs / / clear the relay log (does not block SQL threads)

Save_binary_logs / / Save and copy the binary log of master

3. Install MHA Manager. Hosts in MHA Manager also need to install MHA Node,MHA Manger and rely on perl module.

Rpm-ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpmyum install perl-DBD-MySQL-yyum install-y perl-devel perl-CPANyum install perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager perl-Time-HiRes-ytar xf mha4mysql-node-0.56.tar.gzcd mha4mysql-node-0.56perl Makefile.PLmake & & make installtar xf mha4mysql-manager-0.56.tar.gzcd mha4mysql-manager -0.56perl Makefile.PLmake & & make installcd / apps/mha4mysql-manager-0.56/samples/scriptscp * / usr/local/bin/

4. Configure SSH login without password authentication

Generate on all servers:

Ssh-keygen-t rsa

Log in 10.99.121.206:

Ssh-copy-id-I / root/.ssh/id_rsa.pub root@10.99.121.209ssh-copy-id-I / root/.ssh/id_rsa.pub root@10.99.121.210ssh-copy-id-I / root/.ssh/id_rsa.pub root@10.99.121.213

Log in 10.99.121.209

Ssh-copy-id-I / root/.ssh/id_rsa.pub root@10.99.121.210ssh-copy-id-I / root/.ssh/id_rsa.pub root@10.99.121.213

Log in 10.99.121.210

Ssh-copy-id-I / root/.ssh/id_rsa.pub root@10.99.121.209ssh-copy-id-I / root/.ssh/id_rsa.pub root@10.99.121.213

Log in 10.99.121.213

Ssh-copy-id-I / root/.ssh/id_rsa.pub root@10.99.121.209ssh-copy-id-I / root/.ssh/id_rsa.pub root@10.99.121.210

5, configure MHA (log in to 10.99.121.206)

(1) create a working directory for MHA, and create relevant configuration files (sample configuration files are found in the unzipped directory of the package)

Mkdir-p / etc/masterhacp mha4mysql-manager-0.56/samples/conf/app1.cnf / etc/masterha/

Modify the app1.cnf configuration file. The contents of the modified file are as follows

[server default] manager_workdir=/var/log/masterha/app1manager_log=/var/log/masterha/app1/manager.logmaster_binlog_dir=/data/mysql/mysql_datamaster_ip_failover_script= / usr/local/bin/master_ip_failoverster_ip_online_change_script= / usr/local/bin/master_ip_online_changepassword=123qweuser=monitorping_interval=1remote_workdir=/tmprepl_password=123qwerepl_user=repluserreport_script=/usr/local/bin/send_reportsecondary_check_script= / usr/local/bin/masterha_secondary_check- S lenovo2-s lenovo1-- user=repluser-- master_host=lenovo1-- master_ip=10.99.121.209-- master_port=3306shutdown_script= "" ssh_user= root [server1] hostname=10.99.121.209port= 3306 [server2] hostname=10.99.121.210port=3306candidate_master=1check_repl_delay= 0 [server3] hostname=10.99.121.213port=3306

(2) set the clearing method of relay log (on each slave node)

Mysql-uroot-pLenovo123 set global relay_log_purge=0!-e "set global relay_log_purge=0" mysql-uroot-pLenovo123 chocolate!-e "set global relay_log_purge=0"

6. Check the SSH configuration (operation on the 10.99.121.206 Monitor monitoring node), as follows

[root@lenovo16 masterha] # masterha_check_ssh-- conf=/etc/masterha/app1.cnfThu May 25 16:55:19 2017-[warning] Global configuration file / etc/masterha_default.cnf not found. Skipping.Thu May 25 16:55:19 2017-[info] Reading application default configuration from / etc/masterha/app1.cnf..Thu May 25 16:55:19 2017-[info] Reading server configuration from / etc/masterha/app1.cnf..Thu May 25 16:55:19 2017-[info] Starting SSH connection tests..Thu May 25 16:55:20 2017-[debug] Thu May 25 16:55:19 2017-[debug] Connecting via SSH from root@10.99.121. Thu May 25 16:55:20 2017-[debug] ok.Thu May 25 16:55:20 2017-[debug] Connecting via SSH from root@10.99.121.210 (10.99.121.210) to root@10.99.121.213 (10.99.121.213) to root@10.99.121.213 (10.99.121.213). Thu May 25 16:55 20 2017-[debug] ok.Thu May 25 16:55:20 2017-[debug] Thu May 25 16:55:19 2017-[debug] Connecting via SSH from root@10.99.121.209 (10.99.121.209 Thu May 22) to root@10.99.121.210 (10.99.121.210 Thu May 22) .Thu May 25 16:55:19 2017-[debug] ok.Thu May 25 16:55:19 2017-[debug] Connecting Via SSH from root@10.99.121.209 (10.99.121.209) to root@10.99.121.213 (10.99.121.213). Thu May 25 16:55:20 2017-[debug] ok.Thu May 25 16:55:21 2017-[debug] Thu May 25 16:55:20 2017-[debug] Connecting via SSH from root@10.99.121.213 (10.99.121.213) to root@10 .99.121.209 (10.99.121.209 Thu May 22).. Thu May 25 16:55:20 2017-[debug] ok.Thu May 25 16:55:20 2017-[debug] Connecting via SSH from root@10.99.121.213 (10.99.121.213 ok.Thu May 22) to root@10.99.121.210 (10.99.121.210 ok.Thu May 22).. Thu May 25 16:55:21 2017-[debug] ok.Thu May 25 16: 55:21 2017-[info] All SSH connection tests passed successfully.

7, check the entire replication environment (operation on the 10.99.121.206 Monitor monitoring node), as follows

Masterha_check_repl-conf=/etc/masterha/app1.cnf

If you encounter the following error:

Thu May 25 16:58:30 2017-[info] Connecting to root@10.99.121.210 (10.99.121.210 Connecting to root@10.99.121.210).. Can't exec "mysqlbinlog": No such file or directory at / usr/local/share/perl5/MHA/BinlogManager.pm line 106.mysqlbinlog version command failed with rc 1:0, please verify PATH, LD_LIBRARY_PATH, and client options at / usr/local/bin/apply_diff_relay_logs line 493

That is executed on all mysql databases:

Ln-s / usr/local/mysql/bin/mysqlbinlog / usr/local/bin/mysqlbinlogln-s / usr/local/mysql/bin/mysql / usr/local/bin/mysql

8. Enable MHA Manager monitoring (operation on 10.99.121.206 Monitor monitoring node) as follows

[root@lenovo16 apps] # masterha_check_status-conf=/etc/masterha/app1.cnfapp1 is stopped (2:NOT_RUNNING). [root@lenovo16 apps] # nohup masterha_manager-conf=/etc/masterha/app1.cnf-remove_dead_master_conf-ignore_last_failover

< /dev/null >

/ var/log/masterha/app1/manager.log 2 > & 1 & [1] 18587 [root@lenovo16 apps] # masterha_check_status-- conf=/etc/masterha/app1.cnfapp1 monitoring program is now on initialization phase (10:INITIALIZING_MONITOR). Wait for a while and try checking again. [root@lenovo16 apps] # masterha_check_status-conf=/etc/masterha/app1.cnfapp1 (pid:18587) is running (0:PING_OK), master:10.99.121.209wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gztar-zxvf daemontools-0.76.tar.gzcd admin/daemontools-0.76/package/install

Add-include/ usr/include/errno.h at the end of src/conf-cc

[root@lenovo16 apps] # package/install

Finally, the command directory will be created in admin/daemontools-0.76 and relevant commands will be stored. If there are any commands, we can check them like this:

[root@lenovo16 apps] # ls / apps/admin/daemontools-0.76/commandenvdir fghack pgrphack setlock softlimit svc svscan svstat tai64nlocalenvuidgid multilog readproctitle setuidgid supervise svok svscanboot tai64n

At the same time, a soft connection to the above commands is established under / usr/local/bin to facilitate our execution.

In addition, the monitoring / services directory is created, and there are changes under / etc/inittab:

SV:123456:respawn:/command/svscanboot

It uses init to protect itself.

[root@lenovo16 apps] # mkdir-p / service/masterha_ app1 [root @ lenovo16 apps] # vim / servicecontroller masterhafts app1 / runexamples binding masterha_manager bashexec masterha_manager-- conf=/etc/mha/app1.cnf-- wait_on_monitor_error=60-- wait_on_failover_error=60 > > / var/log/masterha/app1/app1.log 2 > & 1 [root@lenovo16 apps] # chmod 755 / service/masterha_app1/run## start monitoringsvc-u / service/masterha_app1## stop monitoringsvc-d / service/masterha_app1

Let's not start in this way here.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report