MySQL middle layer Atlas_MySQL

Source: Internet
Author: User
Tags database load balancing
MySQL middle tier Atlas from: http://www.oschina.net/p/atlas/

Atlas is a MySQL-based data intermediate layer project developed and maintained by Qihoo 360 and the infrastructure team of the Web platform Department. Based on MySQL-Proxy 0.8.2 officially launched by MySQL, it has modified a large number of bugs and added many functional features. Currently, this project is widely used within 360 companies. many MySQL businesses have been connected to the Atlas platform, and billions of read/write requests are carried every day.

Main functions:
* Read/write splitting
* Slave database load balancing
* IP address filtering
* SQL statement blacklist and whitelist
* Automatic table sharding
Q &
-------------------
Q: Are multiple character sets supported?
A: This is our first improvement on the original MySQL-Proxy and is required in line with national conditions.
Q: automatic read/write splitting is good, but sometimes I want to read it immediately after writing it. what if the master/slave synchronization latency occurs?
A: Add/* master */before the SQL statement to forcibly send read requests to the master database.
Q: Is read operations affected when the master database goes down?
A: No in atlas! If you have used the official mysql-proxy, it is a pity that the official version does not solve this problem.
Q: Will detecting the backend DB status block normal requests?
A: No. the detection thread in atlas performs asynchronous detection. even if A database goes down, the main process is not blocked. There are no exceptions in atlas that will block the main process! The official version will disappoint you.
Q: What should I do if I want to deprecate a database and stop mysql server?
A: You can use the management interface to manually connect backend databases to and from the backend databases. atlas gives priority to the administrator's wishes.
Q: Do you want to add a DB to the cluster and do not want to affect normal online access?
A: It can be easily implemented through the management interface
Q: What are the improvements to atlas compared to the official mysql-proxy?
A: This is really A hard-to-answer question. we have made dozens of improvements in terms of performance, stability, reliability, and maintainability. we will try to list some major changes below.
VS official MySQL-Proxy
-------------------
1. change all Lua code in mainstream processes to pure C implementation. Lua is only used in management interfaces.
2. rewrite the network model and thread model
3. implemented a true connection pool
4. optimized the lock mechanism and improved the performance by dozens of times.
......
Appendix name source:
Atlas, the giant with shoulders in Greek mythology, the brother of Prometheus, one of the largest and strongest gods, was fined for failing to resist Zeus. We expect this system to be able to keep its feet on the back-end DB and support front-end applications for a whole day.
II. configuration file example
-------------------
[Mysql-proxy] # No need to change
Plugins = admin, proxy # Name of the module loaded by Atlas, no need to change
Admin-username = user # user name of the Management Interface
Admin-password = pwd # password of the Management Interface
Admin-lua-script =/usr/local/mysql-proxy/lib/mysql-proxy/lua/admin. lua # path of the Lua script that implements the management interface
Proxy-backend-addresses = 127.0.0.1: 3306 # IP address and port of the MySQL master database connected to the backend of Atlas. multiple entries can be set and separated by commas (,).
Proxy-read-only-backend-addresses = 127.0.0.1: 3305 @ 2 # IP address and port of the MySQL slave database connected to the backend of Atlas. 2 indicates the weight and is used for load balancing, if omitted, the default value is 1. you can set multiple entries, separated by commas (,).
Daemon = false # set the running mode of Atlas. if it is set to true, it is the daemon mode, and if it is set to false, it is the foreground mode. generally, it is set to false during development and debugging, and set to true during online running.
Keepalive = false # set the running mode of Atlas. when set to true, Atlas starts two processes, one being monitor and the other being worker. after the worker unexpectedly exits, the monitor automatically restarts the system, if it is set to false, only worker is available, and no monitor is available. Generally, this parameter is set to false during development and debugging, and set to true during online running.
Event-threads = 4 # Number of worker threads. the recommended setting is equal to the number of CPU cores of the system.
Log-level = message # log level, which includes message, warning, critical, error, and debug
Log-path =/usr/local/mysql-proxy/log # log storage path
Instance = test # instance name, used to distinguish multiple Atlas instances on the same machine
Proxy-address = 0.0.0.0: 1234 # IP address and port of the working interface of the Atlas listener
Admin-address = 0.0.0.0: 2345 # management interface IP address and port of the Atlas listener
Min-idle-connections = 128 # minimum number of idle connections in the connection pool. you can increase or decrease the number of idle connections according to the service request volume.
Tables = person. mt. id.3 # table sharding settings. In this example, "person" is the database name, "mt" is the table name, "id" is the table sharding field, and "3" is the number of sub-tables. you can set multiple entries separated by commas.
Pwds = user1: + jKsgB3YAG8 =, user2: GS + tr4TPgqc = # The encrypted password corresponding to the user name. The password is encrypted using the encryption program encrypt, this setting item is used when multiple user names access the same Atlas instance at the same time. if there is only one user name, you do not need to set this item.
Charset = utf8 # default character set. if this item is not set, the default character set is latin1.
III. compilation and installation
-------------------
Dependencies: glib (2.32.0 or later), libevent (1.4 or later), Lua (5.1 or later), and OpenSSL (0.9.8 or later)
./Bootstrap. sh # The path may need to be modified.
Make
Sudo make install
4. start and stop
-------------------
Go to the PREFIX/conf directory and edit instance. conf. the actual name of the instance must be the same as that of the instance settings. for the meanings of other settings, see section 2.
Start:
PREFIX/bin/mysql-proxyd instance start
Stop:
PREFIX/bin/mysql-proxyd instance stop
Restart:
PREFIX/bin/mysql-proxyd instance restart
View the running Status:
PREFIX/bin/mysql-proxyd instance status

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.