Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize MySQL load balancing and failover in Amoeba

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail how to achieve MySQL load balancing and failover in Amoeba. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.

Amoeba (amoeba, read: amoeba) project, focusing on distributed database proxy development. Located between Client and DB Server (s). Transparent to the client. It has load balancing, high availability, sql filtering, read-write separation, routing related query to the target database, and concurrent requests for merging results of multiple databases.

The main solution is:

Reduce the complex multi-database structure brought by data segmentation

Provide segmentation rules and reduce the impact of data segmentation rules on applications

Reduce the number of connections between db and client [@ more@]

1.3 install Amoeba

The Amoeba framework is developed based on JDK1.5 and adopts the features of JDK1.5. Mysql protocol version 10 (later than mysql 4.1) is supported, so using Amoeba requires installation of JDK1.5 or above, and MySQL requires version 4.1 or later.

System and environment version:

Linux version: Linux localhost.localdomain 2.6.9-67.ELsmp # 1 SMP Fri Nov 16 12:48:03 EST 2007 i686 i686 i386 GNU/Linux

JDK version: jdk-6u16-linux-i586-rpm.bin

1. Go to sun's website to download the package jdk1.6.0_16-linux-i586.rpm

two。 Installation: rpm-ivh jdk1.6.0_16-linux-i586.rpm

3. You need to configure environment variables after installation.

Vi / etc/profile

JAVA_HOME=/usr/java/jdk1.6.0_16

JAVA_BIN=/usr/java/jdk1.6.0.16/bin

PATH=$PATH:$JAVA_HOME/bin

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

Export JAVA_HOME JAVA_BIN PATH CLASSPATH

Make it effective.

Source / etc/profile

Note that you need to change the name of jdk to the current version of JDK that you downloaded.

The next step is necessary, otherwise it always calls the jdk1.4 that comes with FC6.

Create a link

# cd / usr/bin

# ln-s-f / usr/local/jdk1.5.0_05/jre/bin/java

# ln-s-f / usr/local/jdk1.5.0_05/bin/javac

Check the java version: java-version

Vi Hello.java

Make up another java Mini Program:

Public class Hello {

Public static void main (String [] args) {

System.out.println ("hello");}

}

> javac Hello.java

> java Hello

The presence of Hello indicates success

After JDK is installed, run amoeba for mysql.

1. Download the latest version of amoeba-mysql-1.0.2-BETA from the amoeba developer blog

two。 Configure amoeba.xml and rule.xml files, refer to relevant materials

3. Change to the amoeba-mysql-1.0.2-BETA directory and enter

>. / bin/amoeba

It's ready (running in the background)

1.4 configure Amoeba

The configuration file for Amoeba is in XML format and is easy to use. There are four main files:

 Amoeba.xml is the main configuration file that configures all data sources and parameters of Amoeba itself.

 rule.xml, configure information for all Query routing rules:

 functionMap.xml, configured to parse the Java implementation class corresponding to the function in Query.

 nullFunctionMap.xml, an implementation class that configures specific functions that need to be used in routing rules.

Please refer to the official documentation for detailed configuration instructions.

1.5 Test the effect of Amoeba on performance

Amoeba needs to analyze MySQL protocol packets, so there is bound to be performance degradation. The following is a test on the performance degradation of Amoeba by comparing stand-alone direct access with stand-alone access through Amoeba.

Only one server is configured for Amoeba. For example, the configuration of Router is as follows

1500

Master1

Master1

Master1

True

Direct access:

Sysbench-num-threads=20-max-requests=10000

-test=oltp-- oltp-read-only=on-- db-ps-mode=disable-- oltp-skip-trx

-mysql-table-engine=innodb-oltp-table-size=100000

-mysql-host=192.168.100.2-mysql-port=3306-- mysql-db=configdb run

OLTP test statistics:

Queries performed:

Read: 140000

Write: 0

Other: 0

Total: 140000

Transactions: 10000 (751.32 per sec.)

Deadlocks: 0 (0.00 per sec.)

Read/write requests: 140000 (10518.52 per sec.)

Other operations: 0 (0.00 per sec.)

Test execution summary:

Total time: 13.3099s

Total number of events: 10000

Total time taken by event execution: 265.8874

Per-request statistics:

Min: 4.61ms

Avg: 26.59ms

Max: 80.70ms

Approx. 95 percentile: 45.12ms

Threads fairness:

Events (avg/stddev): 500.0000amp 7.78

Execution time (avg/stddev): 13.2944amp 0.01

Sysbench-num-threads=20-max-requests=10000

-test=oltp-- oltp-read-only=on-- db-ps-mode=disable-- oltp-skip-trx

-mysql-table-engine=innodb-oltp-table-size=100000

-mysql-host=192.168.100.2-mysql-port=8066-- mysql-db=configdb run

OLTP test statistics:

Queries performed:

Read: 140000

Write: 0

Other: 0

Total: 140000

Transactions: 10000 (303.17 per sec.)

Deadlocks: 0 (0.00 per sec.)

Read/write requests: 140000 (4244.42 per sec.)

Other operations: 0 (0.00 per sec.)

Test execution summary:

Total time: 32.9845s

Total number of events: 10000

Total time taken by event execution: 658.9933

Per-request statistics:

Min: 6.59ms

Avg: 65.90ms

Max: 10229.09ms

Approx. 95 percentile: 109.86ms

Threads fairness:

Events (avg/stddev): 500.0000max 66.18

Execution time (avg/stddev): 32.9497 Universe 0.01

According to the test results, the performance loss of Amoeba is about 60%. If you add in the configuration of rule and functionMap, I believe the performance loss will be even higher. However, Amoeba has high requirements for machine performance. It is believed that there will be a great improvement if Amoeba is independently deployed on a machine with strong performance. In addition, we can also use multiple Amoeba at the same time and use LVS to achieve Amoeba's own load balancing and failover.

This is the end of how to achieve MySQL load balancing and failover in Amoeba. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report