In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Virtual ip elegant speaking of Failover, there are usually two ways: one is the virtual IP address, and the other is the global configuration file.
MHA does not limit which method to use, but allows users to choose. The way of virtual IP address will involve other software. This article does not repeat the previous article that building mha+keepalive is to control virtual ip through keepalive. This article introduces a way of virtual ip.
Configure virtual ip in the way of ifconfig / sbin/ifconfig eth0:1 192.168.6.66 ifconfig 24
Delete VIP:
/ sbin/ifconfig eth0:1 down found a master_ip_failover script on the Internet to change the VIP in this way:
[root@localhost app1] # more / usr/local/bin/master_ip_online_change_script
#! / 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.6.66 Universe 2400; # Virtual IP
My $key = "1"
My $ssh_start_vip = "/ sbin/ifconfig eth0:$key $vip"
My $ssh_stop_vip = "/ sbin/ifconfig eth0:$key down"
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\" `
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\" `
}
# 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 usage {
"Usage: master_ip_failover-command=start | stop | stopssh | status-- orig_master_host=host-- orig_master_ip=ip-- orig_master_port=port-- new_master_host=host-- new_master_ip=ip-- new_master_port=po
Rt\ n "
}
Copy this script twice to / usr/local/bin, named master_ip_failover and master_ip_online_change_script, respectively
Then remove the following two lines of comments from / etc/app1.cnf:
Master_ip_failover_script=/usr/local/bin/master_ip_failovermaster_ip_online_change_script=/usr/local/bin/master_ip_online_change_script
Experiment
1. Add a vip [root@node2 .ssh] # / sbin/ifconfig eth0:1 192.168.6.66 to the main library
[root@node2 .ssh] # ip a
1: lo: mtu 16436 qdisc noqueue
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 qlen 1000
Link/ether 08:00:27:03:1b:a1 brd ff:ff:ff:ff:ff:ff
Inet 192.168.6.115/24 brd 192.168.6.255 scope global eth0
Inet 192.168.6.66/24 brd 192.168.6.255 scope global secondary eth0:1
Inet6 fe80::a00:27ff:fe03:1ba1/64 scope link
Valid_lft forever preferred_lft forever
two。 Close the main library mysql [root@node2 .ssh] # / etc/init.d/mysqld stop
Stopping mysqld: [OK]
[root@node2 .ssh] # ip a
1: lo: mtu 16436 qdisc noqueue
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 qlen 1000
Link/ether 08:00:27:03:1b:a1 brd ff:ff:ff:ff:ff:ff
Inet 192.168.6.115 brd 24 brd 192.168.6.255 scope global eth0-vip floated away
Inet6 fe80::a00:27ff:fe03:1ba1/64 scope link
Valid_lft forever preferred_lft forever
3 check the ip of newmaster-vip has floated to newmaster [root@node1 ~] # ip a
1: lo: mtu 16436 qdisc noqueue
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 qlen 1000
Link/ether 08:00:27:7a:c6:9c brd ff:ff:ff:ff:ff:ff
Inet 192.168.6.114/24 brd 192.168.6.255 scope global eth0
Inet 192.168.6.66/24 brd 192.168.6.255 scope global secondary eth0:1
Inet6 fe80::a00:27ff:fe7a:c69c/64 scope link
Valid_lft forever preferred_lft forever
(4) reconstruct mysql. Restart mha monitoring 5 turn off 114mysqlfocus VIP float back to 115,
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.