手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

搭建mysql-mmm高可用MySQL集群

[日期:2014-05-25] 来源:Linux社区  作者:jinjianjun [字体:大 中 小]

6.在4台数据库服务器上都指定自己的主数据库服务器

以192.168.10.10为例,配置:

MySQL> change  master  to

    -> master_host="192.168.10.20",

    -> master_user="slave",

    -> master_password="slave",

    -> master_log_file="mysql-20-bin.000001",

    -> master_log_pos=120;

mysql> start slave;

7.测试同步结果

二.在5台数据库服务器上安装 mysql-mmm 软件,另一台服务器192.168.10.50负责监控其余四台数据库服务器

1.先安装依赖包

yum -y install perl-XML-DOM                       

yum -y install perl-XML-DOM-XPath

yum -y install  perl-Class-Singleton    //启动mysql-mmm-montior进程时需要此软件包提供的Singleton类

yum -y install  perl-Params-Validate

yum -y install perl-XML-DOM                       

yum -y install perl-XML-DOM-XPath

yum -y install perl-MailTools

 


rpm -ivh perl-Log-Log4perl-1.26-1.el6.rf.noarch.rpm  //启动mysql-mmm-agent进程时需要此软件包提供的Log-Log4perl 类

 


tar -zxvf Algorithm-Diff-1.1902.tar.gz    //启动mysql-mmm-agent进程时需要此软件包提供的Algorithm-Diff类                                         

cd Algorithm-Diff-1.1902

perl  Makefile.PL

make

make test

make install

 


tar -zxvf Proc-Daemon-0.03.tar.gz        //启动mysql-mmm-agent进程时需要此软件包提供的Daemon类                   

cd Proc-Daemon-0.03                                                                         

perl  Makefile.PL                                                     

make                                                                 

make  test                                                             

make  install 

 


cd Net-ARP-1.0.8                //分配虚拟ip需要安装的包

perl    Makefile.PL

make

make  install   

                                           

2.安装mysql-mmm软件

tar -zxvf mysql-mmm-2.2.1.tar.gz

cd mysql-mmm-2.2.1

make install

 


三.在4台被监控数据库服务器上做授权

1.授权监控用户

grant  replication  client  on *.*  to  monitor@"%" identified by "monitor";

 


2.授权代理用户

grant  replication client,process,super  on *.*  to  agent@"%" identified by "agent";

 


四.所有数据库服务器上编辑配置文件

vim /etc/mysql-mmm/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              slave

        replication_password        slave

 


        agent_user                    agent

        agent_password                agent

 


</host>

 


<host  db10>

        ip                                      192.168.10.10

        mode                                    master

        peer                                    db20

</host>

 


<host db20>

        ip                                      192.168.10.20

        mode                                    master

        peer                                    db10

</host>

 


<host db30>

        ip                                      192.168.10.30

        mode                                    slave

</host>

 


<host db40>

        ip                                      192.168.10.40

        mode                                    slave

</host>

 

 

 

<role writer>

        hosts                                  db10, db20

        ips                                    192.168.10.101      //指定负责写操作数据库服务器使用的虚拟ip

        mode                                    exclusive         

</role>

 


<role reader>

        hosts                                  db20, db30,db40

        ips                                    192.168.10.102, 192.168.10.103, 192.168.10.104                        //指定负责读操作数据库服务器使用的虚拟ip

        mode                                    balanced

</role>

 


可在1台服务器编辑完后,scp到其他服务器/etc/mysql-mmm 目录下

 


五.在4台被监控端配置代理进程的主配置文件 mmm_agent.conf

vim /etc/mysql-mmm/mmm_agent.conf

include mmm_common.conf

this db10                                  //修改成和mmm_common.conf 指定的一致

 


/etc/init.d/mysql-mmm-agent start            //启动代理进程agent

netstat  -tulnp  |  grep  mmm              //默认监听9989端口

 


六、配置监控端192.168.10.50主配置文件 mmm_mon.conf

vim /etc/mysql-mmm/mmm_mon.conf

include mmm_common.conf

<monitor>

        ip                                      192.168.10.50

        pid_path                                /var/run/mmm_mond.pid

        bin_path                                /usr/lib/mysql-mmm/

        status_path                            /var/lib/misc/mmm_mond.status

        ping_ips                                192.168.10.10, 192.168.10.20, 192.168.10.30, 192.168.10.40 //4台数据库服务器的真实ip地址。

</monitor>

 


<host default>

        monitor_user                    monitor

        monitor_password                monitor

</host>

 


debug 0

/etc/init.d/mysql-mmm-monitor  start        //启动监控端的监控进程

netstat  -tulnp  |  grep  mmm                //默认监听9988端口

七.在监控服务器192.168.10.50上查看4台数据库服务器的状态

mmm_control set_online db10

mmm_control set_online db20

mmm_control set_online db30

mmm_control set_online db40

mmm_control show          //查看4台数据库服务器的状态

mmm_control  help          //监控进程命令查看帮助

八.测试mysql-mmm 配置

1.停止192.168.10.10上的数据库服务,再执行mmm_control  show命令,发现192.168.10.20使用虚拟IP 192.168.10.101

2.在从数据库服务器上 查看是否获取到监控主机分配的虚拟ip地址,执行命令ip a或ip addr show

3.分别在2台主数据库服务器上做用户授权:grant all  on  *.*  to  root@"%"  identified by  "123456";

在客户端访问主数据库服务器:mysql  -h192.168.10.101  -uroot  -p123  能够登陆成功说明配置成功

linux
相关资讯       MYSQL集群  MySQL-MMM 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款