Qihoo Atlas Mysql ha Scenario

Source: Internet
Author: User

Installs the 64-bit version of the RPM package



wget https://github.com/Qihoo360/Atlas/releases/download/sharding-1.0.1/Atlas-sharding_1.0.1-el6.x86_64.rpmrpm-                  IVH atlas-2.2.el6.x86_64_2.rpmpreparing ... ########################################### [100%] 1:Atlas ########################################### [100%][[email protected] downloads]# ls


After the RPM package is installed, modify the/USR/LOCAL/TEST.CNF


[Mysql-proxy] #带 # for non-required configuration item # The user name of the management interface admin-username = root# the password of the management interface admin-password = 123456# The IP and port of the MySQL master library connected to the Atlas backend can be set up with multiple entries, separated by commas Proxy-backend-addresses = 10.1.1.102:3306#atlas back-end connected MySQL from the library IP and port , 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 = 10.1.1.107:[email  Protected],10.1.1.108:[email protected] #用户名与其对应的加密过的MySQL密码, the password is encrypted using the encryption program encrypt the Prefix/bin directory, The downstream User1 and User2 are examples, replace them with your MySQL username and encryption password! pwds = repluser:zm3rwtutc2qa8s/owzlmvq== #设置Atlas的运行方式, set to True when the daemon mode, set to False as the foreground mode, general development debugging set to False, There must be no spaces after the line run time set to True,true. daemon = true# set how Atlas runs, set to True when Atlas starts two processes, one for monitor, and one for worker,monitor automatically restarts the worker after it exits unexpectedly. Set to False when only the worker, no monitor, general development debugging is set to False, the line run time set to true,true cannot have space after. keepalive = true# number of worker threads, has a great impact on the performance of Atlas, the event-threads = 8# log level can be set appropriately according to the situation, divided into message, warning, Critical, error, debug five levels log-level = message# log storage path log-path = /usr/local/mysql-proxy/log# SQL log switch that can be set to the ofF, ON, realtime,off means not logging SQL logs, on means logging SQL logs, REALTIME representing logging SQL logs and writing to disk in real time, default to off#sql-log = off# slow log output settings. 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# Instance name for the distinction between multiple Atlas instances on the same machine #instance = test# The management interface IP and port proxy-address = 0.0.0.0:1234#atlas monitoring for the work interface IP and port of the Atlas listener admin-address =  0.0.0.0:2345# table settings, 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 a number of items, separated by commas, if the table does not need to set the item #tables = person.mt.id.3 #默认字符集, after setting the item, the client no longer needs to execute the Set names statement #charset = utf8# allow the IP of the client connecting to Atlas, which can be an exact IP or an IP segment, separated by commas, If you do not set this entry, all IP connections are allowed, otherwise only IP connections in the list are allowed to #client-ips = 127.0.0.1, 192.168.1#atlas the IP of the physical network card of the previously attached LVS (note not the virtual IP). If there is LVS and set client-ips, this must be set, otherwise you can not set #lvs-ips = 192.168.1.1


Running Atlas

Enter the/usr/local/mysql-proxy/bin directory and execute the following command to start, restart, or stop atlas.

(1). sudo./mysql-proxyd test start to launch Atlas.

(2). sudo./mysql-proxyd test restart, restart Atlas.

(3). sudo./mysql-proxyd test stop to stop Atlas.

Attention:

(1). The running file is: Mysql-proxyd (not mysql-proxy).

(2). Test is the name of the configuration file in the Conf directory, and the name of the instance item in the configuration file, and the three need to be unified.

(3). Ps-ef can be used | grep mysql-proxy to see if Atlas has started or stopped.

Execute command: Mysql-h127.0.0.1-p1234-u user name-------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.

Commands to access the management interface of Atlas: MYSQL-H127.0.0.1-P2345-UUSER-PPWD, after entry: SELECT * from Help; View various commands for managing db.


Management Console:

Mysql -uroot -p123456 -h10.1.1.108 -p2345warning: using a password on  the command line interface can be insecure. Welcome to the mysql monitor.  commands end with ; or \ G.your mysql connection id is 1server version: 5.0.99-agent-admincopyright   (c)  2000, 2015, Oracle and/or its affiliates. All rights  Reserved. oracle is a registered trademark of oracle corporation and/or  Itsaffiliates. other names may be trademarks of their respectiveowners . type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement.mysql> select * from help;+----------------------------+--------------- ------------------------------------------+| command                     | description                                                |+----------------------------+---------------------------------------------------------+|  Select * from help         | shows this  help                                           | |  select * from backends     | lists the backends and their state                       | |  SET OFFLINE  $backend _id    | offline backend server, $ Backend_id is backend_ndx ' s id | |  SET ONLINE  $backend _id     | online backend server,  ...                               | |  ADD MASTER  $backend         | example:  "ADD  master 127.0.0.1:3306 ", ...                | |  ADD SLAVE  $backend          | example:  " Add slave 127.0.0.1:3306 ", ...                 | |  REMOVE BACKEND  $backend _id | example:  "remove backend 1", &nbsp ...                          | |  ADD CLIENT  $client          | example:  " add client 192.168.1.2 ", ...                   | |  REMOVE CLIENT  $client       | example:  "remove  client 192.168.1.2 ", ...                | |  SAVE CONFIG                 | save the backends to config file                         |+------ ----------------------+---------------------------------------------------------+10 rows in set   (0.01 sec) mysql> select * from backends;+-------------+-----------------+--- ----+------+| backend_ndx | address         |  state | type |+-------------+-----------------+-------+------+|            1 | 10.1.1.102:3306 | up     | rw   | |            2 | 10.1.1.107:3306 | up     | ro   | |            3 | 10.1.1.108:3306 | up    | ro    |+-------------+-----------------+-------+------+3 rows in set  (0.01 sec)

Slave HA Test

Landing a Slave machine (107)

mysql> stop Slave;

Then use mysql-urepluser-preplpass-h10.1.1.108-p1234 to insert after landing

then execute the query, should be rotation query two slave server (107 and 108), because 107 turned off the slave synchronization, so

The results will appear out of sync, and the query will show synchronization (108), which means load balancing is in effect.


See Https://github.com/Qihoo360/Atlas/blob/master/README_ZH.md for more information


Qihoo Atlas Mysql ha Scenario

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.