亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

【Mysql】MHA配置虛擬ip

發布時間:2020-08-10 16:50:55 來源:ITPUB博客 閱讀:328 作者:小亮520cl 欄目:MySQL數據庫

虛擬ip飄逸

  1. 說到Failover,通常有兩種方式:一種是虛擬IP地址,一種是全局配置文件。
  2. MHA并沒有限定使用哪一種方式,而是讓用戶自己選擇,虛擬IP地址的方式會牽扯到其它的軟件,這里就不贅述了
  3. 上篇文章搭建mha+keepalive就是通過keepalive來控制虛擬ip,本片文章在介紹一種虛擬ip的方式

配置虛擬ip

  1. 采用ifconfig的方式
  2. /sbin/ifconfig eth0:1 192.168.6.66/24
刪除VIP:
  1. /sbin/ifconfig eth0:1 down
網上找了一個master_ip_failover腳本就是用此方法更改VIP:
  1. [root@localhost app1]# more /usr/local/bin/master_ip_online_change_script
  2. #!/usr/bin/env perl
  3. use strict;
  4. use warnings FATAL => 'all';

  5. use Getopt::Long;

  6. my (
  7.     $command, $ssh_user, $orig_master_host, $orig_master_ip,
  8.     $orig_master_port, $new_master_host, $new_master_ip, $new_master_port
  9. );

  10. my $vip = '192.168.6.66/24'; # Virtual IP
  11. my $key = "1";
  12. my $ssh_start_vip = "/sbin/ifconfig eth0:$key $vip";
  13. my $ssh_stop_vip = "/sbin/ifconfig eth0:$key down";

  14. GetOptions(
  15.     'command=s' => \$command,
  16.     'ssh_user=s' => \$ssh_user,
  17.     'orig_master_host=s' => \$orig_master_host,
  18.     'orig_master_ip=s' => \$orig_master_ip,
  19.     'orig_master_port=i' => \$orig_master_port,
  20.     'new_master_host=s' => \$new_master_host,
  21.     'new_master_ip=s' => \$new_master_ip,
  22.     'new_master_port=i' => \$new_master_port,
  23. );

  24. exit &main();

  25. sub main {

  26.     print "\n\nIN SCRIPT TEST====$ssh_stop_vip==$ssh_start_vip===\n\n";

  27.     if ( $command eq "stop" || $command eq "stopssh" ) {

  28.         # $orig_master_host, $orig_master_ip, $orig_master_port are passed.
  29.         # If you manage master ip address at global catalog database,
  30.         # invalidate orig_master_ip here.
  31.         my $exit_code = 1;
  32.         eval {
  33.             print "Disabling the VIP on old master: $orig_master_host \n";
  34.             &stop_vip();
  35.             $exit_code = 0;
  36.         };
  37.         if ($@) {
  38.             warn "Got Error: $@\n";
  39.             exit $exit_code;
  40.         }
  41.         exit $exit_code;
  42.     }
  43.     elsif ( $command eq "start" ) {

  44.         # all arguments are passed.
  45.         # If you manage master ip address at global catalog database,
  46.         # activate new_master_ip here.
  47.         # You can also grant write access (create user, set read_only=0, etc) here.
  48.         my $exit_code = 10;
  49.         eval {
  50.             print "Enabling the VIP - $vip on the new master - $new_master_host \n";
  51.             &start_vip();
  52.             $exit_code = 0;
  53.         };
  54.         if ($@) {
  55.             warn $@;
  56.             exit $exit_code;
  57.         }
  58.         exit $exit_code;
  59.     }
  60.     elsif ( $command eq "status" ) {
  61.         print "Checking the Status of the script.. OK \n";
  62.         `ssh $ssh_user\@cluster1 \" $ssh_start_vip \"`;
  63.         exit 0;
  64.     }
  65.     else {
  66.         &usage();
  67.         exit 1;
  68.     }
  69. }

  70. # A simple system call that enable the VIP on the new master
  71. sub start_vip() {
  72.     `ssh $ssh_user\@$new_master_host \" $ssh_start_vip \"`;
  73. }
  74. # A simple system call that disable the VIP on the old_master
  75. sub stop_vip() {
  76.     `ssh $ssh_user\@$orig_master_host \" $ssh_stop_vip \"`;
  77. }

  78. sub usage {
  79.     print
  80.     "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
  81. rt\n";
  82. }

將此腳本復制兩次到/usr/local/bin, 分別命名為master_ip_failover 和master_ip_online_change_script

然后將/etc/app1.cnf 中下面兩行注釋去掉:

master_ip_failover_script=/usr/local/bin/master_ip_failover
master_ip_online_change_script=/usr/local/bin/master_ip_online_change_script


實驗

  1. 1.主庫(115)添加一個vip

  1. [root@node2 .ssh]# /sbin/ifconfig eth0:1 192.168.6.66/24
    [root@node2 .ssh]# ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> 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

  1. 2.關閉主庫mysql

  1. [root@node2 .ssh]# /etc/init.d/mysqld stop
    Stopping mysqld:                                           [  OK  ]
    [root@node2 .ssh]# ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> 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           ---vip飄走了
        inet6 fe80::a00:27ff:fe03:1ba1/64 scope link 
           valid_lft forever preferred_lft forever

  1. 3 查看newmaster(114)的ip                                                    ----vip已飄到new master上了

  1. [root@node1 ~]# ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> 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: <BROADCAST,MULTICAST,UP,LOWER_UP> 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

  2. 4 重構mysql.重啟mha監控
  3. 5 關閉114mysql,vip飄回115上去了




向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

湘潭县| 博罗县| 巩义市| 景宁| 会泽县| 城固县| 上思县| 开化县| 巴林左旗| 岗巴县| 龙山县| 大石桥市| 汉中市| 绩溪县| 廉江市| 张家川| 五大连池市| 通化市| 襄城县| 裕民县| 武乡县| 秀山| 叶城县| 阿拉善左旗| 福泉市| 安多县| 通渭县| 普格县| 宜宾县| 安义县| 临猗县| 新竹县| 新泰市| 准格尔旗| 克拉玛依市| 子长县| 信阳市| 游戏| 福清市| 泸水县| 邮箱|