Amoeba is a distributed Database intermediate agent layer software similar to MySQL proxy, which is an open source Java project developed by Chen Si.

Source: Internet
Author: User
Tags define abstract

Amoeba (amoeba) project is an open source framework, launched in 2008 to launch a amoeba for MySQL software;

This software is dedicated to MySQL's distributed database front-end agent layer, which mainly serves as the SQL routing function when the application layer accesses MySQL, and focuses on the development of the distributed database Proxy layer, which is located between the Client and DB Server (s). transparent to client;

===================================================================

1 Introduction

2 Preparation

2.1 Time synchronization

2.2 Configuring the MySQL master-slave replication architecture

3 Ameoba Installation Configuration

3.1 Installing the configuration JDK

3.2 Installing Ameoba

3.3 Configuring Ameoba

3.4 Use validation

3.5 Late expansion

4 problem Record

===================================================================

1 Introduction

Amoeba (amoeba) project is an open source framework, launched in 2008 to launch a amoeba for MySQL software;

This software is dedicated to MySQL's distributed database front-end agent layer, which mainly serves as the SQL routing function when the application layer accesses MySQL, and focuses on the development of the distributed database Proxy layer, which is located between the Client and DB Server (s). transparent to client;

Load balancing, high availability, SQL filtering, read and write separation, routing-related requests to the target database, multiple databases can be requested concurrently, and results are consolidated;

Through the amoeba you can complete the multi-data source of high availability, load balancing, data slicing function, the current amoeba has been used in many enterprise production lines;

2 Preparation

2.1 Time synchronization

# crontab-e# Dscrip:time sync# CTIME:2014.03.23*/5 * * * */usr/sbin/ntpdate 172.16.0.1 &>/dev/null

2.2 Configuring the MySQL master-slave replication architecture

See the blog "MariaDB master-slave copy"

3 Ameoba Installation Configuration

3.1 Installing the configuration JDK

chmod +x jdk-6u31-linux-x64-rpm.binvi/etc/profile.d/java.sh # Install JDK with bin file    export java_home=/usr/java/latest    Export path= $JAVA _home/bin: $PATH

3.2 Installing Ameoba

Mkdir/usr/local/amoebatar XF amoeba-mysql-binary-2.2.0.tar.gz-c/usr/local/amoeba # Install using a binary program file amoebacd/usr/local/ Amoebabin/amoeba Start # foreground run Nohup/usr/local/amoeba/bin/amoeba start & # background run mysql-h127.0.0.1-uroot-p-p8066 # AMO EBA default listener port is 8066

3.3 Configuring Ameoba

CD/USR/LOCAL/AMOEBA/CONFVI Ameoba.xml # front-end Definition profile # Modify Ameoba front-end listening port <service name= "Amoeba for Mysql" class= " Com.meidusa.amoeba.net.ServerableConnectionManager "> <property name=" Port ">3306</property> # The default port is 8066, modified to 3306, easy to implement the front-end program to connect the database transparency # Modify the authentication information of the connection amoeba interface <property name= "Authenticator" > <bean class= "           Com.meidusa.amoeba.mysql.server.MysqlClientAuthenticator "> <property name=" User ">root</property> <property name= "Password" >mypass</property> # Add login Password # query routing settings <queryrouter class= "Com.meidusa.amoeb A.mysql.parser.mysqlqueryrouter "> <property name=" Ruleloader "> <bean class=" Com.meidusa.amoeb            A.route.tablerulefileloader "> <property name=" rulefile ">${amoeba.home}/conf/rule.xml</property> <property name= "Functionfile" >${amoeba.home}/conf/ruleFunctionMap.xml</property> &LT;/BEAN&G    T </property> <property name= "SqlfunctionfilE ">${amoeba.home}/conf/functionMap.xml</property> <property name=" Lrumapsize ">1500</property > <property name= "Defaultpool" >master</property> # Set Default node <property name= "Writepool" >master< /property> # Set writable node, node definition see Dbservers.xml file <property name= "Readpool" >readservers</property> # Set read-only pool, configurable Multiple slave nodes <property name= "Needparse" >true</property></queryrouter>vi Dbservers.xml # Backend node configuration file # Define abstract server, provide default connection configuration for each back-end MySQL server <dbserver name= "Abstractserver" abstractive= "true" > <factoryconfig class= " Com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory "> <property name=" manager ">${defaultmanager}& lt;/property> <property name= "sendbuffersize" >64</property> <property name= "receivebuffers Ize ">128</property> <property name=" Port ">3406</property> <property name=" schema " ;test</property> <property name= "User ">root</property>         <property name= "password" >magedu</property></factoryconfig># defines the backend MySQL IP address, a master, a slave<dbserver name= "master" parent= "Abstractserver" > < factoryconfig> <property name= "ipAddress" >192.168.0.45</property> </factoryconfig></dbse Rver><dbserver name= "Slave" parent= "Abstractserver" > <factoryConfig> <property name= "Ipaddres S ">192.168.0.46</property> </factoryconfig></dbserver># defines a virtual server group, which is a read-only pool readservers< DBServer name= "Readservers" virtual= "true" > <poolconfig class= "Com.meidusa.amoeba.server.MultipleServerPool" > <property name= "loadbalance" >1</property> <property name= "Poolnames" >master,slave< /property> </poolConfig></dbServer>

