环境

CentOS

Mysql 5.1

前提

安装了EPEL,详细安装步骤请參照

http://blog.csdn.net/robinsonmhj/article/details/36184863

机器列表

机器IP 机器名
192.168.0.135 db1
192.168.0.136 monitor
192.168.0.137 db2
虚拟IP 作用
192.168.0.138 writter
192.168.0.139 reader
192.168.0.140 reader

安装步骤

1. 在db1 和 db2 上安装mysql

yum install mysql-server

2. 改动配置文件

db1 的配置文件

[mysqld]
datadir = /data/mysql
socket=/data/mysql/mysql.sock
user=mysql
<span style="font-size:18px;"><strong>server-id=1</strong></span>
table_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 64M
thread_concurrency = 8
log-bin=mysql-bin
binlog_format = mixed
max_connections=2048
character_set_server=utf8
wait_timeout=1800
interactive_timeout=1800
skip-show-database
skip-name-resolve
tmp_table_size = 512M
max_heap_table_size = 512M
binlog-ignore-db = mysql
replicate-ignore-db = mysql
binlog-ignore-db = information_schema
replicate-ignore-db = information_schema
binlog-ignore-db = performance_schema
replicate-ignore-db = performance_schema
binlog-ignore-db = test
replicate-ignore-db = test
innodb_data_home_dir=/data/mysql/innodb
innodb_data_file_path=ibdata1:2000M;ibdata2:10M:autoextend
innodb_log_group_home_dir=/data/mysql/innodb/log
innodb_file_per_table=1
innodb_buffer_pool_size = 1000M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 100M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 50
default-storage-engine = MyISAM
#default-storage-engine = INNODB [mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid [mysqldump]
quick
max_allowed_packet = 16M
socket=/data/mysql/mysql.sock [mysql]
no-auto-rehash
socket=/data/mysql/mysql.sock

db2 的配置文件

[mysqld]
datadir = /data/mysql
socket=/data/mysql/mysql.sock
user=mysql
<span style="font-size:18px;"><strong>server-id=2</strong></span>
table_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 64M
thread_concurrency = 8
log-bin=mysql-bin
binlog_format = mixed
max_connections=2048
character_set_server=utf8
wait_timeout=1800
interactive_timeout=1800
skip-show-database
skip-name-resolve
tmp_table_size = 512M
max_heap_table_size = 512M
binlog-ignore-db = mysql
replicate-ignore-db = mysql
binlog-ignore-db = information_schema
replicate-ignore-db = information_schema
binlog-ignore-db = performance_schema
replicate-ignore-db = performance_schema
binlog-ignore-db = test
replicate-ignore-db = test
innodb_data_home_dir=/data/mysql/innodb
innodb_data_file_path=ibdata1:2000M;ibdata2:10M:autoextend
innodb_log_group_home_dir=/data/mysql/innodb/log
innodb_file_per_table=1
innodb_buffer_pool_size = 1000M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 100M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 50
default-storage-engine = MyISAM
#default-storage-engine = INNODB [mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid [mysqldump]
quick
max_allowed_packet = 16M
socket=/data/mysql/mysql.sock [mysql]
no-auto-rehash
socket=/data/mysql/mysql.sock

3. 在db1和db2 上分别建立复制,监控用户

    GRANT REPLICATION CLIENT                 ON *.* TO 'mmm_monitor'@'192.168.0.136' IDENTIFIED BY 'monitor';
GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_agent'@'192.168.0.%' IDENTIFIED BY 'agent';
GRANT REPLICATION SLAVE ON *.* TO 'replication'@'192.168.0.%' IDENTIFIED BY 'replication';

4. 把db1和db2互相设置成master和slave

4.1 在db1上运行。mysql命令

CHANGE MASTER TO master_host='192.168.0.137', master_port=3306, master_user='replication',master_password='replication', master_log_file='mysql-bin.000006', master_log_pos=106;
注意:
<span></span><pre name="code" class="html">master_log_file和master_log_pos的值通过例如以下命令察看
在db2上运行例如以下mysql命令 show master status


4.2 在db2上运行,mysql命令

CHANGE MASTER TO master_host='192.168.0.135', master_port=3306, master_user='replication',master_password='replication', master_log_file='mysql-bin.000006', master_log_pos=106;
注意:
<span></span><pre name="code" class="html">master_log_file和master_log_pos的值通过例如以下命令察看
在db1上运行例如以下mysql命令 show master status


5. 在db1和db2上安装mysql-mmm-agent

yum install mysql-mmm-agent*

6. 在monitor上安装mysql-mmm-monitor

yum install mysql-mmm-monitor*



7. 改动配置文件

在db1,db2和monitor上改动

/etc/mysql-mmm/mmm_common.conf。改动内容例如以下

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 replication
replication_password replication
agent_user mmm_agent
agent_password agent
</host> <host db1>
ip 192.168.0.135
mode master
peer db2
</host> <host db2>
ip 192.168.0.137
mode master
peer db1
</host> <role writer>
hosts db1,db2
ips 192.168.0.138
mode exclusive
</role> <role reader>
hosts db1,db2
ips 192.168.0.139,192.168.0.140
mode balanced
</role>

改动配置文件

/etc/mysql-mmm/mmm_agent.conf

db1上的内容例如以下

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.
<span style="font-size:18px;"><strong>this db1</strong></span>

db2上的内容例如以下

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.
<span style="font-size:18px;"><strong>this db2</strong></span>

改动配置monitor文件

/etc/mysql-mmm/mmm_mon.conf,内容例如以下

include mmm_common.conf

<monitor>
ip <span style="font-size:18px;"><strong>192.168.0.136</strong></span>
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 <span style="font-size:18px;"><strong>192.168.0.135,192.168.0.137</strong></span>
auto_set_online 60 # 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 mmm_monitor
monitor_password monitor
</host> debug 0

