In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the example analysis of keepalived Mysql dual-master hot standby configuration, which is very detailed and has a certain reference value. Interested friends must read it!
Dual master hot backup based on keepalived:
one。 Environment:
OS:CentOS 6.5 X64
DB Version:Percona Mysql 5.7.15-9-log
Path: / app/mysql57
Data file path: / data/mysql57/data
DB1:192.168.213.4
DB2:192.168.213.5
two。 Install the keepalived package (both hosts need to operate)
1. Download the keepalived package
Cd / usr/local/tools
Wget http://www.keepalived.org/software/keepalived-1.2.23.tar.gz
two。 Install the required packages
Yum-y install openssl-devel
3. Install keepalived
Mkdir-pv / app/keepalived
Cd / usr/local/tools
Tar xf keepalived-1.2.23.tar.gz
Cd keepalived-1.2.23
. / configure-- prefix=/app/keepalived/
Make
Make install
4. Configure keepalived
Cp / app/keepalived/etc/keepalived/keepalived.conf / etc/keepalived/keepalived.conf
Cp / app/keepalived/etc/rc.d/init.d/keepalived / etc/init.d/keepalived
Cp / app/keepalived/etc/sysconfig/keepalived / etc/sysconfig/
Cp / app/keepalived/sbin/keepalived / usr/sbin/
Db01 keepalived configuration
Cat / etc/keepalived/keepalived.conf
! Configuration File for keepalived
Global_defs {
Router_id HA_MYSQL
}
Vrrp_script chk_mysql {
Script "/ etc/init.d/mysql57 status"
}
Vrrp_instance VI_1 {
State MASTER
Interface eth0! Virtual IP corresponding interface, that is, the network card number corresponding to the business interface.
Virtual_router_id 51
Priority 105! Weight
Advert_int 1
Nopreempt! Do not seize the position of the current master after launching, even if its weight is lower than your own.
Virtual_ipaddress {
192.168.213.100! VIP
}
Track_script {
Chk_mysql! Enable the script defined by the header to check the status of MySQL
}
}
Virtual_server 192.168.213.100 3306 {
Delay_loop 3
Lb_algo rr
Lb_kind NAT
Persistence_timeout 60
Protocol TCP sorry_server 192.168.213.5 3306! Temporarily use the top of sorry_server after real_server hangs up
Real_server 192.168.213.4 3306 {
Weight 1
TCP_CHECK {
Connect_port 3306
Connect_timeout 3
}
}
}
Db02 keepalived configuration
[root@ORADB-213-5] # cat / etc/keepalived/keepalived.conf
! Configuration File for keepalived
Global_defs {
Router_id HA_MYSQL
}
Vrrp_script chk_mysql {
Script "/ etc/init.d/mysql57 status"
}
Vrrp_instance VI_1 {
State BACKUP
Interface eth0! Virtual IP corresponding interface, that is, the network card number corresponding to the business interface.
Virtual_router_id 51
Priority 100! Weight
Advert_int 1
Nopreempt! Do not seize the position of the current master after launching, even if its weight is lower than your own.
Virtual_ipaddress {
192.168.213.100! VIP
}
Track_script {
Chk_mysql! Enable the script defined by the header to check the status of MySQL
}
}
Virtual_server 192.168.213.100 3306 {
Delay_loop 3
Lb_algo rr
Lb_kind NAT
Persistence_timeout 60
Protocol TCP sorry_server 192.168.213.4 3306! Temporarily use the top of sorry_server after real_server hangs up
Real_server 192.168.213.5 3306 {
Weight 1
TCP_CHECK {
Connect_port 3306
Connect_timeout 3
}
}
}
5. Two DB start keepalived
/ etc/init.d/keepalived start
View VIP
[root@ORA11G-213-4 keepalived-1.2.23] # ip addr
1: lo: mtu 16436 qdisc noqueue state UNKNOWN
Link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
Inet 127.0.0.1/8 scope host lo
Inet6:: 1/128 scope host
Valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
Link/ether 00:0c:29:c7:d5:27 brd ff:ff:ff:ff:ff:ff
Inet 192.168.213.4/24 brd 192.168.213.255 scope global eth0
Inet 192.168.213.100/32 scope global eth0
Inet6 fe80::20c:29ff:fec7:d527/64 scope link
Valid_lft forever preferred_lft forever
test
[root@ORA11G-213-4 keepalived-1.2.23] # mysql-unetdata-pnetdata-h 192.168.213.100
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with; or\ g.
Your MySQL connection id is 2881
Server version: 5.7.15-9-log Source distribution
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.
Netdata@192.168.213.100 23:41: [(none)] > system ifconfig
Eth0 Link encap:Ethernet HWaddr 00:0C:29:C7:D5:27
Inet addr:192.168.213.4 Bcast:192.168.213.255 Mask:255.255.255.0
Inet6 addr: fe80::20c:29ff:fec7:d527/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:156643 errors:0 dropped:0 overruns:0 frame:0
TX packets:191173 errors:0 dropped:0 overruns:0 carrier:0
Collisions:0 txqueuelen:1000
RX bytes:39459924 (37.6 MiB) TX bytes:31911844 (30.4 MiB)
Lo Link encap:Local Loopback
Inet addr:127.0.0.1 Mask:255.0.0.0
Inet6 addr: 1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:17378 errors:0 dropped:0 overruns:0 frame:0
TX packets:17378 errors:0 dropped:0 overruns:0 carrier:0
Collisions:0 txqueuelen:0
RX bytes:1002566 (979.0 KiB) TX bytes:1002566 (979.0 KiB)
Stop the db01.
[root@ORA11G-213-4 keepalived-1.2.23] # / etc/init.d/mysql57 stop
Shutting down MySQL (Percona Server). SUCCESS!
View db02
[root@ORADB-213-5] # ip addr
1: lo: mtu 16436 qdisc noqueue state UNKNOWN
Link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
Inet 127.0.0.1/8 scope host lo
Inet6:: 1/128 scope host
Valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
Link/ether 00:0c:29:63:54:39 brd ff:ff:ff:ff:ff:ff
Inet 192.168.213.5/24 brd 192.168.213.255 scope global eth0
Inet 192.168.213.100/32 scope global eth0
Inet6 fe80::20c:29ff:fe63:5439/64 scope link
Valid_lft forever preferred_lft forever
The above is all the contents of the article "sample Analysis of keepalived Mysql dual-master Hot standby configuration". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.