mysqlops.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:ops 作者: xiaomatech 项目源码 文件源码
def get_master_mysql_major_version(instance):
    """ Given an instance, determine the mysql major version for the master
        of the replica set.

    Args:
    instance - a hostaddr object

    Returns - A string similar to '5.5' or '5.6'
   """
    zk = MysqlZookeeper()
    master = zk.get_mysql_instance_from_replica_set(
        instance.get_zk_replica_set()[0], repl_type=REPLICA_ROLE_MASTER)
    try:
        mysql_version = get_global_variables(master)['version'][:3]
    except _mysql_exceptions.OperationalError:
        raise Exception('Could not connect to master server {instance} in '
                        'order to determine MySQL version to launch with. '
                        'Perhaps run this script from there? This is likely '
                        'due to firewall rules.'
                        ''.format(instance=instance.hostname))
    return mysql_version
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号