ó n[Qc@s„dZddlZddlZddlZddlZddlZddlmZm Z ddl m Z ddl m Z m Z ddl mZddlmZddlmZdd lmZmZdd lmZd Zd Zd dZdZdZy.ddlZddlZejej ƒZ!WnnXd„Z"y4ddl#Z#e#j$e#j%e#j&ƒdd„ƒZ(Wndd„Z(nXe"e(ƒej)dej*dej+j,ej-dƒƒdedede.ƒZ/e/j0dddƒe e/ƒe/j0ddddd d!d"d#d$d%dd&ƒe/j0d'd(ddd d)d"d*d$d+d,d+d-d.gdd/ƒe/j0d0ddd d1d"d2d$ddd3ƒe/j0d4dd5d d6dd7ƒe/j0d8ddd d9d"d2d$ddd:ƒe/j0d;dd5d d<dd=ƒe e/e.ƒe e/dƒe/j1ƒ\Z2Z3ee/e2j4e2j5ƒe6e2j7ƒd>krQe/j8d?ƒny)e6e2j9ƒdkrye/j8d@ƒnWne:k rše/j8dAƒnXe2j4dkrºe/j8dBƒne2j5dkrèe2j;dkrèe/j8dCƒne2j<d-kre2j=dkre/j8dDƒnyee2ƒ\Z>Z?Z@Wn)e k rZZAdEGeAjBGHeCdFƒnXx-e?D]%ZDee>eDƒrbe/j8dGƒqbqbWx-e@D]%ZEee>eEƒr’e/j8dHƒq’q’Wie@dI6e2jFdkrÚdJne2jFdK6e2jGdkrùdne2jGdL6e2jHdM6e2jIdN6e2jJdO6e2jKdP6e2jLdQ6e2j;dR6e6e2j9ƒdS6e2j7d!6e2j<d)6e2jMdk dT6e2jMdU6e2jNd66e2jOdV6e2jPdW6e2jQd<6ZRe2jMdk rÝee2jMe2jSƒ rÝe/j8dXƒnejTdYe2jMdZejUd[d\d]eƒy&ee>e?eRƒZVeVjWe2j7ƒWnHek ruZAejXejYeAjBjZd^ƒƒdEGeAjBGHeCdFƒnXeCdƒdS(_s† This file contains the replication slave administration utility. It is used to perform replication operations on one or more slaves. iÿÿÿÿN(t UtilErrort UtilRplError(t add_verbosity(tadd_failover_optionst add_rpl_user(tcheck_server_lists(tcheck_hostname_alias(tparse_failover_connections(t RplCommandst purge_log(t VERSION_FRMs MySQL Utilities - mysqlfailover sDmysqlfailover - automatic replication health monitoring and failovers;%prog --master=root@localhost --discover-slaves-login=root s1--candidates=root@host123:3306,root@host456:3306 s%Y-%m-%d %H:%M:%S %picCsLtjdkr5ddlm}|jj|tƒntjtj|ƒdS(Ntntiÿÿÿÿ(twindll( tostnametctypesR tkernel32tSetConsoleCtrlHandlertTruetsignaltSIGTERM(tfuncR ((s%..\utilities\scripts\mysqlfailover.pytset_signal_handler:scCstjdƒtjdƒdS(Ns&Failover console stopped with SIGTERM.i(tloggingtinfotsystexit(RR((s%..\utilities\scripts\mysqlfailover.pyton_exitFs cCsItjdkr+tjtjtjtƒntj dƒtj dƒdS(Ntposixs&Failover console stopped with SIGTERM.i( R Rttermiost tcsetattrRtstdint TCSADRAINtold_terminal_settingsRRR(RR((s%..\utilities\scripts\mysqlfailover.pyRKs   tversiontprogramit descriptiontusagetadd_help_options--helptactionthelps --intervals-itstoretdesttintervalttypetinttdefaultt15s}interval in seconds for polling the master for failure and reporting health. Default = 15 seconds. Lowest value is 5 seconds.s--failover-modes-ft failover_modetchoicetautotchoicestelecttfailsßaction to take when the master fails. 'auto' = automatically fail to best slave, 'elect' = fail to candidate list or if no candidate meets criteria fail, 'fail' = take no action and stop when master fails. Default = 'auto'.s--exec-fail-checkt exec_failtstrings=name of script to execute on each interval to invoke failovers--forcet store_truetforceskoverride the registration check on master for multiple instances of the console monitoring the same master.s--exec-post-failovertexec_post_failsename of script to execute after failover is complete and the utility has refreshed the health report.s --rediscovert rediscovers_Rediscover slaves on interval. Allows console to detect when slaves have been removed or added.isBThe --interval option requires a value greater than or equal to 5.s5The --timeout option requires a value greater than 0.s/The --timeout option requires an integer value.s%You must specify a master to monitor.sGYou must supply a list of slaves or the --discover-slaves-login option.s8Failover mode = 'elect' reqiures at least one candidate.sERROR:is<The master and one of the slaves are the same host and port.s@The master and one of the candidates are the same host and port.t candidatesitpingt verbositytbeforetaftert fail_checkt max_positiont max_delaytdiscoverttimeoutRtlog_filet post_failtrpl_usersError purging log file.tfilenametleveltformats%%(asctime)s %(levelname)s %(message)stdatefmtt ([t__doc__Rtoptparsetos.pathR RRtmysql.utilities.exceptionRRtmysql.utilities.common.optionsRRRRtmysql.utilities.common.serverRtmysql.utilities.common.topologyRt!mysql.utilities.command.rpl_adminRR tmysql.utilitiesR tNAMEt DESCRIPTIONtUSAGEt _DATE_FORMATt _DATE_LENtttyRt tcgetattrRR!RRt WINFUNCTYPEtc_inttc_uinttNoneRt OptionParserRKtpathtbasenametargvtFalsetparsert add_optiont parse_argstopttargstmastertslavesR-R+terrorREt ValueErrorRDR0R<t master_valt slaves_valtcandidates_valteterrmsgRt slave_valtcand_valR=R>t exec_beforet exec_afterR6RBRCRFR9R:RHR;toptionstlog_aget basicConfigtINFOtrpl_cmdst auto_failovertlogtCRITICALtstrip(((s%..\utilities\scripts\mysqlfailover.pytsà         %                     %