-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Installing Atlas
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
- Atlas only run in 64-bit systems.
- Mysql version should be greater than 5.1, it is recommended to use Mysql 5.6.
- When you install the rpm package, Atlas will be installed in the directory:/usr/local/mysql-proxy.
dpkg -i Atlas-XX-debian6.0-x86_64.deb
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.
[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
-
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
-
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;
-
use this command to connect the admin interface of Atlas:
mysql -h127.0.0.1 -uuser -ppwd -P2345;
-
the commands of admin interface supported, through the command to view
select * from help;
-
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.
[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