8.在db1。db2上启动agent

    # cd /etc/init.d/
# chkconfig mysql-mmm-agent on
# service mysql-mmm-agent start

9. 在monitor上启动monitor

    # cd /etc/init.d/
# chkconfig mysql-mmm-monitor on
# service mysql-mmm-monitor start

10. 在monitor上察看

mmm_control -show status

10.2 把一台机器上线

mmm_control set_online db1

10.3 试验

把db1上的mysql停掉 service mysqld stop

察看状态mmm_control -show status。db1上的写ip应该飘到db2上

參考

http://blog.csdn.net/mydeman/article/details/6845567

http://hi.baidu.com/viewehsoitfmyzr/item/5024bec2ef02ccd196445280

CentOS 搭建 Mysql MMM 高可用架构的更多相关文章

  1. Oracle Compute云快速搭建MySQL Keepalived高可用架构

    最近有个客户在测试Oracle Compute云,他们的应用需要使用MySQL数据库,由于是企业级应用一定要考虑高可用架构,因此有需求要在Oracle Compute云上搭建MySQL高可用集群.客户 ...

  2. MySQL集群搭建(3)-MMM高可用架构

    1 MMM 介绍 1.1 简介 MMM 是一套支持双主故障切换以及双主日常管理的第三方软件.MMM 由 Perl 开发,用来管理和监控双主复制,虽然是双主架构,但是业务上同一时间只允许一个节点进行写入 ...

  3. 搭建MySQL MMM高可用

    搭建MMM: 1,安装 agent 节点执行 yum install -y mysql-mmm-agent 2, monitor 节点执行 yum install -y mysql-mmm-monit ...

  4. centos6.6部署mysql mmm高可用架构

    一.环境简述 1.工作逻辑图 2.MySQL-MMM优缺点 优点:高可用性,扩展性好,出现故障自动切换,对于主主同步,在同一时间只提供一台数据库写操作,保证的数据的一致性. 缺点:Monitor节点是 ...

  5. mysql mmm高可用架构设计

    项目概述:搭建主从,双主,安装Perl模块  安装配置mmm软件  测试 硬件环境:4台虚拟PC 软件环境:rehl6.5 MySQL-5.6.26 percona-xtrabackup-2.3.4 ...

  6. 美团点评MySQL数据库高可用架构从MMM到MHA+Zebra以及MHA+Proxy的演进

    本文介绍最近几年美团点评MySQL数据库高可用架构的演进过程,以及我们在开源技术基础上做的一些创新.同时,也和业界其它方案进行综合对比,了解业界在高可用方面的进展,和未来我们的一些规划和展望. MMM ...

  7. (转)基于keepalived搭建MySQL的高可用集群

    基于keepalived搭建MySQL的高可用集群  原文:http://www.cnblogs.com/ivictor/p/5522383.html MySQL的高可用方案一般有如下几种: keep ...

  8. mysql复制(高可用架构方案的基础)

    mysql复制:把一个数据库实例上所有改变复制到另外一个数据库库服务器实例的过程特点:1.没有改变就无所谓复制 ;改变是复制的根本与数据源2.所有的改变:是指可以复制全部改变,也可以复制部分改变 可以 ...

  9. Mysql MMM 高可用

    一.Mysql MMM 高可用概况: mmm_mond  负责所有的监控工作的监控守护进程,决定节点的移除等: mmm_agentd  运行在mysql服务器上的代理守护进程,通过简单远程服务集提供给 ...

随机推荐

  1. Ncomputering 安装及参数设置

    1.加域 2.添加用户:系统属性---远程

  2. 使用java向邮箱发送邮件

    这是我很早之前写的一个工具类,最近在整理自己所学的东西,无意中找到了,就拿出来与大家分享,代码如下: import java.io.ByteArrayOutputStream; import java ...

  3. (一)React再学习

    新公司的技术栈是React,虽然之前对react大概过了一遍,但是自己没有实际落地过项目 再学习一遍react: 一.react全家桶 ·create-react-app ·组件化思维 ·JSX ·开 ...

  4. bzoj4551 [HEOI2016]树

    题目描述 在2016年,佳媛姐姐刚刚学习了树,非常开心.现在他想解决这样一个问题:给定一颗有根树(根为1),有以下 两种操作:1. 标记操作:对某个结点打上标记(在最开始,只有结点1有标记,其他结点均 ...

  5. luogu P2041 分裂游戏(结论题)

    题意 题解 一开始理解错题意了.以为这题不可解.. 其实这题当n>=3时都是无解的 然后n=1,2时的解都给出来了. 推荐一个博客的证明 #include<iostream> #in ...

  6. 从A小程序跳转到B小程序

    从A小程序跳转到B小程序: A小程序 wxml: <navigator target="miniProgram" open-type="navigate" ...

  7. python list set dict的简单应用示例

    list.count(x):返回指定元素x在列表中出现的次数 set(list):将list类型变量转换为set类型,去除重复值 dick:保存键值对 x=[1,2,2,3,3] s1=set(x) ...

  8. java用jxl实现导出execl表格

    //先将需要导出的数据放到list中 //然后将list中的数据放到execl表中 @RequestMapping(params="exportExecl") public Str ...

  9. Building a Space Station POJ 2031 【最小生成树 prim】

    http://poj.org/problem?id=2031 Description You are a member of the space station engineering team, a ...

  10. JavaScript(14)jQuery(JavaScript 库)

    JavaScript 框架(库) JavaScript 高级程序设计(特别是对浏览器差异的复杂处理),通常非常困难也非常耗时.为了应对这些调整,很多的 JavaScript (helper) 库应运而 ...