mysql mmm 架构

172.168.10.11  master

172.168.10.12  master

172.168.10.24  slave

两台mysql 互为主,一台充当slave,做好同步功能,这里主要介绍一下mysql-mmm的用法


三台mysql 数据库服务器需要安装:mysql-mmm-agent*,perl-Time-HiRes*

在172.168.10.24  slave 机器上安装mysql-mmm-monitor服务需要安装:mysql-mmm-monitor,perl-Time-HiRes*

rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm



mysql-mmm-monitor配置文件:

include mmm_common.conf
<monitor>
    ip                  127.0.0.1
    pid_path            /var/run/mysql-mmm/mmm_mond.pid
    bin_path            /usr/libexec/mysql-mmm
    status_path         /var/lib/mysql-mmm/mmm_mond.status
    ping_ips      172.168.10.11,172.168.10.12,172.168.10.24
    auto_set_online     30
    # The kill_host_bin does not exist by default, though the monitor will
    # throw a warning about it missing.  See the section 5.10 "Kill Host
    # Functionality" in the PDF documentation.
    #
    # kill_host_bin     /usr/libexec/mysql-mmm/monitor/kill_host
    #
</monitor>
<host default>
    monitor_user        root   #监控帐号每台mysql都需要有这个帐号
    monitor_password    xxx
</host>
debug 0

mmm_common.conf配置文件,monitor添加好后同步到各mysql mmm-agent下

active_master_role      writer
<host default>
    cluster_interface       eth0
    pid_path                /var/run/mysql-mmm/mmm_agentd.pid
    bin_path                /usr/libexec/mysql-mmm/
    replication_user        slave001
    replication_password    123456
    agent_user              root
    agent_password          xxx
</host>
<host db1>
    ip      172.168.10.11
    mode    master
    peer    db2
</host>
<host db2>
    ip      172.168.10.12
    mode    master
    peer    db1
</host>
<host db3>
    ip      172.168.10.24
    mode    slave
</host>
<role writer>
    hosts   db1, db2
    ips     172.168.10.200
    mode    exclusive
    prefer  db1   #添加此选项后每次DB1正常后都会成为writer
</role>
<role reader>
    hosts   db1, db2
    ips     172.168.10.201, 172.168.10.202,172.168.10.203
    mode    balanced
</role>

mysql-mmm-agent 配置文件:


include mmm_common.conf
# The 'this' variable refers to this server.  Proper operation requires
# that 'this' server (db1 by default), as well as all other servers, have the
# proper IP addresses set in mmm_common.conf.
this db2   #

启动mysql 服务,并启动/etc/init.d/mysql-mmm-agentstart

启动/etc/init.d/mysql-mmm-monitorstart 服务

slave db3的主如果出现故障 mon会切换到其它正常的master上


mmm_control 命令用法:

Valid commands are:
    help                              - show this message
   #查看帮助信息
ping                              - ping monitor
#ping监控
show                              - show status
#查看状态信息
checks [<host>|all [<check>|all]] - show checks status
#显示检查状态,包括(ping、mysql、rep_threads、rep_backlog)
set_online <host>                 - set host <host> online
#设置某host为online状态
set_offline <host>                - set host <host> offline
#设置某host为offline状态
mode                              - print current mode.
#打印当前的模式,是ACTIVE、MANUAL、PASSIVE?
#默认ACTIVE模式
set_active                        - switch into active mode.
#更改为active模式
set_manual                        - switch into manual mode.
#更改为manual模式
set_passive                       - switch into passive mode.
#更改为passive模式
    move_role [--force] <role> <host> - move exclusive role <role> to host <host>
       #更改host的模式,比如更改处于slave的mysql数据库角色为write
   (Only use --force if you know what you are doing!)
set_ip <ip> <host>                - set role with ip <ip> to host <host>
#为host设置ip,只有passive模式的时候才允许更改!


你可能感兴趣的:(mysql,数据库,服务器,配置文件)