1. Download and install:
2. Configure Atlas
[Mysql-proxy]
#管理接口的用户名
Admin-username = user
#管理接口的密码
Admin-password = pwd
#实现管理接口的Lua脚本所在路径
Admin-lua-script =/usr/local/mysql-proxy/lib/mysql-proxy/lua/admin.lua
#Atlas后端连接的MySQL主库的IP和端口, multiple items can be set, separated by commas
Proxy-backend-addresses = 127.0.0.1:3320
#Atlas后端连接的MySQL从库的IP和端口, the number at the end of the @ represents the weight, used for load balancing, and if omitted the default is 1, you can set multiple items, separated by commas
proxy-read-only-backend-addresses = 127.0.0.1:[email protected], 127.0.0.1:[email protected]
#设置Atlas的运行方式, set to True when the daemon mode, set to False as the foreground mode, general development debugging is set to False, the online runtime is set to True
Daemon = True
#设置Atlas的运行方式, set to True when Atlas starts two processes, one for monitor, one for worker,monitor automatically restarts after worker exits unexpectedly, set to false when only worker, no monitor, General development debugging is set to false, and the on-line runtime is set to True
KeepAlive = True
#工作线程数, the recommended setting is equal to the number of CPU cores in the system
Event-threads = 4
#日志级别, divided into a message, warning, critical, error, debug five levels
Log-level = Message
#日志存放的路径
Log-path =/usr/local/mysql-proxy/log
#实例名称 for the distinction between multiple Atlas instances on the same machine
Instance = Test
#Atlas监听的工作接口IP和端口
Proxy-address = 0.0.0.0:1234
#Atlas监听的管理接口IP和端口
Admin-address = 0.0.0.0:2345
#日志存放的路径
Log-path =/usr/local/mysql-proxy/log
#实例名称 for the distinction between multiple Atlas instances on the same machine
Instance = Test
#Atlas监听的工作接口IP和端口
Proxy-address = 0.0.0.0:1234
#Atlas监听的管理接口IP和端口
Admin-address = 0.0.0.0:2345
#连接池的最小空闲连接数, should be set to an integer multiple of event-threads, can be adjusted according to the size of the business request volume or smaller
Min-idle-connections = 8
#分表设置, 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 child tables, you can set multiple items, separated by commas, if the table does not need to set the item
#tables = Person.mt.id.3
#用户名与其对应的加密过的MySQL密码, the password is encrypted using the Encrypt encryption program in the Prefix/bin directory, which is used for multiple user names to access the same Atlas instance at the same time, if only one user name is not > needs to be set
#pwds = user1:+jksgb3yag8=, user2:gs+tr4tpgqc=
PWDs =mytest:bkyjrecq8rs1w8ptadqrvq==
#默认字符集, if the key is not set, the default character set is Latin1
#charset = UTF8
#允许连接Atlas的客户端的IP, can be a precise IP, can be an IP segment, comma-delimited, if not set the entry allows all IP connections, otherwise only allow IP connections in the list
#client-ips = 127.0.0.1, 192.168.1
#Atlas前面挂接的LVS的物理网卡的IP (note is not a virtual IP), if there is LVS and set client-ips, this key must be set, otherwise you can not set
#lvs-ips = 192.168.1.1
3. Authorize in the database:
1. Start:
/usr/local/mysql-proxy/bin/mysql-proxyd Test Start
mysql-h127.0.0.1-uuser-ppwd-p2345;
2. Restart:
Mysql-proxyd Test Restart
3. Stop
Mysql-proxyd Test Stop
4. Check
[email protected]:/usr/local/mysql-proxy/bin# netstat-tnlp|grep 234
TCP 0 0 0.0.0.0:1234 0.0.0.0:* LISTEN 14247/mysql-proxy
TCP 0 0 0.0.0.0:2345 0.0.0.0:* LISTEN 14247/mysql-proxy
5. Log on to the admin side:
Mysql-h127.0.0.1-p2345-uuser-ppwd, enter after execution: SELECT * from Help; View various commands for managing DB
6. Login Client:
Mysql-h127.0.0.1-p1234-u User name-p password, if you can connect to prove that Atlas preliminary test is normal, you can try to send several SQL statements to see if the results are correct
5. Precautions:
This article is from the "Webseven" blog, make sure to keep this source http://webseven.blog.51cto.com/4388012/1746368