基于amoeba实现mysql数据库的读写分离/负载均衡
更多博文请关注:没有伞的孩子必须努力奔跑(www.xuchanggang.cn)一、Amoeba的简述:[来自百度百科]Amoeba是一个以MySQL为底层数据存储,并对应用提供MySQL协议接
当前测试环境使用的amoeba软件下载地址:
amoeba参考手册:
amoeba项目代码:
(4).简要原理图:
2.我们这里将amoeba相关软件放在/tmp目录下,这里我们先配置JDK
# 解压JDK软件到/usr/local目录下 [root@centos tmp]# tar -xf jdk-7u15-linux-x64.tar.gz -C /usr/local/ # 进入相应目录,并建立java目录 [root@centos tmp]# cd /usr/local/ [root@centos local]# mkdir java # 将解压出来的内容移到java目录 [root@centos local]# mv jdk1.7.0_15/* java # 设置java环境变量 [root@centos local]# echo 'export JAVA_HOME=/usr/local/java' >> ~/.bashrc [root@centos local]# . ~/.bashrc # 测试jdk是否正确安装 [root@centos local]# java -version # ******************************* # 以下这个方法设置JDK[在下面设置amoeba时,会覆盖,所以这里的配置文件,以最下面amoeba的配置为准] [root@centos java]# echo $JAVA_HOME [root@centos java]# vim /etc/profile # 在末尾添加 export JAVA_HOME=/usr/locla/java export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH [root@centos java]# source /etc/profile # *******************************3.配置amoeba中的dbServer.xml(后端mysql 服务器连接配置)
[root@centos java]# cd /tmp/ # 建立相应amoeba目录 [root@centos tmp]# mkdir /usr/local/amoeba # 将压缩包解压到指定目录 [root@centos tmp]# tar -xf amoeba-mysql-binary-2.2.0.tar.gz -C /usr/local/amoeba [root@centos tmp]# cd /usr/local/amoeba/ [root@centos amoeba]# cd conf/ # 准备修改配置文件 #/* 以下部分为注解 #/* Amoeba总共有7个配置文件,分别如下: #/* Amoeba主配置文件($AMOEBA_HOME/conf/amoeba.xml),用来配置Amoeba服务的基本参数,如Amoeba主机地址、端口、认证方式、用于连接的用户名、密码、线程数、超时时间、其他配置文件的位置等。 #/* 数据库服务器配置文件($AMOEBA_HOME/conf/dbServers.xml),用来存储和配置Amoeba所代理的数据库服务器的信息,如:主机IP、端口、用户名、密码等。 #/* 切分规则配置文件($AMOEBA_HOME/conf/rule.xml),用来配置切分规则。 #/* 数据库函数配置文件($AMOEBA_HOME/conf/functionMap.xml),用来配置数据库函数的处理方法,Amoeba将使用该配置文件中的方法解析数据库函数。 #/* 切分规则函数配置文件($AMOEBA_HOME/conf/ruleFunctionMap.xml),用来配置切分规则中使用的用户自定义函数的处理方法。 #/* 访问规则配置文件($AMOEBA_HOME/conf/access_list.conf),用来授权或禁止某些服务器IP访问Amoeba。 #/* 日志规格配置文件($AMOEBA_HOME/conf/log4j.xml),用来配置Amoeba输出日志的级别和方式。 # 配置后端mysql 服务器连接[dbServer.xml] [root@centos conf]# vim dbServers.xml .........................(省略)
Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



MySQL is suitable for beginners because it is simple to install, powerful and easy to manage data. 1. Simple installation and configuration, suitable for a variety of operating systems. 2. Support basic operations such as creating databases and tables, inserting, querying, updating and deleting data. 3. Provide advanced functions such as JOIN operations and subqueries. 4. Performance can be improved through indexing, query optimization and table partitioning. 5. Support backup, recovery and security measures to ensure data security and consistency.

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

Create a database using Navicat Premium: Connect to the database server and enter the connection parameters. Right-click on the server and select Create Database. Enter the name of the new database and the specified character set and collation. Connect to the new database and create the table in the Object Browser. Right-click on the table and select Insert Data to insert the data.

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

You can create a new MySQL connection in Navicat by following the steps: Open the application and select New Connection (Ctrl N). Select "MySQL" as the connection type. Enter the hostname/IP address, port, username, and password. (Optional) Configure advanced options. Save the connection and enter the connection name.

Recovering deleted rows directly from the database is usually impossible unless there is a backup or transaction rollback mechanism. Key point: Transaction rollback: Execute ROLLBACK before the transaction is committed to recover data. Backup: Regular backup of the database can be used to quickly restore data. Database snapshot: You can create a read-only copy of the database and restore the data after the data is deleted accidentally. Use DELETE statement with caution: Check the conditions carefully to avoid accidentally deleting data. Use the WHERE clause: explicitly specify the data to be deleted. Use the test environment: Test before performing a DELETE operation.

Redis uses a single threaded architecture to provide high performance, simplicity, and consistency. It utilizes I/O multiplexing, event loops, non-blocking I/O, and shared memory to improve concurrency, but with limitations of concurrency limitations, single point of failure, and unsuitable for write-intensive workloads.
