OneProxy5.8.1防止單點故障特性試驗

yb708發表於2016-01-31

目前的版本中主要有兩個級別的單點故障設計,一個是針對程式級別:通過在啟動程式後啟動兩個程式,其中一個作為守護程式,一個作為對外提供服務的程式,一旦對外提供服務的程式掛掉後,守護程式可以重新啟動一個新的程式對外提供服務;另一個是針對主機級別:在兩臺主機上部署OneProxy,並同時對外提供服務,當一臺主機出現問題後,另一臺主機上可以提供同樣的服務。

以下驗證在兩臺機器上分別部署OneProxy如何設定高可用。

準備步驟:

1、  在測試之前準備了兩臺linuxredhat5.4)虛擬機器(機器1bogonIP10.122.3.73;機器2bogon_2IP10.122.3.69),分別安裝了MySQL5.6.27

2、  按照“1.OneProxy5.8.1新的目錄組織結構執行試驗.docx”的步驟在兩臺機器都安裝OneProxy

3、  bogonbogon_2test資料庫中建立測試表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、  分別在bogonbogon_2上啟動OneProxy,可以發現10.122.3.200被繫結在bogon上,並在bogonbogon_2上通過vip的地址10.122.3.2003307埠連線資料庫,執行查詢命令可以通過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上,然後在bogonbogon_2上通過vip地址10.122.3.2003307埠連線資料庫,執行查詢命令仍然可以正常提供服務,並且有一點很有意思的現象,所查詢的資料庫和上一步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部落格 ” ,連結:http://blog.itpub.net/7913676/viewspace-1984861/,如需轉載,請註明出處,否則將追究法律責任。

相關文章