centos下配置mysql mm 步骤


配置mysql

1.GRANT REPLICATION SLAVE ON *.* TO 'replication'@'%' IDENTIFIED BY 'replpassword'; #配置复制账号
2.GRANT REPLICATION CLIENT ON *.* TO 'mmm_monitor'@'%' IDENTIFIED BY 'monpassword'; #配置监控账号
3.GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_agent'@'%' IDENTIFIED BY 'agentpassword'; #配置监控代理账号
4.FLUSH PRIVILEGES; #刷新权限

配置主host

log-bin=mysql-bin
binlog_format=mixed


server-id = 1
replicate-do-db=exam
replicate-ignore-db=
log-slave-updates
slave-skip-errors=all
sync_binlog=1
auto_increment_increment=2
auto_increment_offset=1

master-host = 10.3.1.25
master-user = replication
master-password = replpassword
master-port = 3306


配置slave主机

log-bin=mysql-bin
binlog_format=mixed


server-id = 2
replicate-do-db=exam
replicate-ignore-db=
log-slave-updates
slave-skip-errors=all
sync_binlog=1
auto_increment_increment=2
auto_increment_offset=2

master-host = 10.3.1.17
master-user = replication
master-password = replpassword
master-port = 3306

升级perl到5.12.2-----------此种方法失败

1、wget http://www.cpan.org/src/5.0/perl-5.12.2.tar.gz
2、tar -zxvf perl-5.12.2.tar.gz
3、cd perl-5.12.2
4、./Configure -des -Dprefix=/usr/local/perl -Duseithreads Configure #开启多线程,否则monitor不运行
5、make test
6、make install
7、mv /usr/bin/perl /usr/bin/perl.bak
8、ln -s /usr/local/perl/bin/perl /usr/bin/perl

更新perl模块
cpan -i Algorithm::Diff Class::Singleton DBI DBD::mysql Log::Dispatch Log::Log4perl Mail::Send Net::Ping Proc::Daemon Time::HiRes Params::Validate Net::ARP

安装mmm
1. cd /usr/local/
2. mkdir mmm
3. cd mmm
4. wget http://mysql-mmm.org/_media/:mmm2:mysql-mmm-2.2.1.tar.gz -O mysql-mmm-2.2.1.tar.gz
5. tar -xzvf mysql-mmm-2.2.1.tar.gz
6. cd mysql-mmm-2.2.1
7. make, make install
8. mv /MMM /usr/local/perl/lib/5.12.2/
9. cd /etc/mysql-mmm/
10.ls

------------------------------------- monitor 启动失败,需要perl支持多线程-------
使用 yum 搞定

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
yum install mysql-mmm* -y


11.修改配置文件

10.3.1.17 主数据库,mmm_common.conf:

active_master_role writer


<host default>
cluster_interface eth0

pid_path /var/run/mmm_agentd.pid
bin_path /usr/lib/mysql-mmm/

replication_user replication #对应上面mysql配置时的用户名
replication_password replpassword #对应上面mysql配置时的密码

agent_user mmm_agent #对应上面mysql配置时的用户名
agent_password agentpassword #对应上面mysql配置时的密码
</host>

<host db1>
ip 10.3.1.17 #实际ip
mode master
peer db2
</host>

<host db2>
ip 10.3.1.25 #实际ip
mode master
peer db1
</host>


<role writer>
hosts db1, db2
ips 10.3.1.110 #虚ip,程序调用虚ip,由mmmm负责转向实际ip
mode exclusive
</role>

<role reader>
hosts db1, db2
ips 10.3.1.111,10.3.1.112 #虚ip,程序读取时对应的ip ,这个配置可以用户读写分离
mode balanced
</role>

10.3.1.25,次数据库配置

mmm_common.conf同上

mmm_agent.conf:

include mmm_common.conf
this db2


10.3.1.24,监控器配置

include mmm_common.conf
<monitor>
ip 127.0.0.1
pid_path /var/run/mmm_mond.pid
bin_path /usr/lib/mysql-mmm/
status_path /var/lib/misc/mmm_mond.status
ping_ips 10.3.1.17, 10.3.1.25 #实际ip
</monitor>

<host default>
monitor_user mmm_monitor #对应上面的mysql账号
monitor_password monpassword
</host>
debug 0


启动

10.3.1.17:/etc/init.d/mysql-mmm-agent start
10.3.1.25:/etc/init.d/mysql-mmm-agent start
10.3.1.24:/etc/init.d/mysql-mmm-monitor start

自动启动
/sbin/chkconfig --del mysql-mmm-agent
/sbin/chkconfig --add mysql-mmm-agent


10.3.1.24:

mmm_control set_online db1
mmm_control set_online db2 #保证虚地址生效

mmm_control show

mmm_control checks

17/25需要打开9989端口

 

 

安装完成,测试一下,发现/etc/init.d/mysql-mmm-agent stop后再启动失败,需要重启服务器才能再次启动,没有找到原因,有可能是mmm还不是正式版的原因吧.看样子mmm还不能用于生产环境,回头试一下配置linux heartbeat.

你可能感兴趣的:(centos)