it运维开发教程,运维管理,因为微不足道,所以值得关注!域名来源:sos 救援 idc 数据中心 所以sos+idc=sosidc.com

mysql高可用mha解决方案02-去哪网采用的

发布:admin2016-3-4 16:24分类: 解决方案

1.2   .主从同步搭建

注意:防火墙需要关闭

创建复制账号(masterslave1(mha新主)

GRANT REPLICATION  SLAVE ON *.*  TO 'repl'@'192.168.127.%'  IDENTIFIED BY 'repl';

flush privileges;

 

查看master binlog  POS点信息

root@(none) 06:47:05>show master status;

+------------------+----------+--------------+------------------+-------------------+

| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |

+------------------+----------+--------------+------------------+-------------------+

| mysql-bin.000004 |      409 |              |                  |                   |

+------------------+----------+--------------+------------------+-------------------+

1 row in set (0.01 sec)

 

建立主从复制(slave01slave02

[root@slave01 ~]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.6.27-75.0-log Percona Server (GPL), Release 75.0, Revision 8bb53b6

 

Copyright (c) 2009-2015 Percona LLC and/or its affiliates

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

root@(none) 07:03:39>CHANGE MASTER TO MASTER_HOST='192.168.127.101',MASTER_PORT=3306,MASTER_USER='repl',MASTER_PASSWORD='repl',MASTER_LOG_FILE='mysql-bin.000004',MASTER_LOG_POS=409;

Query OK, 0 rows affected, 2 warnings (0.05 sec)

 

root@(none) 07:03:41>start slave;

Query OK, 0 rows affected (0.02 sec)

 

查看主从复制

root@(none) 07:03:42>show slave status\G;

*************************** 1. row ***************************

               Slave_IO_State: Waiting for master to send event

                  Master_Host: 192.168.127.101

                  Master_User: repl

                  Master_Port: 3306

                Connect_Retry: 60

              Master_Log_File: mysql-bin.000004

          Read_Master_Log_Pos: 409

               Relay_Log_File: mysqld-relay-bin.000002

                Relay_Log_Pos: 283

        Relay_Master_Log_File: mysql-bin.000004

             Slave_IO_Running: Yes

            Slave_SQL_Running: Yes

              Replicate_Do_DB:

          Replicate_Ignore_DB:

           Replicate_Do_Table:

       Replicate_Ignore_Table:

      Replicate_Wild_Do_Table:

  Replicate_Wild_Ignore_Table:

                   Last_Errno: 0

                   Last_Error:

                 Skip_Counter: 0

          Exec_Master_Log_Pos: 409

              Relay_Log_Space: 457

              Until_Condition: None

               Until_Log_File:

                Until_Log_Pos: 0

           Master_SSL_Allowed: No

           Master_SSL_CA_File:

           Master_SSL_CA_Path:

              Master_SSL_Cert:

            Master_SSL_Cipher:

               Master_SSL_Key:

        Seconds_Behind_Master: 0

Master_SSL_Verify_Server_Cert: No

                Last_IO_Errno: 0

                Last_IO_Error:

               Last_SQL_Errno: 0

               Last_SQL_Error:

  Replicate_Ignore_Server_Ids:

             Master_Server_Id: 101

                  Master_UUID: 8b1cf62d-e063-11e5-84ba-000c2908253f

             Master_Info_File: /data/mysql3306/master.info

                    SQL_Delay: 0

          SQL_Remaining_Delay: NULL

      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it

           Master_Retry_Count: 86400

                  Master_Bind:

      Last_IO_Error_Timestamp:

     Last_SQL_Error_Timestamp:

               Master_SSL_Crl:

           Master_SSL_Crlpath:

           Retrieved_Gtid_Set:

            Executed_Gtid_Set:

                Auto_Position: 0

1 row in set (0.02 sec)

 

ERROR:

No query specified

 

以上主从已经搭建好,下面我们安装与配置MHA

1slave服务器(192.168.127.102,192.168.103)设置read only;

mysql> set global read_only=1;

2)设置relay log清除方式(在每个slave 下)

mysql> set global relay_log_purge=0;

(3)创建监控用户,在所有MYSQL上执行

mysql> grant all privileges on *.* to 'root'@'192.168.127.%' identified by '123456';

mysql>flush privileges;

 

 

4)在slave01(192.168.127.102)上创建复制用户:

mysql> grant replication slave on *.* to 'repl'@'192.168.127.%' identified by 'repl';

mysql>flush privileges;

 

 

温馨提示如有转载或引用以上内容之必要,敬请将本文链接作为出处标注,谢谢合作!

已有 0/17310 人参与

发表评论:

欢迎使用手机扫描访问本站,还可以关注微信哦~