ITPub博客

首页 > 数据库 > 国内数据库 > OneProxy5.8.1防止单点故障特性试验

OneProxy5.8.1防止单点故障特性试验

原创 国内数据库 作者:yb708 时间:2016-01-31 17:33:00 0 删除 编辑

目前的版本中主要有两个级别的单点故障设计,一个是针对进程级别:通过在启动程序后启动两个进程,其中一个作为守护进程,一个作为对外提供服务的进程,一旦对外提供服务的进程挂掉后,守护进程可以重新启动一个新的进程对外提供服务;另一个是针对主机级别:在两台主机上部署OneProxy,并同时对外提供服务,当一台主机出现问题后,另一台主机上可以提供同样的服务。

以下验证在两台机器上分别部署OneProxy如何设置高可用。

准备步骤:

1、  在测试之前准备了两台linux(redhat5.4)虚拟机(机器1:bogon,IP:10.122.3.73;机器2:bogon_2,IP:10.122.3.69),分别安装了MySQL5.6.27。

2、  按照“1.OneProxy5.8.1新的目录组织结构运行试验.docx”的步骤在两台机器都安装OneProxy 。

3、  在bogon和bogon_2的test数据库中创建测试表t,并分别插入一条记录用于区分,数据如下:

在bogon上:

mysql> select * from t;

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

| a | b     |

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

| 1 | bogon |

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

1 row in set (0.00 sec)

在bogon_2上:

mysql> select * from t;

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

| a | b       |

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

| 1 | bogon_2 |

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

1 row in set (0.00 sec)

测试步骤:

1、  修改配置文件proxy.conf,将两台机器设置成一个group,内容如下:

机器bogon上:

…(其他部分参见OneProxy5.8.1新的目录组织结构运行试验.docx)

proxy-master-addresses.1 = 10.122.3.73:3306@server1

proxy-slave-addresses.1 = 10.122.3.69:3306@server1

…(其他部分参见OneProxy5.8.1新的目录组织结构运行试验.docx)

remote-address         = 10.122.3.69:4041

    address            = 10.122.3.200/eth0:0

机器bogon_2上:

…(其他部分参见OneProxy5.8.1新的目录组织结构运行试验.docx)

proxy-master-addresses.1 = 10.122.3.69:3306@server1

proxy-slave-addresses.1 = 10.122.3.73:3306@server1

…(其他部分参见1.OneProxy5.8.1新的目录组织结构运行试验.docx)

remote-address         = 10.122.3.73:4041

    address            = 10.122.3.200/eth0:0

 

2、  分别在bogon和bogon_2上启动OneProxy,可以发现10.122.3.200被绑定在bogon上,并在bogon和bogon_2上通过vip的地址10.122.3.200的3307端口连接数据库,执行查询命令可以通过vip地址可以正常提供服务,并查询的是bogon上配置文件中设置的数据库:

机器bogon上:

[root@bogon ~]# mysql -h 10.122.3.200 -P 3307 -utest -ptest

Warning: Using a password on the command line interface can be insecure.

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

Your MySQL connection id is 106

Server version: 5.6.27 OneProxy-Agent-5.8.1 (OneXSoft)

 

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.

 

mysql> select * from t;

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

| a | b     |

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

| 1 | bogon |

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

1 row in set (0.00 sec)

机器bogon_2上:

[root@bogon_2 ~]# mysql -h 10.122.3.200 -P 3307 -utest -ptest

Warning: Using a password on the command line interface can be insecure.

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

Your MySQL connection id is 107

Server version: 5.6.27 OneProxy-Agent-5.8.1 (OneXSoft)

 

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.

 

mysql> select * from t;

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

| a | b     |

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

| 1 | bogon |

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

1 row in set (0.00 sec)

3、  停止bogon上的OneProxy,可以发现10.122.3.200自动绑定到了bogon_2上,然后在bogon和bogon_2上通过vip地址10.122.3.200的3307端口连接数据库,执行查询命令仍然可以正常提供服务,并且有一点很有意思的现象,所查询的数据库和上一步OneProxy正常时查询的一样(说明bogon_2上的OneProxy使用的配置文件信息是bogon上的而不是其本身机器上的):

机器bogon上,有一个查询失败后会自动重连到可用服务:

mysql> select * from t;

ERROR 2013 (HY000): Lost connection to MySQL server during query

mysql>

mysql> select * from t;

ERROR 2006 (HY000): MySQL server has gone away

No connection. Trying to reconnect...

Connection id:    105

Current database: *** NONE ***

 

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

| a | b     |

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

| 1 | bogon |

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

1 row in set (0.00 sec)

机器bogon_2上,和bogon一样有一个查询失败后会自动重连到可用服务:

mysql> select * from t;

ERROR 2013 (HY000): Lost connection to MySQL server during query

mysql> select * from t;

ERROR 2006 (HY000): MySQL server has gone away

No connection. Trying to reconnect...

Connection id:    106

Current database: *** NONE ***

 

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

| a | b     |

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

| 1 | bogon |

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

1 row in set (0.02 sec)


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7913676/viewspace-1984861/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-08-07

  • 博文量
    11
  • 访问量
    189326