<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        FailoverwiththeMySQLUtilities–Part1:mysqlrpladmin_MySQL

        來源:懂視網 責編:小采 時間:2020-11-09 19:32:56
        文檔

        FailoverwiththeMySQLUtilities–Part1:mysqlrpladmin_MySQL

        FailoverwiththeMySQLUtilities–Part1:mysqlrpladmin_MySQL:MySQL Utilitiesare a set of tools provided by Oracle to perform many kinds of administrative tasks. When GTID-replication is enabled, 2 tools can be used for slave promotion:mysqlrpladminandmysqlfailover. We will reviewmysqlrpladmin(version
        推薦度:
        導讀FailoverwiththeMySQLUtilities–Part1:mysqlrpladmin_MySQL:MySQL Utilitiesare a set of tools provided by Oracle to perform many kinds of administrative tasks. When GTID-replication is enabled, 2 tools can be used for slave promotion:mysqlrpladminandmysqlfailover. We will reviewmysqlrpladmin(version

        MySQL Utilitiesare a set of tools provided by Oracle to perform many kinds of administrative tasks. When GTID-replication is enabled, 2 tools can be used for slave promotion:mysqlrpladminandmysqlfailover. We will reviewmysqlrpladmin(version 1.4.3) in this post.

        Summary

      1. mysqlrpladmincan perform manual failover/switchover when GTID-replication is enabled.
      2. You need to have your servers configured with--master-info-repository = TABLEor to add the--rpl-useroption for the tool to work properly.
      3. The check for errant transactions is failing in the current GA version (1.4.3) so be extra careful when using it or watchbug #73110to see when a fix is committed.
      4. There are some limitations, for instance the inability to pre-configure the list of slaves in a configuration file or the inability to check that the tool will work well without actually doing a failover or switchover.
      5. Failover vs switchover

        mysqlrpladmin can help you promote a slave to be the new master when the master goes down and then automate replication reconfiguration after this slave promotion. There are 2 separate scenarios: unplanned promotion (failover) and planned promotion (switchover). Beyond the words, it has implications on the way you have to execute the tool.

        Setup for this test

        To test the tool, our setup will be a master with 2 slaves, all using GTID replication.mysqlrpladmincan show us the current replication topology with thehealthcommand:

        $ mysqlrpladmin --master=root@localhost:13001 --discover-slaves-login=root health# Discovering slaves for master at localhost:13001# Discovering slave at localhost:13002# Found slave: localhost:13002# Discovering slave at localhost:13003# Found slave: localhost:13003# Checking privileges.## Replication Topology Health:+------------+--------+---------+--------+------------+---------+| host | port | role| state| gtid_mode| health|+------------+--------+---------+--------+------------+---------+| localhost| 13001| MASTER| UP | ON | OK|| localhost| 13002| SLAVE | UP | ON | OK|| localhost| 13003| SLAVE | UP | ON | OK|+------------+--------+---------+--------+------------+---------+# ...done.

        $mysqlrpladmin--master=root@localhost:13001--discover-slaves-login=roothealth

        # Discovering slaves for master at localhost:13001

        # Discovering slave at localhost:13002

        # Found slave: localhost:13002

        # Discovering slave at localhost:13003

        # Found slave: localhost:13003

        # Checking privileges.

        #

        # Replication Topology Health:

        +------------+--------+---------+--------+------------+---------+

        |host |port |role |state |gtid_mode |health |

        +------------+--------+---------+--------+------------+---------+

        |localhost |13001 |MASTER |UP |ON |OK |

        |localhost |13002 |SLAVE |UP |ON |OK |

        |localhost |13003 |SLAVE |UP |ON |OK |

        +------------+--------+---------+--------+------------+---------+

        # ...done.

        As you can see, we have to specify how to connect to the master (no surprise) but instead of listing all the slaves, we can let the tool discover them.

        Simple failover scenario

        What will the tool do when performing failover? Essentially we will give it the list of slaves and the list of candidates and it will:

      6. Run a few sanity checks
      7. Elect a candidate to be the new master
      8. Make the candidate as up-to-date as possible by making it a slave of all the other slaves
      9. Configure replication on all the other slaves to make them replicate from the new master
      10. After killing -9 the master, let’s try failover:

        $ mysqlrpladmin --slaves=root:@localhost:13002,root:@localhost:13003 --candidates=root@localhost:13002 failover

        $mysqlrpladmin--slaves=root:@localhost:13002,root:@localhost:13003--candidates=root@localhost:13002failover

        This time, the master is down so the tool has no way to automatically discover the slaves. Thus we have to specify them with the--slavesoption.

        However we get an error:

        # Checking privileges.# Checking privileges on candidates.ERROR: You must specify either the --rpl-user or set all slaves to use --master-info-repository=TABLE.

        # Checking privileges.

        # Checking privileges on candidates.

        ERROR:Youmustspecifyeitherthe--rpl-userorsetallslavestouse--master-info-repository=TABLE.

        The error message is clear, but it would have been nice to have such details when running thehealthcommand (maybe a warning instead of an error). That would allow you to check beforehand that the tool can run smoothly rather than to discover in the middle of an emergency that you have to look at the documentation to find which option is missing.

        Let’s choose to specify the replication user:

        $ mysqlrpladmin --slaves=root:@localhost:13002,root:@localhost:13003 --candidates=root@localhost:13002 --rpl-user=repl:repl failover# Checking privileges.# Checking privileges on candidates.# Performing failover.# Candidate slave localhost:13002 will become the new master.# Checking slaves status (before failover).# Preparing candidate for failover.# Creating replication user if it does not exist.# Stopping slaves.# Performing STOP on all slaves.# Switching slaves to new master.# Disconnecting new master as slave.# Starting slaves.# Performing START on all slaves.# Checking slaves for errors.# Failover complete.## Replication Topology Health:+------------+--------+---------+--------+------------+---------+| host | port | role| state| gtid_mode| health|+------------+--------+---------+--------+------------+---------+| localhost| 13002| MASTER| UP | ON | OK|| localhost| 13003| SLAVE | UP | ON | OK|+------------+--------+---------+--------+------------+---------+# ...done.

        $mysqlrpladmin--slaves=root:@localhost:13002,root:@localhost:13003--candidates=root@localhost:13002--rpl-user=repl:replfailover

        # Checking privileges.

        # Checking privileges on candidates.

        # Performing failover.

        # Candidate slave localhost:13002 will become the new master.

        # Checking slaves status (before failover).

        # Preparing candidate for failover.

        # Creating replication user if it does not exist.

        # Stopping slaves.

        # Performing STOP on all slaves.

        # Switching slaves to new master.

        # Disconnecting new master as slave.

        # Starting slaves.

        # Performing START on all slaves.

        # Checking slaves for errors.

        # Failover complete.

        #

        # Replication Topology Health:

        +------------+--------+---------+--------+------------+---------+

        |host |port |role |state |gtid_mode |health |

        +------------+--------+---------+--------+------------+---------+

        |localhost |13002 |MASTER |UP |ON |OK |

        |localhost |13003 |SLAVE |UP |ON |OK |

        +------------+--------+---------+--------+------------+---------+

        # ...done.

        Simple switchover scenario

        Let’s now restart the old master and configure it as a slave of the new master (by the way, this can be done withmysqlreplicate, another tool from the MySQL Utilities). If we want to promote the old master, we can run:

        $ mysqlrpladmin --master=root@localhost:13002 --new-master=root@localhost:13001 --discover-slaves-login=root --demote-master --rpl-user=repl:repl --quiet switchover# Discovering slave at localhost:13001# Found slave: localhost:13001# Discovering slave at localhost:13003# Found slave: localhost:13003+------------+--------+---------+--------+------------+---------+| host | port | role| state| gtid_mode| health|+------------+--------+---------+--------+------------+---------+| localhost| 13001| MASTER| UP | ON | OK|| localhost| 13002| SLAVE | UP | ON | OK|| localhost| 13003| SLAVE | UP | ON | OK|+------------+--------+---------+--------+------------+---------+

        $mysqlrpladmin--master=root@localhost:13002--new-master=root@localhost:13001--discover-slaves-login=root--demote-master--rpl-user=repl:repl--quietswitchover

        # Discovering slave at localhost:13001

        # Found slave: localhost:13001

        # Discovering slave at localhost:13003

        # Found slave: localhost:13003

        +------------+--------+---------+--------+------------+---------+

        |host |port |role |state |gtid_mode |health |

        +------------+--------+---------+--------+------------+---------+

        |localhost |13001 |MASTER |UP |ON |OK |

        |localhost |13002 |SLAVE |UP |ON |OK |

        |localhost |13003 |SLAVE |UP |ON |OK |

        +------------+--------+---------+--------+------------+---------+

        Notice that the master is available in this case so we can use thediscover-slaves-loginoption. Also notice that we can tune the verbosity of the tool by using--quietor--verboseor even log the output in a file with--log.

        We also used--demote-masterto make the old master a slave of the new master. Without this option, the old master will be isolated from the other nodes.

        Extension points

        In general doing switchover/failover at the database level is one thing but informing the other components of the application that something has changed is most often necessary for the application to keep on working correctly.

        This is where the extension points are handy: you can execute a script before switchover/failover with--exec-beforeand after switchover/failover with--exec-after.

        For instance with these simple scripts:

        # cat /usr/local/bin/check_before#!/bin/bash/usr/local/mysql5619/bin/mysql -uroot -S /tmp/node1.sock -Ee 'SHOW SLAVE STATUS' > /tmp/before# cat /usr/local/bin/check_after#!/bin/bash/usr/local/mysql5619/bin/mysql -uroot -S /tmp/node1.sock -Ee 'SHOW SLAVE STATUS' > /tmp/after

        # cat /usr/local/bin/check_before

        #!/bin/bash

        /usr/local/mysql5619/bin/mysql-uroot-S/tmp/node1.sock-Ee'SHOW SLAVE STATUS'>/tmp/before

        # cat /usr/local/bin/check_after

        #!/bin/bash

        /usr/local/mysql5619/bin/mysql-uroot-S/tmp/node1.sock-Ee'SHOW SLAVE STATUS'>/tmp/after

        We can execute:

        $ mysqlrpladmin --master=root@localhost:13001 --new-master=root@localhost:13002 --discover-slaves-login=root --demote-master --rpl-user=repl:repl --quiet --exec-before=/usr/local/bin/check_before --exec-after=/usr/local/bin/check_after switchover

        $mysqlrpladmin--master=root@localhost:13001--new-master=root@localhost:13002--discover-slaves-login=root--demote-master--rpl-user=repl:repl--quiet--exec-before=/usr/local/bin/check_before--exec-after=/usr/local/bin/check_afterswitchover

        And looking the /tmp/before and /tmp/after, we can see that our scripts have been executed:

        # cat /tmp/before# cat /tmp/after*************************** 1. row *************************** Slave_IO_State: Queueing master event to the relay logMaster_Host: localhostMaster_User: replMaster_Port: 13002[...]

        # cat /tmp/before

        # cat /tmp/after

        ***************************1.row***************************

        Slave_IO_State:Queueingmastereventtotherelaylog

        Master_Host:localhost

        Master_User:repl

        Master_Port:13002

        [...]

        If the external script does not seem to work, using –verbose can be useful to diagnose the issue.

        What about errant transactions?

        We already mentioned that errant transactions can createlots of issueswhen a new master is promoted in a cluster running GTIDs. So the question is: howmysqlrpladminbehaves when there is an errant transaction?

        Let’s create an errant transaction:

        # On localhost:13003mysql> CREATE DATABASE test2;mysql> FLUSH LOGS;mysql> SHOW BINARY LOGS;+------------------+-----------+| Log_name | File_size |+------------------+-----------+| mysql-bin.000001 | 69309 || mysql-bin.000002 | 1237667 || mysql-bin.000003 | 617 || mysql-bin.000004 | 231 |+------------------+-----------+mysql> PURGE BINARY LOGS TO 'mysql-bin.000004';

        # On localhost:13003

        mysql>CREATEDATABASEtest2;

        mysql>FLUSHLOGS;

        mysql>SHOWBINARYLOGS;

        +------------------+-----------+

        |Log_name |File_size|

        +------------------+-----------+

        |mysql-bin.000001| 69309|

        |mysql-bin.000002| 1237667|

        |mysql-bin.000003| 617|

        |mysql-bin.000004| 231|

        +------------------+-----------+

        mysql>PURGEBINARYLOGSTO'mysql-bin.000004';

        and let’s try to promote localhost:13003 as the new master:

        $ mysqlrpladmin --master=root@localhost:13001 --new-master=root@localhost:13003 --discover-slaves-login=root --demote-master --rpl-user=repl:repl --quiet switchover[...]+------------+--------+---------+--------+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| host | port | role| state| gtid_mode| health|+------------+--------+---------+--------+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| localhost| 13003| MASTER| UP | ON | OK|| localhost| 13001| SLAVE | UP | ON | IO thread is not running., Got fatal error 1236 from master when reading data from binary log: 'The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.', Slave has 1 transactions behind master.|| localhost| 13002| SLAVE | UP | ON | IO thread is not running., Got fatal error 1236 from master when reading data from binary log: 'The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.', Slave has 1 transactions behind master.|+------------+--------+---------+--------+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

        $mysqlrpladmin--master=root@localhost:13001--new-master=root@localhost:13003--discover-slaves-login=root--demote-master--rpl-user=repl:repl--quietswitchover

        [...]

        +------------+--------+---------+--------+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

        |host |port |role |state |gtid_mode |health |

        +------------+--------+---------+--------+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

        |localhost |13003 |MASTER |UP |ON |OK |

        |localhost |13001 |SLAVE |UP |ON |IOthreadisnotrunning.,Gotfatalerror1236frommasterwhenreadingdatafrombinarylog:'The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.',Slavehas1transactionsbehindmaster. |

        |localhost |13002 |SLAVE |UP |ON |IOthreadisnotrunning.,Gotfatalerror1236frommasterwhenreadingdatafrombinarylog:'The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.',Slavehas1transactionsbehindmaster. |

        +------------+--------+---------+--------+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

        Oops! Although it is suggested by the documentation, the tool does not check errant transactions. This is a major issue as you cannot run failover/switchover reliably with GTID replication if errant transactions are not correctly detected.

        The documentation suggests errant transactions should be checked and a quick look at the code confirms that, but it does not work! So it has beenreported.

        Some limitations

        Apart from the missing errant transaction check, I also noticed a few limitations:

      11. You cannot use a configuration file listing all the slaves. This becomes boring once you have a large amount of slaves. In such a case, you should write a wrapper script aroundmysqlrpladminto generate the right command for you
      12. The slave election process is either automatic or it relies on the order of the servers given in the--candidatesoption. This is not very sophisticated.
      13. It would be useful to have a –dry-run mode which would validate that everything is configured correctly but without actually failing/switching over. This is something MHA does for instance.
      14. Conclusion

        mysqlrpladminis a very good tool to help you perform manual failover/switchover in a cluster using GTID replication. The main caveat at this point is the failing check for errant transactions, which requires a lot of care before executing the tool.

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        FailoverwiththeMySQLUtilities–Part1:mysqlrpladmin_MySQL

        FailoverwiththeMySQLUtilities–Part1:mysqlrpladmin_MySQL:MySQL Utilitiesare a set of tools provided by Oracle to perform many kinds of administrative tasks. When GTID-replication is enabled, 2 tools can be used for slave promotion:mysqlrpladminandmysqlfailover. We will reviewmysqlrpladmin(version
        推薦度:
        標簽: the mysql with
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 麻豆国产精品免费视频| a级片免费观看视频| 永久免费av无码不卡在线观看| 国产亚洲精品a在线观看app| 国产精品成人69XXX免费视频| 亚洲色偷偷综合亚洲AV伊人| 一区二区三区免费视频播放器| 亚洲午夜无码久久久久| 无码av免费一区二区三区试看| 亚洲麻豆精品果冻传媒| 成人免费AA片在线观看| 亚洲色偷精品一区二区三区| 国产a不卡片精品免费观看| 男女猛烈无遮掩视频免费软件| 国产精品亚洲玖玖玖在线观看| 91在线免费观看| 自怕偷自怕亚洲精品| www.黄色免费网站| 国产综合激情在线亚洲第一页 | 无遮挡国产高潮视频免费观看 | 四虎免费大片aⅴ入口| 免费观看亚洲人成网站| 在线亚洲午夜理论AV大片| 久久免费区一区二区三波多野| 亚洲精品在线免费观看| 啦啦啦www免费视频| 91av免费在线视频| 亚洲2022国产成人精品无码区 | 亚洲精品视频免费在线观看| 一本天堂ⅴ无码亚洲道久久| 亚洲国产一区二区视频网站| 久久精品成人免费看| 久久亚洲国产最新网站| 黑人大战亚洲人精品一区| 美女视频黄的全免费视频网站| 免费国产va视频永久在线观看| 亚洲激情中文字幕| 国产国产成年年人免费看片| 久久久久久免费一区二区三区| 在线观看亚洲AV日韩AV| 人人狠狠综合久久亚洲婷婷|