In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Introduction: 1. MHA is currently a relatively mature solution in terms of high availability of MySQL, which is a highly available software for failover and master-slave promotion under MySQL high availability environment. 2. MHA can complete the failover in a short time and ensure data consistency to the maximum extent to achieve real high availability. 3. MHA is based on mysql protocol. Copy through mysql master-slave or master-master 4. MHA official website: https://code.google.com/p/mysql-master-ha/ software consists of two parts: MHA Manager (relationship node) and MHA Node (data node) 1. MHA Manager can be deployed on a separate machine to manage multiple master-slave clusters. It can also be deployed on a slave node. 2. MHA Node runs on each MySQL server. 3. MHA_Manager will regularly detect the master nodes in the cluster. When master fails, it can automatically upgrade the slave of the latest data to the new master. Then redirecting all other slave to the new master4, MHA combined with semi-synchronous replication can maximize the working principle of data security: 1. Save binary log events (binlog events) from crashed master, identify slave3 with latest updates, relay log (relay log) with application differences to other slave4, application saved binary log event (binlog events) 5 from master, upgrade one slave to new master6, Make other slave connect to new master to copy MHA tool: Manager kit: masterha_check_ssh # check the SSH configuration status of MHA MHA relies heavily on ssh key verification masterha_check_repl # check MySQL replication status masterha_manager # MHA main program masterha_check_status # detect current MHA running status masterha_master_monitor # detect whether master is down masterha_master_switch # manually control failover masterha_conf_host # add or remove configured server information masterha_stop # MHA off Tool Node toolkit: save_binary_logs # saves and copies master's binary log apply _ diff_relay_logs # identifies differential relay log events and applies their differential events to other slavefilter_mysqlbinlog # remove unnecessary ROLLBACK events (MHA no longer uses this tool) purge_relay_logs # clear the relay log (does not block SQL threads) experimental environment: Role ip address MHA_manager 192.168.0.70Master 192.168.0.40Slave 192.168.0.60Slave 192.168.0.10 installation MHA:1, Configure elpe and baseyum source 2, yum-y localinstall mha4mysql-manager-0.55-0.el6.noarch.rpm mha4mysql-node-0.54-0.el6.noarch.rpm# non-managed nodes without installing mha4mysql-manager-0.55-0.el6.noarch.rpm3, configure ssh secret key to verify ssh-keygen # to generate secret key Always enter cat id_rsa.pub > > authorized_keys # copy authorized_keys id_rsa id_rsa.pub to the ~ / .ssh directory of all nodes Note: do not disable password login, otherwise there will be misconfiguration of mysql master / slave (recommended to use mysql5.5 version or above): master configuration: vim / etc/my.cnf # modify configuration file Add the following [mysqld] # find mysqld configuration segment log-bin=mysql-bin # enable binary log relay-log=relay-bin # enable relay log binlog _ format=mixed # use mixed mode binary log server-id= 1 # globally unique server-idinnodb-file-per-table=1 # use single tablespace file Default-storage-engine=InnoDB # use InnoDB storage engine autocommit=0 # to turn off transaction auto-commit skip-name-resolve=1 # turn off hostname anti-decryption relay-log-purge=0 # does not allow automatic cleaning of relay logs Because MHA relies on relay logs to recover data service mysqld restart # restart mysqlmysql > SHOW MASTER STATUS # View the current binary log location +-+-+ | File | Position | +-+-+ | mysql-bin.000004 | # remember the current value +- -+-+ mysql > GRANT REPLICATION SLAVE REPLICATION CLIENT ON *. * TO 'mha'@'192.168.0.%' IDENTIFIED BY' mha' Mysql > GRANT ALL ON *. * TO 'mymha'@'192.168.0.%' IDENTIFIED BY' mymha'; # create MHA monitoring user mysql > FLUSH PRIVILEGES Slave configuration: vim / etc/my.cnf # modify configuration file Add the following content [mysqld] # find mysqld configuration segment log-bin=mysql-bin # enable binary log relay-log=relay-bin # enable relay log binlog _ format=mixed # use mixed mode binary log server-id= 2 # globally unique server-idinnodb-file-per-table=1 # using a single tablespace file default-storage-engine=InnoDB # using the InnoDB storage engine autocommit=0 # turn off transaction auto-commit skip-name-resolve=1 # turn off hostname de-decryption read-only=1 # read-only Invalid for root users (slave node must be set) relay-log-purge=0 # does not allow automatic cleaning of relay logs because MHA relies on relay logs to recover data mysql > CHANGE MASTER TO MASTER_HOST='192.168.0.10',MASTER_USER='mha',MASTER_PASSWORD='mha', MASTER_LOG_FILE='mysql-bin.000004',MASTER_LOG_POS=360,MASTER_PORT=3306 # specify master server mysql > START SLAVE; # start replication thread mysql > SHOW SLAVE STATUS\ G; # View slave server status Slave_IO_Running: Yes # must all be yesSlave_SQL_Running: Yesmysql > SELECT USER,PASSWORD,HOST FROM mysql.user # check whether mha is synchronized successfully MHA configuration: mkdir / etc/mha mkdir / var/log/mha_app1vim / etc/mha/app1.cnf [server default] # MHA working attribute definition (no comments during configuration) manager_workdir=/masterha/app1 # MHA working directory manager_log=/var/log/ Mha_app1/manager.log # MHA log file password=mymha # set MHA monitoring user's password user=mymha # set monitoring user ping_interval=1 # set monitoring master library Health check time remote_workdir=/masterha/app1 # set the save location of the remote mysql when switching occurs repl_password=mha # set the password of the replication user repl_user=mha # set the replication user name ssh_user=root # set the login user name of ssh master_binlog_dir=/usr/local/mysql/data/ # binary Optional parameters for the storage path of log files Scripts need to be written by themselves: shutdown_script=/masterha/scripts/shutdown.sh # close the failed host script (to prevent brain cleavage) after a failure master_ip_failover_script=/masterha/scripts/automatic.sh # set the script to be executed during automatic failover master_ip_online_change_script=/masterha/scripts/manual.sh # set up the script report_script=/masterha/scripts/twili.py to be executed during manual failover # setting alarm script [server1] hostname=192.168.0.40 port=3306 [server2] # Node setting hostname=192.168.0.60 # Host address port=3306 # Port check_repl_delay=0 # to prevent master failure Slave has delay when switching. Candidate_master=1 # is set as candidate master. If it is not set, select the latest data in slave to become master. If it is set, it is recommended to point to the semi-synchronous node [server3] hostname=192.168.0.10 port=3306MHA use: chmod 600 / etc/mha/app1.cnf # set to only root users have permission to this file masterha_check_ssh-- conf=/etc/mha/app1.cnf # check ssh key recognition Whether the certificate is successful-- conf: specify the profile masterha_check_repl-- conf=/etc/mha/app1.cnf # check the success of the mysql replication environment masterha_check_status-- conf=/etc/mha/app1.cnf # check the MHA running status masterha_manager-- conf=/etc/mha/app1.cnf # start MHA
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.