设为首页 加入收藏

TOP

MySQL MGR集群单主模式的自动搭建和自动化故障修复(四)
2019-09-03 03:39:41 】 浏览:102
Tags:MySQL MGR 集群 单主 模式 自动 建和 自动化 故障 修复
_gtid_value):
                print("skip gtid and restart group replication,skiped gtid is "
                      + slave_gtid_list[-1]["Executed_Gtid_Set"].split(":")[-1].split("-")[0]
                      + ":"+str(slave_executed_skiped_gtid))
                slave_executed_skiped_gtid = slave_executed_gtid_prefix+":"+str(slave_executed_skiped_gtid)
                skip_gtid_on_slave(conn_slave_dict,slave_executed_skiped_gtid)
                time.sleep(10)
                start_group_replication(conn_slave_dict)
                if(get_group_replication_status(conn_slave_dict)[0]["MEMBER_STATE"]=="ONLINE"):
                    print("mgr cluster fixed,back to normal")
                    break
            else:
                start_group_replication(conn_slave_dict)
                if(get_group_replication_status(conn_slave_dict)[0]["MEMBER_STATE"]=="ONLINE"):
                    print("mgr cluster fixed,back to normal")
                break
    elif (group_replication_status[0]['MEMBER_STATE'] == 'ONLINE'):
        print("mgr cluster is normal,nothing to do")
        check_replication_group_members(conn_slave_dict)


'''
reset master
'''
def reset_master(conn_dict):
    try:
        execute_noquery(conn_dict, "reset master;")
    except:
        raise



def install_group_replication_plugin(conn_dict):
    get_plugin_sql = "SELECT name,dl FROM mysql.plugin WHERE name = 'group_replication';"
    install_plugin_sql = '''install plugin group_replication soname 'group_replication.so'; '''
    try:
        result = execute_query(conn_dict, get_plugin_sql)
        if not result:
            execute_noquery(conn_dict, install_plugin_sql)
    except:
        raise



def create_mgr_repl_user(conn_master_dict,user,password):
    try:
        reset_master(conn_master_dict)
        sql_exists_user = '''select user from mysql.user where user = '{0}'; '''.format(user)
        user_list = execute_query(conn_master_dict,sql_exists_user)
        if not user_list:
            create_user_sql = '''create user {0}@'%' identified by '{1}'; '''.format(user,password)
            grant_privilege_sql = '''grant replication slave o

首页 上一页 1 2 3 4 5 6 下一页 尾页 4/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇如何删除MySQL用户帐户 下一篇MySQL使用存储过程插入批量测试数..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目