MySQL Middle tier Atlas

Source: Internet
Author: User
Tags lua

Atlas is a MySQL protocol-based data mid-tier project developed and maintained by Qihoo, a web platform infrastructure team. It is based on MySQL's official launch of the Mysql-proxy 0.8.2 version, which modifies a large number of bugs and adds many feature features. At present, the project has been widely used within 360 companies, many MySQL services have been connected to the Atlas platform, the number of read and write requests per day up to billions of.

main functions:
* Read/write separation
* Load Balancing from library
* IP Filtering
* Black and white list of SQL statements
* Automatic sub-table

Q & A
-------------------
Q: are multiple character sets supported?
A: This is our first improvement to the original mysql-proxy, it is necessary to meet the national conditions

Q: The automatic reading and writing separation is good, but sometimes I want to read it immediately after writing, in case of master-slave synchronization delay how to do?
Add/*master*/before A:sql statement to force a read request to the main library

Q: Does the read operation affect the main library outage?
A: Not in Atlas! Can ask such questions, stating that you have used the official mysql-proxy, it is regrettable that the official version did not solve the problem

Q: Does detecting back-end DB status block normal requests?
A: No, the detection thread in Atlas is detected asynchronously and does not block the main process even if there is db outage. There is nothing unusual in Atlas that will block the main process! Ditto, the official version will disappoint you.

Q: Want to offline a db, do not want to stop MySQL server, how to do?
A: You can manually up and down the backend DB via the management interface, and Atlas will prioritize the administrator's wishes

Q: Want to add a db to the cluster, do not want to affect the normal access to the line can?
A: Easy to implement through the management interface

Q: What are the improvements to Atlas compared to the official mysql-proxy?
A: This is a difficult question to answer, performance, stability, reliability, maintainability, we have made dozens of improvements, the following will try to list some of the larger changes

VS official Mysql-proxy
-------------------
1. Change all LUA code in the main process to a pure C implementation, LUA is used only in the management interface
2. Overriding the network model, threading model
3. Realize the true meaning of the connection pool
4. Optimized lock mechanism, dozens of times times performance improvement
......

Attached name Source:
Atlas, the giant of the two-shoulder sky in Greek mythology, the brother of Prometheus, one of the tallest and strongest gods, was punished for the defeat of Zeus. We expect this system to be able to pedal back-end db and prop up a day for front-end applications.

Ii. configuration file Examples
-------------------
[Mysql-proxy] #不需要改
Plugins = admin, proxy #Atlas加载的模块名称, do not need to change

Admin-username = User #管理接口的用户名
Admin-password = pwd #管理接口的密码
Admin-lua-script =/usr/local/mysql-proxy/lib/mysql-proxy/lua/admin.lua #实现管理接口的Lua脚本所在路径

proxy-backend-addresses = 127.0.0.1:3306 #Atlas后端连接的MySQL主库的IP和端口, multiple items can be set, separated by commas
Proxy-read-only-backend-addresses = 127.0.0.1:[email protected] #Atlas后端连接的MySQL从库的IP和端口, 2 is the weight, used for load balancing, if omitted the default is 1, Multiple items can be set, separated by commas

Daemon = False #设置Atlas的运行方式, set to True when the daemon mode, set to False as the foreground mode, general development debugging set to False, the online runtime is set to True
KeepAlive = False #设置Atlas的运行方式, set to True when Atlas starts two processes, one for monitor, and one for worker,monitor automatically restarts the worker after it exits unexpectedly. Set to False when only worker, no monitor, general development debug set to False, online runtime set to True

Event-threads = 4 #工作线程数, the recommended setting is equal to the number of CPU cores in the system
Log-level = Message #日志级别, divided into message, warning, critical, error, debug five levels
Log-path =/usr/local/mysql-proxy/log #日志存放的路径
Instance = Test #实例名称 for the distinction between multiple Atlas instances on the same machine

proxy-address = 0.0.0.0:1234 #Atlas监听的工作接口IP和端口
admin-address = 0.0.0.0:2345 #Atlas监听的管理接口IP和端口

Min-idle-connections = #连接池的最小空闲连接数, can be adjusted or smaller according to the size of the business request volume
tables = Person.mt.id.3 #分表设置, in this case the person is the library name, MT is the table name, the ID is a sub-table field, 3 is the number of children, you can set multiple items, separated by commas
PWDs = user1:+jksgb3yag8=, user2:gs+tr4tpgqc= #用户名与其对应的加密过的密码, the password is encrypted using an encryption program encrypt, which is used for multiple user names to access the same instance of Atlas simultaneously. If you have only one user name, you do not need to set this
charset = UTF8 #默认字符集, if the key is not set, the default character set is Latin1

Third, compile and install
-------------------
Dependency: GLib (above 2.32.0), libevent (above 1.4), Lua (above 5.1), OpenSSL (0.9.8 above)

./bootstrap.sh #可能需要修改其中的路径
Make
sudo make install

Iv. start-Up and stop
-------------------
Enter the prefix/conf directory and edit the instance.conf, where the actual name instance should be the same as the instance settings, and the other set items are described in section Ii.

Start:
Prefix/bin/mysql-proxyd instance Start

Stop it:
Prefix/bin/mysql-proxyd instance Stop

Restart:
Prefix/bin/mysql-proxyd instance Restart

To view the running status:
Prefix/bin/mysql-proxyd Instance Status

MySQL Middle tier Atlas

Related Article

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.