<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關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題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關(guān)鍵字專題關(guān)鍵字專題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
        當(dāng)前位置: 首頁 - 科技 - 知識百科 - 正文

        HighAvailabilitywithMySQLFabric:PartI_MySQL

        來源:懂視網(wǎng) 責(zé)編:小采 時間:2020-11-09 19:17:39
        文檔

        HighAvailabilitywithMySQLFabric:PartI_MySQL

        HighAvailabilitywithMySQLFabric:PartI_MySQL:In ourprevious post, we introduced the MySQL Fabric utility and said we would dig deeper into it. This post is the first part of our test of MySQL Fabrics High Availability (HA) functionality.Today, well review MySQL Fabrics HA concepts,
        推薦度:
        導(dǎo)讀HighAvailabilitywithMySQLFabric:PartI_MySQL:In ourprevious post, we introduced the MySQL Fabric utility and said we would dig deeper into it. This post is the first part of our test of MySQL Fabrics High Availability (HA) functionality.Today, well review MySQL Fabrics HA concepts,
        In ourprevious post, we introduced the MySQL Fabric utility and said we would dig deeper into it. This post is the first part of our test of MySQL Fabric’s High Availability (HA) functionality.

        Today, we’ll review MySQL Fabric’s HA concepts, and then walk you through the setup of a 3-node cluster with one Primary and two Secondaries, doing a few basic tests with it. In a second post, we will spend more time generating failure scenarios and documenting how Fabric handles them.(MySQL Fabric is an extensible framework to manage large farms of MySQL servers, with support for high-availability and sharding.)

        Before we begin, we recommend you read this postby Oracle’s Mats Kindahl, which, among other things, addresses the issues we raised on our first post. Mats leads the MySQL Fabric team.

        Our lab

        All our tests will be using our test environment with Vagrant (https://github.com/martinarrieta/vagrant-fabric)

        If you want to play with MySQL Fabric, you can have these VMs running in your desktop following the instructions in the README file. If you don’t want full VMs, our colleague Jervin Real created aset of wrapper scriptsthat let you test MySQL Fabric using sandboxes.

        Here is a basic representation of our environment.

        Fabric Lab

        Set up

        To set up MyQSL Fabric without using our Vagrant environment, you can follow theofficial documentation, or check the ansibleplaybooksin our lab repo. If you follow the manual, the only caveat is that whencreating the user, you should either disable binary logging for your session, or use a GRANT statement instead of CREATE USER. You can readhere for more info on why this is the case.

        A description of all the options in the configuration file can be foundhere. For HA tests, the one thing to mention is that, in our experience, the failure detector will only trigger an automatic failover if the value forfailover_intervalin the[failure_tracking]section is greater than 0. Otherwise, failures will be detected and written to the log, but no action will be taken.

        MySQL configuration

        In order to manage a mysqld instance with MySQL Fabric, the following options need to be set in the [mysqld] section of its my.cnf file:

        log_bingtid-mode=ONenforce-gtid-consistencylog_slave_updates
        log_bingtid-mode=ON

        enforce-gtid-consistency

        log_slave_updates

        Additionally, as in any replication setup, you must make sure that all servers have a distinctserver_id.

        When everything is in place, you can setup and start MySQL Fabric with the following commands:

        [vagrant@store ~]$ mysqlfabric manage setup[vagrant@store ~]$ mysqlfabric manage start --daemon

        [vagrant@store~]$mysqlfabricmanagesetup

        [vagrant@store~]$mysqlfabricmanagestart--daemon

        Thesetupcommand creates the database schema used by MySQL Fabric to store information about managed servers, and thestartone, well, starts the daemon. The–daemonoption makes Fabric start as a daemon, logging to a file instead of to standard output. Depending on the port and file name you configured in fabric.cfg, this may need to be run as root.

        While testing, you can make MySQL Fabric reset its state at any time (though itwon’tchange existing node configurations such as replication) by running:

        [vagrant@store ~]$ mysqlfabric manage teardown[vagrant@store ~]$ mysqlfabric manage setup

        [vagrant@store~]$mysqlfabricmanageteardown

        [vagrant@store~]$mysqlfabricmanagesetup

        If you’re using our Vagrant environment, you can run the reinit_cluster.sh scriptfrom your host OS(from the root of the vagrant-fabric repo) to do this for you, and also initialise the datadir of the three instances.

        Creating a High Availability Cluster:

        A High Availability Cluster is a set of servers using the standard Asynchronous MySQL Replication with GTID.

        Creating a group

        The first step is to create the group by running mysqlfabric with this syntax:

        $ mysqlfabric group create 

        $mysqlfabricgroupcreate

        In our example, to create the cluster “mycluster” you can run:

        [vagrant@store ~]$ mysqlfabric group create myclusterProcedure :{ uuid= 605b02fb-a6a1-4a00-8e24-619cad8ec4c7,finished= True,success = True,return= True,activities=}

        [vagrant@store~]$mysqlfabricgroupcreatemycluster

        Procedure:

        {uuid =605b02fb-a6a1-4a00-8e24-619cad8ec4c7,

        finished =True,

        success =True,

        return =True,

        activities =

        }

        Add the servers to the group

        The second step is add the servers to the group. The syntax to add a server to a group is:

        $ mysqlfabric group add  [:port]

        $mysqlfabricgroupadd[:port]

        The port number is optional and only required if distinct from 3306. It is important to mention that the clients that will use this cluster must be able to resolve this host or IP. This is because clients will connect directly both with MySQL Fabric’s XML-PRC server and with the managed mysqld servers. Let’s add the nodes to our group.

        [vagrant@store ~]$ for i in 1 2 3; do mysqlfabric group add mycluster node$i; doneProcedure :{ uuid= 9d65c81c-e28a-437f-b5de-1d47e746a318,finished= True,success = True,return= True,activities=}Procedure :{ uuid= 235a7c34-52a6-40ad-8e30-418dcee28f1e,finished= True,success = True,return= True,activities=}Procedure :{ uuid= 4da3b1c3-87cc-461f-9705-28a59a2a4f67,finished= True,success = True,return= True,activities=}

        [vagrant@store~]$foriin123;domysqlfabricgroupaddmyclusternode$i;done

        Procedure:

        {uuid =9d65c81c-e28a-437f-b5de-1d47e746a318,

        finished =True,

        success =True,

        return =True,

        activities =

        }Procedure:

        {uuid =235a7c34-52a6-40ad-8e30-418dcee28f1e,

        finished =True,

        success =True,

        return =True,

        activities =

        }Procedure:

        {uuid =4da3b1c3-87cc-461f-9705-28a59a2a4f67,

        finished =True,

        success =True,

        return =True,

        activities =

        }

        Promote a node as a master

        Now that we have all our nodes in the group, we have to promote one of them. You can promote one specific node or you can let MySQL Fabric to choose one for you.

        The syntax to promote a specific node is:

        $ mysqlfabric group promote  --slave_uuid=''

        $mysqlfabricgrouppromote--slave_uuid=''

        or to let MySQL Fabric pick one:

        $ mysqlfabric group promote 

        $mysqlfabricgrouppromote

        Let’s do that:

        [vagrant@store ~]$ mysqlfabric group promote myclusterProcedure :{ uuid= c4afd2e7-3864-4b53-84e9-04a40f403ba9,finished= True,success = True,return= True,activities=}

        [vagrant@store~]$mysqlfabricgrouppromotemycluster

        Procedure:

        {uuid =c4afd2e7-3864-4b53-84e9-04a40f403ba9,

        finished =True,

        success =True,

        return =True,

        activities =

        }

        You can then check the health of the group like this:

        [vagrant@store ~]$ mysqlfabric group health myclusterCommand :{ success = Truereturn= {'e245ec83-d889-11e3-86df-0800274fb806': {'status': 'SECONDARY', 'is_alive': True, 'threads': {}}, 'e826d4ab-d889-11e3-86df-0800274fb806': {'status': 'SECONDARY', 'is_alive': True, 'threads': {}}, 'edf2c45b-d889-11e3-86df-0800274fb806': {'status': 'PRIMARY', 'is_alive': True, 'threads': {}}}activities=}

        [vagrant@store~]$mysqlfabricgrouphealthmycluster

        Command:

        {success =True

        return ={'e245ec83-d889-11e3-86df-0800274fb806':{'status':'SECONDARY','is_alive':True,'threads':{}},'e826d4ab-d889-11e3-86df-0800274fb806':{'status':'SECONDARY','is_alive':True,'threads':{}},'edf2c45b-d889-11e3-86df-0800274fb806':{'status':'PRIMARY','is_alive':True,'threads':{}}}

        activities =

        }

        One current limitation of the ‘health’ command is that it only identifies servers by their uuid. To get a list of the servers in a group, along with quick status summary, and their host names, use lookup_servers instead:

        [vagrant@store ~]$ mysqlfabric group lookup_servers myclusterCommand :{ success = Truereturn= [{'status': 'SECONDARY', 'server_uuid': 'e245ec83-d889-11e3-86df-0800274fb806', 'mode': 'READ_ONLY', 'weight': 1.0, 'address': 'node1'}, {'status': 'SECONDARY', 'server_uuid': 'e826d4ab-d889-11e3-86df-0800274fb806', 'mode': 'READ_ONLY', 'weight': 1.0, 'address': 'node2'}, {'status': 'PRIMARY', 'server_uuid': 'edf2c45b-d889-11e3-86df-0800274fb806', 'mode': 'READ_WRITE', 'weight': 1.0, 'address': 'node3'}]activities=}

        [vagrant@store~]$mysqlfabricgrouplookup_serversmycluster

        Command:

        {success =True

        return =[{'status':'SECONDARY','server_uuid':'e245ec83-d889-11e3-86df-0800274fb806','mode':'READ_ONLY','weight':1.0,'address':'node1'},{'status':'SECONDARY','server_uuid':'e826d4ab-d889-11e3-86df-0800274fb806','mode':'READ_ONLY','weight':1.0,'address':'node2'},{'status':'PRIMARY','server_uuid':'edf2c45b-d889-11e3-86df-0800274fb806','mode':'READ_WRITE','weight':1.0,'address':'node3'}]

        activities =

        }

        We sent amergerequest to use a Json string instead of the “print” of the object in the “return” field from the XML-RPC in order to be able to use that information to display the results in a friendly way. In the same merge, we have added the address of the servers in the health command too.

        Failure detection

        Now we have the three lab machines set up in a replication topology of one master (thePRIMARYserver) and two slaves (theSECONDARYones). To make MySQL Fabric start monitoring the group for problems, you need to activate it:

        [vagrant@store ~]$ mysqlfabric group activate myclusterProcedure :{ uuid= 230835fc-6ec4-4b35-b0a9-97944c18e21f,finished= True,success = True,return= True,activities=}

        [vagrant@store~]$mysqlfabricgroupactivatemycluster

        Procedure:

        {uuid =230835fc-6ec4-4b35-b0a9-97944c18e21f,

        finished =True,

        success =True,

        return =True,

        activities =

        }

        Now MySQL Fabric will monitor the group’s servers, and depending on the configuration (remember thefailover_intervalwe mentioned before) it may trigger an automatic failover. But let’s start testing a simpler case, by stopping mysql on one of the secondary nodes:

        [vagrant@node2 ~]$ sudo service mysqld stopStopping mysqld: [OK]

        [vagrant@node2~]$sudoservicemysqldstop

        Stoppingmysqld: [ OK ]

        And checking how MySQL Fabric report’s the group’s health after this:

        [vagrant@store ~]$ mysqlfabric group health myclusterCommand :{ success = Truereturn= {'e245ec83-d889-11e3-86df-0800274fb806': {'status': 'SECONDARY', 'is_alive': True, 'threads': {}}, 'e826d4ab-d889-11e3-86df-0800274fb806': {'status': 'FAULTY', 'is_alive': False, 'threads': {}}, 'edf2c45b-d889-11e3-86df-0800274fb806': {'status': 'PRIMARY', 'is_alive': True, 'threads': {}}}activities=}

        [vagrant@store~]$mysqlfabricgrouphealthmycluster

        Command:

        {success =True

        return ={'e245ec83-d889-11e3-86df-0800274fb806':{'status':'SECONDARY','is_alive':True,'threads':{}},'e826d4ab-d889-11e3-86df-0800274fb806':{'status':'FAULTY','is_alive':False,'threads':{}},'edf2c45b-d889-11e3-86df-0800274fb806':{'status':'PRIMARY','is_alive':True,'threads':{}}}

        activities =

        }

        We can see that MySQL Fabric successfully marks the server as faulty. In our next post we’ll show an example of this by using one of the supported connectors to handle failures in a group, but for now, let’s keep on the DBA/sysadmin side of things, and try to bring the server back online:

        [vagrant@node2 ~]$ sudo service mysqld startStarting mysqld: [OK][vagrant@store ~]$ mysqlfabric group health myclusterCommand :{ success = Truereturn= {'e245ec83-d889-11e3-86df-0800274fb806': {'status': 'SECONDARY', 'is_alive': True, 'threads': {}}, 'e826d4ab-d889-11e3-86df-0800274fb806': {'status': 'FAULTY', 'is_alive': True, 'threads': {}}, 'edf2c45b-d889-11e3-86df-0800274fb806': {'status': 'PRIMARY', 'is_alive': True, 'threads': {}}}activities=}

        [vagrant@node2~]$sudoservicemysqldstart

        Startingmysqld: [ OK ]

        [vagrant@store~]$mysqlfabricgrouphealthmycluster

        Command:

        {success =True

        return ={'e245ec83-d889-11e3-86df-0800274fb806':{'status':'SECONDARY','is_alive':True,'threads':{}},'e826d4ab-d889-11e3-86df-0800274fb806':{'status':'FAULTY','is_alive':True,'threads':{}},'edf2c45b-d889-11e3-86df-0800274fb806':{'status':'PRIMARY','is_alive':True,'threads':{}}}

        activities =

        }

        So the server is back online, but Fabric still considers it faulty. To add the server back into rotation, we need to look at the server commands:

        [vagrant@store ~]$ mysqlfabric help serverCommands available in group 'server' are:server set_weight uuid weight[--synchronous]server lookup_uuid addressserver set_mode uuid mode[--synchronous]server set_status uuid status[--update_only] [--synchronous]

        [vagrant@store~]$mysqlfabrichelpserver

        Commandsavailableingroup'server'are:

        serverset_weightuuidweight [--synchronous]

        serverlookup_uuidaddress

        serverset_modeuuidmode [--synchronous]

        serverset_statusuuidstatus [--update_only][--synchronous]

        The specific command we need isset_status, and in order to add the server back to the group, we need to change it’s status twice: first toSPAREand then back toSECONDARY. You can see what happens if we try to set it toSECONDARYdirectly:

        [vagrant@store ~]$ mysqlfabric server set_status e826d4ab-d889-11e3-86df-0800274fb806 SECONDARYProcedure :{ uuid= 9a6f2273-d206-4fa8-80fb-6bce1e5262c8,finished= True,success = False,return= ServerError: Cannot change server's (e826d4ab-d889-11e3-86df-0800274fb806) status from (FAULTY) to (SECONDARY).,activities=}

        [vagrant@store~]$mysqlfabricserverset_statuse826d4ab-d889-11e3-86df-0800274fb806SECONDARY

        Procedure:

        {uuid =9a6f2273-d206-4fa8-80fb-6bce1e5262c8,

        finished =True,

        success =False,

        return =ServerError:Cannotchangeserver's(e826d4ab-d889-11e3-86df-0800274fb806)statusfrom(FAULTY)to(SECONDARY).,

        activities =

        }

        So let’s try it the right way:

        [vagrant@store ~]$ mysqlfabric server set_status e826d4ab-d889-11e3-86df-0800274fb806 SPAREProcedure :{ uuid= c3a1c244-ea8f-4270-93ed-3f9dfbe879ea,finished= True,success = True,return= True,activities=}[vagrant@store ~]$ mysqlfabric server set_status e826d4ab-d889-11e3-86df-0800274fb806 SECONDARYProcedure :{ uuid= 556f59ec-5556-4225-93c9-b9b29b577061,finished= True,success = True,return= True,activities=}

        [vagrant@store~]$mysqlfabricserverset_statuse826d4ab-d889-11e3-86df-0800274fb806SPARE

        Procedure:

        {uuid =c3a1c244-ea8f-4270-93ed-3f9dfbe879ea,

        finished =True,

        success =True,

        return =True,

        activities =

        }

        [vagrant@store~]$mysqlfabricserverset_statuse826d4ab-d889-11e3-86df-0800274fb806SECONDARY

        Procedure:

        {uuid =556f59ec-5556-4225-93c9-b9b29b577061,

        finished =True,

        success =True,

        return =True,

        activities =

        }

        And check the group’s health again:

        [vagrant@store ~]$ mysqlfabric group health myclusterCommand :{ success = Truereturn= {'e245ec83-d889-11e3-86df-0800274fb806': {'status': 'SECONDARY', 'is_alive': True, 'threads': {}}, 'e826d4ab-d889-11e3-86df-0800274fb806': {'status': 'SECONDARY', 'is_alive': True, 'threads': {}}, 'edf2c45b-d889-11e3-86df-0800274fb806': {'status': 'PRIMARY', 'is_alive': True, 'threads': {}}}activities=}

        [vagrant@store~]$mysqlfabricgrouphealthmycluster

        Command:

        {success =True

        return ={'e245ec83-d889-11e3-86df-0800274fb806':{'status':'SECONDARY','is_alive':True,'threads':{}},'e826d4ab-d889-11e3-86df-0800274fb806':{'status':'SECONDARY','is_alive':True,'threads':{}},'edf2c45b-d889-11e3-86df-0800274fb806':{'status':'PRIMARY','is_alive':True,'threads':{}}}

        activities =

        }

        In our next post, when we discuss how to use the Fabric aware connectors, we’ll also test other failure scenarios like hard VM shutdown and network errors, but for now, let’s try the same thing but on thePRIMARYnode instead:

        [vagrant@node3 ~]$ sudo service mysqld stopStopping mysqld: [OK]

        [vagrant@node3~]$sudoservicemysqldstop

        Stoppingmysqld: [ OK ]

        And let’s check the servers again:

        [vagrant@store ~]$ mysqlfabric group lookup_servers myclusterCommand :{ success = Truereturn= [{'status': 'SECONDARY', 'server_uuid': 'e245ec83-d889-11e3-86df-0800274fb806', 'mode': 'READ_ONLY', 'weight': 1.0, 'address': 'node1'}, {'status': 'PRIMARY', 'server_uuid': 'e826d4ab-d889-11e3-86df-0800274fb806', 'mode': 'READ_WRITE', 'weight': 1.0, 'address': 'node2'}, {'status': 'FAULTY', 'server_uuid': 'edf2c45b-d889-11e3-86df-0800274fb806', 'mode': 'READ_WRITE', 'weight': 1.0, 'address': 'node3'}]activities=}

        [vagrant@store~]$mysqlfabricgrouplookup_serversmycluster

        Command:

        {success =True

        return =[{'status':'SECONDARY','server_uuid':'e245ec83-d889-11e3-86df-0800274fb806','mode':'READ_ONLY','weight':1.0,'address':'node1'},{'status':'PRIMARY','server_uuid':'e826d4ab-d889-11e3-86df-0800274fb806','mode':'READ_WRITE','weight':1.0,'address':'node2'},{'status':'FAULTY','server_uuid':'edf2c45b-d889-11e3-86df-0800274fb806','mode':'READ_WRITE','weight':1.0,'address':'node3'}]

        activities =

        }

        We can see that MySQL Fabric successfully marked node3 asFAULTY, and promoted node2 toPRIMARYto resolve this. Once we start mysqld again on node3, we can add it back asSECONDARYusing the same process of setting it’s status toSPAREfirst, as we did for node2 above.

        Remember that unlessfailover_interval is greater than 0, MySQL Fabric will detect problems in an active group, but it won’t take any automatic action. We think it’s a good thing that the value for this variable in the documentation is 0, so that automatic failover is not enabled by default (if people follow the manual, of course), as even in mature HA solutions likePacemaker, automatic failover is something that’s tricky to get right. But even without this, we believe the main benefit of using MySQL Fabric for promotion is that it takes care of reconfiguring replication for you, which should reduce the risk for error in this process, specially once the project becomes GA.

        What’s next

        In this post we’ve presented a basic replication setup managed by MySQL Fabric and reviewed a couple of failure scenarios, but many questions are left unanswered, among them:

      1. What happens to clients connected with a Fabric aware driver when there is a status change in the cluster?
      2. What happens when the XML-RPC server goes down?
      3. How can we improve its availability?
      4. We’ll try to answer these and other questions in our next post. If you have some questions of your own, please leave them in the comments section and we’ll address them in the next or other posts, depending on the topic.

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

        文檔

        HighAvailabilitywithMySQLFabric:PartI_MySQL

        HighAvailabilitywithMySQLFabric:PartI_MySQL:In ourprevious post, we introduced the MySQL Fabric utility and said we would dig deeper into it. This post is the first part of our test of MySQL Fabrics High Availability (HA) functionality.Today, well review MySQL Fabrics HA concepts,
        推薦度:
        標(biāo)簽: mysql :: available
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 国产综合激情在线亚洲第一页| A级毛片内射免费视频| 成人免费视频网址| 亚洲日本香蕉视频| 一级毛片全部免费播放| 亚洲国产精品无码久久一线| 二个人看的www免费视频| 国产成人精品日本亚洲专区 | 在线观看亚洲专区| 成人免费视频国产| 美女无遮挡免费视频网站| 亚洲а∨天堂久久精品| 一级全免费视频播放| 亚洲精品国产精品乱码不99| 日本免费中文视频| 亚洲精品自产拍在线观看动漫| 99久9在线|免费| 亚洲综合小说另类图片动图| 国产精品公开免费视频| jizz免费观看| 在线观看亚洲一区二区| 最新仑乱免费视频| 免费很黄无遮挡的视频毛片| 亚洲综合另类小说色区| 91福利免费视频| 亚洲熟妇AV乱码在线观看| 亚洲免费在线观看| 十八禁无码免费网站| 亚洲人成77777在线观看网| 全亚洲最新黄色特级网站 | 亚洲精品偷拍视频免费观看| 久久丫精品国产亚洲av不卡| 免费观看黄网站在线播放| 高潮毛片无遮挡高清免费| 亚洲AV综合色区无码另类小说| 国产人成免费视频网站| 国产亚洲精品美女| 亚洲AV人无码综合在线观看 | 天堂亚洲免费视频| 91高清免费国产自产拍2021| 亚洲国产区男人本色|