• MySQL(MMM架构使用)


    本案例要求基于普通版的MySQL服务器改造MMM架构,完成以下任务操作:
    启动MMM集群架构
    设置集群中服务器为online状态
    MySQL-MMM架构部署完成后需要启动,数据库端启动mmm-agent进程,管理端启动mmm-monitor进程,启动完成后设置所有数据库主机状态为online。
    实现此案例需要按照如下步骤进行。

    步骤一:启动MMM集群架构

    1)启动mmm-agent进程

    master1操作:
    [root@master1 ~]# /etc/init.d/mysql-mmm-agent start
    Daemon bin: '/usr/sbin/mmm_agentd'
    Daemon pid: '/var/run/mmm_agentd.pid'
    Starting MMM Agent daemon... Ok
    master2操作:
    [root@master2 ~]# /etc/init.d/mysql-mmm-agent start
    Daemon bin: '/usr/sbin/mmm_agentd'
    Daemon pid: '/var/run/mmm_agentd.pid'
    Starting MMM Agent daemon... Ok
    slave1操作:
    [root@master2 ~]# /etc/init.d/mysql-mmm-agent start
    Daemon bin: '/usr/sbin/mmm_agentd'
    Daemon pid: '/var/run/mmm_agentd.pid'
    Starting MMM Agent daemon... Ok
    slave2操作:
    [root@slave2 ~]# /etc/init.d/mysql-mmm-agent start
    Daemon bin: '/usr/sbin/mmm_agentd'
    Daemon pid: '/var/run/mmm_agentd.pid'
    Starting MMM Agent daemon... Ok
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    2)启动mmm-monitor进程

    monitor主机操作:
    [root@monitor ~]# /etc/init.d/mysql-mmm-monitor start
    Daemon bin: '/usr/sbin/mmm_mond'
    Daemon pid: '/var/run/mmm_mond.pid'
    Starting MMM Monitor daemon: Ok
    1
    2
    3
    4
    5
    步骤二:设置集群中服务器为online状态

    控制命令只能在管理端monitor服务器上执行。
    查看当前集群中各服务器状态:
    [root@monitor ~]# mmm_control show
    master1(192.168.4.10) master/AWAITING_RECOVERY. Roles:
    master2(192.168.4.11) master/AWAITING_RECOVERY. Roles:
    slave1(192.168.4.12) slave/AWAITING_RECOVERY. Roles:
    slave2(192.168.4.13) slave/AWAITING_RECOVERY. Roles:
    设置4台数据库主机状态为online:
    [root@monitor ~]# mmm_control set_online master1
    OK: State of 'master1' changed to ONLINE. Now you can wait some time and check its new roles!
    [root@monitor ~]# mmm_control set_online master2
    OK: State of 'master2' changed to ONLINE. Now you can wait some time and check its new roles!
    [root@monitor ~]# mmm_control set_online slave1
    OK: State of 'slave1' changed to ONLINE. Now you can wait some time and check its new roles!
    [root@monitor ~]# mmm_control set_online slave2
    OK: State of 'slave2' changed to ONLINE. Now you can wait some time and check its new roles!
    [root@monitor ~]#
    再次查看当前集群中各服务器状态:
    [root@monitor ~]# mmm_control show
    master1(192.168.4.10) master/ONLINE. Roles: writer(192.168.4.200)
    master2(192.168.4.11) master/ONLINE. Roles:
    slave1(192.168.4.12) slave/ONLINE. Roles: reader(192.168.4.201)
    slave2(192.168.4.13) slave/ONLINE. Roles: reader(192.168.4.202)

    [root@monitor ~]#
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    步骤三:测试MySQL-MMM架构

    1)客户机安装MySQL-client软件包

    [root@client ~]# tar xvf MySQL-5.6.15-1.el6.x86_64.rpm-bundle.tar
    .. ..
    [root@client ~]# rpm -ivh MySQL-client-5.6.15-1.el6.x86_64.rpm
    .. ..
    1
    2
    3
    4
    2)MySQL-MMM虚拟IP访问测试

    [root@client ~]# mysql -h192.168.4.200 -uroot -ppwd123 -e "show databases"
    Warning: Using a password on the command line interface can be insecure.
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | mysql |
    | performance_schema |
    | tarena |
    | test |
    +--------------------+
    [root@client ~]#

    [root@client ~]# mysql -h192.168.4.200 -uroot -ppwd123 -e "show databases"
    Warning: Using a password on the command line interface can be insecure.
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | mysql |
    | performance_schema |
    | tarena |
    | test |
    +--------------------+
    [root@client ~]#

    [root@client ~]# mysql -h192.168.4.202 -uroot -ppwd123 -e "show databases"
    Warning: Using a password on the command line interface can be insecure.
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | mysql |
    | performance_schema |
    | tarena |
    | test |
    +--------------------+
    [root@client ~]#
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    3)主数据库宕机测试
    [

    root@master1 ~]# service mysql stop //停止master1上服务
    Shutting down MySQL.... [确定]
    [root@master1 ~]#

    [root@monitor ~]# mmm_control show //查看集群内服务器状态
    通过输出信息可以看到虚拟IP从master1切换到master2:
    master1(192.168.4.10) master/HARD_OFFLINE. Roles:
    master2(192.168.4.11) master/ONLINE. Roles: writer(192.168.4.200)
    slave1(192.168.4.12) slave/ONLINE. Roles: reader(192.168.4.201)
    slave2(192.168.4.13) slave/ONLINE. Roles: reader(192.168.4.202)
    [root@monitor ~]#

    [root@client ~]# mysql -h192.168.4.200 -uroot -ppwd123 -e "show databases" //访问虚拟IP测试
    Warning: Using a password on the command line interface can be insecure.
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | mysql |
    | performance_schema |
    | tarena |
    | test |
    +--------------------+
    [root@client ~]#
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24

  • 相关阅读:
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
    Evanyou Blog 彩带
  • 原文地址:https://www.cnblogs.com/hyhy904/p/10965824.html
Copyright © 2020-2023  润新知