-
Notifications
You must be signed in to change notification settings - Fork 1.2k
The Architecture Of Atlas
Atlas is a MySQL protocol-based database middleware project. In the view of the database, Atlas is a mysql client. But in the view of mysql client, Atlas is a database server. Atlas has a connection pool for every mysql database.After finishing the client request, Atlas will give the connection back to the connection pool. The picture below depicts the overall architecture of Atlas.
When Atlas start, it will create multiple threads.One of them is the main thread, the others are working threads. The main thread is responsible for monitoring the connecting requests from clients, and the working thread only monitor the command request from the main thread.
As shown below, The main thread recieve the request from a client, Atlas will packaging the relative information for a CON structure, and then put the CON into an asynchronous queue. The main thread chooses a working thread to process this CON by a round-robin manner, and then sends a byte to the working thread in order to activate it.When the working thread receives the activation instruction, it will take out the CON structure from the asynchronous queue, and start to process of the client request.
As shown below,The LVS in front end is for loading balance, two Atlas in the back end of LVS is for high available, preventing single point of failure.The LVS periodically detects the survival status of Atlas in two ways, one is detecting the port whether can be connected successfully. Another is executing a script, the script will try to connect to Atlas, through the value that the script returns to determine the availability of each backend.There are two running status of Atlas:online or offline.If Atlas is online, the value that the script returns online.Otherwise the value is offline.
If you want update the version of Atlas smoothly. You can follow these steps: Firstly send signal(SIGUSR2) to Atlas, then the running status of Atlas will become offline.LVS will not transpond the requests to the offline Atlas. Now you can upgrade Atlas.Secondly send signal(SIGUSR1) to Atlas to make Atlas online. LVS will detect this Atlas is online, and transpond the requests to this Atlas again.
[mysql-proxy]
- 管理接口的用户名
- 管理接口的密码
- Atlas后端连接的MySQL主库的IP和端口,可设置多项,用逗号分隔
- 从库
- 用户名和密码配置项,需要和主从复制配置的用户名和密码配置一样
- 后台运行
- 工作线程数,对Atlas的性能有很大影响,可根据情况适当设置
- 日志级别,分为message、warning、critical、error、debug五个级别
- 日志存放的路径
- SQL日志的开关,可设置为OFF、ON、REALTIME,OFF代表不记录SQL日志,ON代表记录SQL日志,REALTIME代表记录SQL日>志且实时写入磁盘,默认为OFF
- sql-log = OFF
- 慢日志输出设置。当设置了该参数时,则日志只输出执行时间超过sql-log-slow(单位:ms)的日志>记录。不设置该参数则输出全部日志。
- 实例名称,用于同一台机器上多个Atlas实例间的区分
- Atlas监听的工作接口IP和端口
- Atlas监听的管理接口IP和端口
- 分表设置,此例中person为库名,mt为表名,id为分表字段,3为子表数量,可设置多项,以逗号分>隔,若不分表则不需要设置该项
- tables = person.mt.id.3
- 默认字符集,设置该项后客户端不再需要执行SET NAMES语句
- 允许连接Atlas的客户端的IP,可以是精确IP,也可以是IP段,以逗号分隔,若不设置该项则允许所>有IP连接,否则只允许列表中的IP连接
- client-ips = 127.0.0.1, 192.168.1
- Atlas前面挂接的LVS的物理网卡的IP(注意不是虚IP),若有LVS且设置了client-ips则此项必须设置>,否则可以不设置
- lvs-ips = 192.168.1.1