本文整理汇总了Python中mysql.utilities.common.server.Server.flush_logs方法的典型用法代码示例。如果您正苦于以下问题:Python Server.flush_logs方法的具体用法?Python Server.flush_logs怎么用?Python Server.flush_logs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysql.utilities.common.server.Server
的用法示例。
在下文中一共展示了Server.flush_logs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: move_binlogs_from_server
# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import flush_logs [as 别名]
#.........这里部分代码省略.........
binlog_source, binlog_file = os.path.split(binlog_basename)
# Get log_bin_index (available since MySQL 5.6.4).
if srv.check_version_compat(5, 6, 4):
if bin_index:
print(_WARN_MSG_VAL_NOT_REQ_FOR_SERVER.format(
value='bin index', min_version='5.6.4',
var_name='log_bin_index'))
binlog_index = srv.select_variable('log_bin_index')
else:
binlog_index = None
action = _ACTION_SEARCH_INDEX.format(file_type='bin-log')
print(_WARN_MSG_VAR_NOT_AVAILABLE.format(
var_name='log_bin_basename', host=srv.host, port=srv.port,
min_version='5.6.4', action=action))
if verbosity > 0:
print("# log_bin_index: {0}".format(binlog_index))
else:
if bin_basename:
binlog_source, binlog_file = os.path.split(bin_basename)
else:
action = _ACTION_DATADIR_USED.format(file_type='bin-log')
print(_WARN_MSG_VAR_NOT_AVAILABLE.format(
var_name='log_bin_basename', host=srv.host, port=srv.port,
min_version='5.6.2', action=action))
# Get datadir value.
binlog_source = srv.select_variable('datadir')
binlog_file = None
if verbosity > 0:
print("#")
print("# datadir: {0}".format(binlog_source))
binlog_index = bin_index
# Move binlog files.
num_files = _move_binlogs(
binlog_source, destination, LOG_TYPE_BIN, options,
basename=binlog_file, index_file=binlog_index, skip_latest=True)
print("#")
# Flush binary logs to reload server's cache after move.
if not skip_flush and num_files > 0:
# Note: log_type for FLUSH available since MySQL 5.5.3.
if srv.check_version_compat(5, 5, 3):
print(_INFO_MSG_FLUSH_LOGS.format(log_type='binary'))
srv.flush_logs(log_type='BINARY')
else:
print(_WARN_MSG_FLUSH_LOG_TYPE.format(log_type='binary',
host=srv.host,
port=srv.port))
print("#")
if log_type in (LOG_TYPE_RELAY, LOG_TYPE_ALL):
# Get relay_log_basename (available since MySQL 5.6.2).
if srv.check_version_compat(5, 6, 2):
if relay_basename:
print(_WARN_MSG_VAL_NOT_REQ_FOR_SERVER.format(
value='relay basename', min_version='5.6.2',
var_name='relay_log_basename'))
relay_log_basename = srv.select_variable('relay_log_basename')
if verbosity > 0:
print("#")
print("# relay_log_basename: {0}".format(relay_log_basename))
relay_source, relay_file = os.path.split(relay_log_basename)
else:
if relay_basename:
relay_source, relay_file = os.path.split(relay_basename)
else:
action = _ACTION_DATADIR_USED.format(file_type='relay-log')
print(_WARN_MSG_VAR_NOT_AVAILABLE.format(
var_name='relay_log_basename', host=srv.host,
port=srv.port, min_version='5.6.2', action=action))
# Get datadir value.
relay_source = srv.select_variable('datadir')
relay_file = None
if verbosity > 0:
print("#")
print("# datadir: {0}".format(relay_source))
# Get relay_log_index (available for all supported versions).
relay_log_index = srv.select_variable('relay_log_index')
if verbosity > 0:
print("# relay_log_index: {0}".format(relay_log_index))
# Move relay log files.
num_files = _move_binlogs(
relay_source, destination, LOG_TYPE_RELAY, options,
basename=relay_file, index_file=relay_log_index, skip_latest=True)
print("#")
# Flush relay logs to reload server's cache after move.
if not skip_flush and num_files > 0:
# Note: log_type for FLUSH available since MySQL 5.5.3.
if srv.check_version_compat(5, 5, 3):
print(_INFO_MSG_FLUSH_LOGS.format(log_type='relay'))
srv.flush_logs(log_type='RELAY')
else:
print(_WARN_MSG_FLUSH_LOG_TYPE.format(log_type='relay',
host=srv.host,
port=srv.port))
print("#")
print("#...done.\n#")