def __call__(self, event, snapshot_fsm, snapshot): LOG.info("Handing-off to mysqldump plugin") datadir = self.mysqld_config['datadir'] # find a mysqld executable to use mysqld_exe = locate_mysqld_exe(self.mysqld_config) self.mysqld_config['log-error'] = 'holland_lvm.log' socket = os.path.join(datadir, 'holland_mysqldump.sock') self.mysqld_config['socket'] = socket # patch up socket in plugin self.mysqldump_plugin.config['mysql:client']['socket'] = socket self.mysqldump_plugin.mysql_config['client']['socket'] = socket # set pidfile (careful to not overwrite current one) self.mysqld_config['pid-file'] = os.path.join(datadir, 'holland_lvm.pid') mycnf_path = os.path.join(datadir, 'my.bootstrap.cnf') # generate a my.cnf to pass to the mysqld bootstrap my_conf = generate_server_config(self.mysqld_config, mycnf_path) # log-bin is disabled to avoid conflict with the normal mysqld process self.mysqldump_plugin.config['mysqldump']['bin-log-position'] = False mysqld = MySQLServer(mysqld_exe, my_conf) mysqld.start(bootstrap=False) LOG.info("Waiting for %s to start", mysqld_exe) try: wait_for_mysqld(self.mysqldump_plugin.mysql_config['client']) LOG.info("%s accepting connections on unix socket %s", mysqld_exe, socket) self.mysqldump_plugin.backup() finally: mysqld.kill(signal.SIGKILL) # DIE DIE DIE mysqld.stop( ) # we dont' really care about the exit code, if mysqldump ran smoothly :)
def __call__(self, event, snapshot_fsm, snapshot): LOG.info("Handing-off to mysqldump plugin") datadir = self.mysqld_config["datadir"] # find a mysqld executable to use mysqld_exe = locate_mysqld_exe(self.mysqld_config) self.mysqld_config["log-error"] = "holland_lvm.log" socket = os.path.join(datadir, "holland_mysqldump.sock") self.mysqld_config["socket"] = socket # patch up socket in plugin self.mysqldump_plugin.config["mysql:client"]["socket"] = socket self.mysqldump_plugin.mysql_config["client"]["socket"] = socket # set pidfile (careful to not overwrite current one) self.mysqld_config["pid-file"] = os.path.join(datadir, "holland_lvm.pid") mycnf_path = os.path.join(datadir, "my.bootstrap.cnf") # generate a my.cnf to pass to the mysqld bootstrap my_conf = generate_server_config(self.mysqld_config, mycnf_path) # log-bin is disabled to avoid conflict with the normal mysqld process self.mysqldump_plugin.config["mysqldump"]["bin-log-position"] = False mysqld = MySQLServer(mysqld_exe, my_conf) mysqld.start(bootstrap=False) LOG.info("Waiting for %s to start", mysqld_exe) try: wait_for_mysqld(self.mysqldump_plugin.mysql_config["client"]) LOG.info("%s accepting connections on unix socket %s", mysqld_exe, socket) self.mysqldump_plugin.backup() finally: mysqld.kill(signal.SIGKILL) # DIE DIE DIE mysqld.stop() # we dont' really care about the exit code, if mysqldump ran smoothly :)
def __call__(self, event, snapshot_fsm, snapshot): LOG.info("Starting InnoDB recovery") mysqld_exe = locate_mysqld_exe(self.mysqld_config) LOG.info("Bootstrapping with %s", mysqld_exe) mycnf_path = os.path.join(self.mysqld_config['datadir'], 'my.innodb_recovery.cnf') self.mysqld_config['log-error'] = 'innodb_recovery.log' my_conf = generate_server_config(self.mysqld_config, mycnf_path) mysqld = MySQLServer(mysqld_exe, my_conf) mysqld.start(bootstrap=True) while mysqld.poll() is None: if signal.SIGINT in snapshot_fsm.sigmgr.pending: mysqld.kill(signal.SIGKILL) time.sleep(0.5) LOG.info("%s has stopped", mysqld_exe) if mysqld.returncode != 0: datadir = self.mysqld_config['datadir'] for line in open(os.path.join(datadir, 'innodb_recovery.log'), 'r'): LOG.error("%s", line.rstrip()) raise BackupError("%s exited with non-zero status (%s) during " "InnoDB recovery" % (mysqld_exe, mysqld.returncode)) else: LOG.info("%s ran successfully", mysqld_exe)