Skip to content
Tristan Su edited this page Oct 22, 2015 · 6 revisions

1. Install Atlas in Redhat/Centos (recommended)

Download the latest version of the RPM package from https://github.com/Qihoo360/Atlas/releases , and then run

sudo rpm –i Atlas-XX.el6.x86_64.rpm 

notes:

  1. Atlas only run in 64-bit systems.
  2. Mysql version should be greater than 5.1, it is recommended to use Mysql 5.6.
  3. When you install the rpm package, Atlas will be installed in the directory:/usr/local/mysql-proxy.

2. Install Atlas in Debian/Ubuntu

dpkg -i Atlas-XX-debian6.0-x86_64.deb 

3. Modify the configuration file

Atlas run with a configuration file (test.cnf). Before running Atlas, the file needs to be configured. The default installation directory of Atlas is /usr/local/mysql-proxy, enter /usr/local/mysql-proxy/conf, you can see that there is a default configuration file named test.cnf, we only need to modify some configuration options inside, not need to rewrite a configuration file from scratch.

4. Configuration Examples and comments

[mysql-proxy]

# (Necessary, the default value is ok) The name access to admin port 
admin-username = user 

# (Necessary, the default value is ok) The password access to admin port 
admin-password = pwd 

# (Necessary,set value according to the actual situation) The master database server,ip:port. 
proxy-backend-addresses = 192.168.0.12:3306 

# (Not necessary,set value according to the actual situation) The slave database server, ip:port. 
# The number behind '@'represents the weight used by load balance for reading, 
# the default weight is 1. If you want the master backend also can process the read requests, 
# add its ip:port to this configuration option. 
proxy-read-only-backend-addresses = 192.168.0.13:3306@2,192.168.0.14:3306 

# (Necessary,set value according to the actual situation) Username and its password login master and slave.
# We can use the username and password login the master database and the slave database server.
# The password encrypt by /usr/loca/mysql-proxy/bin/encrypt. 
# For example, the username is: myuser, and the password is:mypwd (encrypted ciphertext is:HJBoxfRsjeI=). 
pwds = myuser:HJBoxfRsjeI=,myuser2:RePBqJ+5gI4=

# (Necessary, the default value is ok) if the value is true,Atlas run as a daemon. 
daemon = true 

# (Necessary, the default value is ok) Atlas will start two processes when the value set true, 
# one is monitor process, another is the work process. The monitor process will restart the work process 
# automatically when the work process crash unexpectedly. 
# If the value set false, Atlas will only start the work process.
keepalive = true 

# (Necessary, set value according to the actual situation) The count of work threads in work process.
# set the value equal to twice of cpu cores 
event-threads = 4 

# (Necessary, the default value is ok) Log level: message, warning, critical, error, debug 
log-level = message 

# (Necessary, the default value is ok) Log file path 
log-path = /usr/local/mysql-proxy/log 

# (Necessary, the default value is ok) The switch for printing log. 
#     ON          : log the sql to the log file with buffer. 
#     OFF         : not log the sql. 
#     REALTIME    : log the sql to the log file without buffer. 
sql-log = REALTIME 

# (Necessary, set value according to the actual situation) Slow log output settings. 
# When this parameter is set, Only log the sql which execution time more than sql-log-slow (ms) logging. 
# Do not set this parameter, will log all the sql. 
sql-log-slow = 10 

# (Necessary, set value according to the actual situation) close the inactive client connections
# after ‘wait_timeout’ seconds
wait-timeout =  10

# (Necessary, the default value is ok) The work port of Atlas
proxy-address = 0.0.0.0:1234 

# (Necessary, the default value is ok) The admin port of Atlas 
admin-address = 0.0.0.0:2345 

# (Not necessary, set value according to the actual situation) Shard table setting. 
# In this case, person is the database name, mt is the table name, id is the shard key,
# the shard table count is 3,and you should create table mt_0, mt_1, mt_2 in mysql manually.
# If you have more shard table,you can set them and separated by commas. 
tables = person.mt.id.3 

# (Not necessary,set value according to the actual situation)character set, 
# If you not set this parameter, the character is latin1. 
charset = utf8 

# (Not necessary,do not set this parameter) The client's IP be allowed to connect Atlas. 
# If you not set this parameter, all client can connect Atlas.
client-ips = 127.0.0.1, 192.168.1 

# (Not necessary,do not set this parameter) If you set client-ips, and through LVS connecting Atlas, 
# then you need set lvs-ips, and this parameter is the true IP of LVS.
lvs-ips = 192.168.1.1

Tips:

  1. If you have finished modifying the configuration file, you can use this command to run Atlas.

    /usr/local/mysql-proxy/bin/mysql-proxyd test start
  2. use this command to connect the work interface of Atlas, and then send sqls like using mysql:

    mysql -h127.0.0.1 -umyuser -pmypwd -P1234;
  3. use this command to connect the admin interface of Atlas:

    mysql -h127.0.0.1 -uuser -ppwd -P2345;
  4. the commands of admin interface supported, through the command to view

    select * from help;
  5. If you have any problem with the installation of Atlas, send email(g-atlas[at]360.cn) to us, we are glad to help you solving the problem.