MySQL read-write separation-atlas

Source: Internet
Author: User

Https://github.com/Qihoo360/Atlas/releases

Installing RPM Packages

RPM-IVH atlas-2.2.1.el6.x86_64.rpm

Program Directory in/usr/local/mysql-proxy/

Encrypt Database Password:

[Email protected] mysql-proxy]#/bin/encrypt 123456

/izxz+0groa=

Vim CONF/TEST.CNF

[Mysql-proxy]

#带 # is a non-required configuration item

#管理接口的用户名
Admin-username = user123

#管理接口的密码
Admin-password = 123456

#Atlas后端连接的MySQL主库的IP和端口, multiple items can be set, separated by commas
Proxy-backend-addresses = 192.168.200.101:3306

#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 = 192.168.200.102:3306,192.168.200.103:3306

#用户名与其对应的加密过的MySQL密码, password using the Prefix/bin directory encryption program encrypt encryption, downlink user1 and User2 For example, replace it with your MySQL username and encryption password!
PWDs = test:/izxz+0groa=

#设置Atlas的运行方式, set to True when the daemon mode, set to False as the foreground mode, the general development debugging is set to False, the line run when set to true,true cannot have space behind.
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, the line run time set to true,true cannot have space after.
KeepAlive = True

#工作线程数, there is a significant impact on the performance of Atlas, which can be set appropriately depending on the situation
Event-threads = 8

#日志级别, divided into a message, warning, critical, error, debug five levels
Log-level = Message

#日志存放的路径
Log-path =/usr/local/mysql-proxy/log

#SQL日志的开关, can be set to off, on, Realtime,off for not logging SQL logs, on for logging SQL logs, REALTIME for logging SQL logs and writing to disk in real time, default to OFF
#sql-log = OFF

#慢日志输出设置. When this parameter is set, the log only outputs log records with a execution time exceeding sql-log-slow (in ms). If you do not set this parameter, all logs are output.
#sql-log-slow = 10

#实例名称 for the distinction between multiple Atlas instances on the same machine
#instance = Test

#Atlas监听的工作接口IP和端口
Proxy-address = 192.168.200.104:1234

#Atlas监听的管理接口IP和端口
Admin-address = 192.168.200.104:2345

#分表设置, 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

#默认字符集, the client no longer needs to execute the SET NAMES statement after setting the item
#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

Management Interface Login: Mysql-u user123-p123456-h 192.168.200.104-p2345

Querying connection Status

MySQL [(None)]> select * from Backends;

+-------------+----------------------+-------+------+

| Backend_ndx | Address | State | Type |

+-------------+----------------------+-------+------+

| 1 | 192.168.200.101:3306 | Up | RW |

| 2 | 192.168.200.102:3306 | Up | Ro |

| 3 | 192.168.200.103:3306 | Up | Ro |

+-------------+----------------------+-------+------+

3 Rows in Set (0.00 sec)

Master-Slave Database configuration

Mysql-u root-p123456

Create user test settings password 123456

MariaDB [(None)]> grant all on * * to [e-mail protected] ' 127.0.0.1 ' identified by "Hello";

MariaDB [(none)]> use MySQL;

Modify Host Permissions

MariaDB [(None)]> Update user Set host = '% ' where user = ' test ';

MariaDB [mysql]> Select User, host from user;

+------+---------------+

| user | Host |

+------+---------------+

| Test | %             |

Refreshing the database

MariaDB [mysql]> flush Privileges;

Test

Mysql-u test-p123456-h 192.168.200.104-p1234

Disconnect Mysql-master Network, find unable to write, can only query

MySQL [test]> use test;

MySQL [test]> SELECT * from Test2

Disconnect mysql-slave1, 2 network, found unable to query, only can write

MySQL read-write separation-atlas

Related Article

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.