3.4 Use validation

To authorize on the main library:

MariaDB [(None)]> grant all on * * to ' root ' @ ' 172.16.%.% ' identified by ' magedu '; Query OK, 0 rows Affected (0.00 sec) MariaDB [(none)]> grant all on * * to ' root ' @ '%mysql.com ' identified by ' magedu '; # The password here should match the database password in dbserver.xml query OK, 0 rows Affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows Affected (0.00 sec)
# login verification [[email protected]l conf]# mysql-h127.0.0.1-uroot-p-p3306enter password:welcome to the MariaDB Monitor. Commands End With; or \g.your MySQL connection ID is 2097086015Server version:5.1.45-mysql-amoeba-proxy-2.2.0 Source distributioncopyright (c) Skysql, Oracle, Ab and others. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement. MySQL [(None)]> Show Master status;+------------------+----------+--------------+------------------+| File | Position | binlog_do_db | binlog_ignore_db |+------------------+----------+--------------+------------------+|      mysql-bin.000030 |              326 |                  | |+------------------+----------+--------------+------------------+1 row in Set (0.00 sec) MySQL [(None)]># read/write verification [[  Email protected] conf]# mysql-h127.0.0.1-uroot-p-p3306enter password:welcome to the MariaDB Monitor. Commands End With; or \g.your MySQL connection ID is 2097086015Server version:5.1.45-mysql-amoeba-proxy-2.2.0 Source Distributioncopyright (c)., Oracle, Skysql Ab and others. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement. MySQL [(None)]> CREATE Database amoeba_test;  Query OK, 1 row affected (0.04 sec) MySQL [(None)]>[[email protected] bin]# mysql-h127.0.0.1-uroot-p-p3406enter  Password:welcome to the MariaDB Monitor. Commands End With; or \g.your MariaDB connection ID is 33Server version:10.0.10-mariadb-log Source distributioncopyright (c) $, Ora CLE, Skysql Ab and others. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement. MariaDB [(None)]> show databases;+--------------------+| Database |+--------------------+| Amoeba_test | | Information_schema | | MySQL | | Performance_schema | | Test |+--------------------+9 rows in Set (0.01 sec) MariaDB [(none)]># log on from the amoeba interface to create the database amoeba_test, and then from the main library Interface to query the database has been created, indicating that the write does fall on the main library node; # to verify that Ameoba is scheduled for read operations, you need to temporarily stopCopy operations from the library, and then update the data on the main library so that the data read from the Ameoba will appear inconsistent; 

3.5 Late expansion

With the MMM dual master replication Architecture +amoeba Agent, it can achieve high availability and high performance for MySQL;

About MMM content to participate in the blog "MySQL Scale Out"

4 problem Record

symptom : Using the mysql-uroot-p-p8066 command always fails to connect to the Ameoba configuration interface, which is always the configuration interface to the MySQL database.

cause : In the test environment, the Ameoba and MySQL main libraries are deployed on the same host, when the Ameoba service is started, even if the-p8066 connection is specified, the MySQL client will default to the recognized socket file (/tmp/ Mysql.sock) connection, the same designation-hlocalhost is the same;

When you use the MySQL command to connect mysqld:

    • When the connection host is localhost or not specified, MySQL will use the UNIX socket connection mode;

    • When the connection host is 127.0.0.1, MySQL will connect by TCP;

workaround : Specify the-h127.0.0.1 connection, i.e. Mysql-h127.0.0.1-uroot-p-p8066

Amoeba is a distributed Database intermediate agent layer software similar to MySQL proxy, which is an open source Java project developed by Chen Si.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.