Mysql-Proxy proxy configuration, mysql-Proxy proxy

Source: Internet
Author: User

Mysql-Proxy proxy configuration, mysql-Proxy proxy
I. Principles of Mysql-Proxy

Mysql-Proxy is a simple program between your client and Mysql Server. It can monitor, analyze, and change their communication. It is flexible and unrestricted. Its common uses include load balancing, faults, query analysis, query filtering and modification.

Mysql-Proxy is such a middle-layer Proxy. In short, Mysql-Proxy is a connection pool that forwards requests from foreground applications to the background database and uses lua scripts, complex Connection Control and filtering can be implemented to achieve read/write splitting and load balancing. For applications, MySQL Proxy is completely transparent, and the application only needs to connect to the listening port of MySQL Proxy. Of course, the proxy machine may become a single point of failure, but multiple proxy machines can be used as redundancy. You can configure the connection parameters of multiple proxies in the connection pool configuration of the application server.

The principle is taken from Baidu encyclopedia.

Ii. Install Mysql-Proxy

1. When installing the mysql database through yum, You can first enter the yum list | grep mysql command to view the downloadable mysql database version provided on yum, when viewing the mysql database version, you can also view the available mysql-proxy. The figure below shows the desired result;

[root@10-17-1-229 ~]# yum list|grep mysql

  

2. We use yum install mysql-proxy to install:

[root@10-17-1-229 ~]# yum install mysql-proxy

The download progress bar and installation process are displayed. When a Complete is displayed, the installation is Complete.

Iii. Mysql-Proxy configuration

1. Use mysql-proxy-V to view information about mysql-proxy. Pay attention to the version information and use it when configuring the lua path in step 3;

2. Use the vim/etc/mysql-proxy.cnf command to open the configuration file of mysqk-proxy for editing:

[root@10-17-1-229 ~]# vim /etc/mysql-proxy.cnf

Enter the following in the mysql-proxy.cnf:

[Mysql-proxy] admin-username = user # admin username admin-password = password admin-lua-script =/usr/lib64/mysql-proxy/lua/admin. lua # lua location, see the previous version information daemon = true # mysql-proxy run keepalive = true in the daemprocess mode # there will be two processes to keep the Connection Starting, process 1 is used to monitor the proxy-backend-addresses = 10.17.6.210 # Destination Address and Indb Intranet address of process 2. The default port is 3306, 10.17.6.210 is the iplog-file of the target inDB =/var/log/mysql-proxy.log # log file storage path log-level = debug

After editing, exit the editing through Esc and save the editing of the mysql-proxy.cnf with ': wq.

3. Use the chmod 0660/etc/mysql-proxy.cnf command to change the configuration file permissions, and then start the mysql-proxy service with mysql-proxy -- defaults-file =/etc/mysql-proxy.cnf:

[root@10-17-1-229 ~]# chmod 0660 /etc/mysql-proxy.cnf[root@10-17-1-229 ~]# mysql-proxy --defaults-file=/etc/mysql-proxy.cnf

4. Test with mysql-h $ uhost_ip-P4040-u $ User-p $ Password:

[root@10-17-1-229 ~]# mysql -h106.75.94.37 -P4040 -uroot -p123456

$ Uhost_ip: Internet IP address of UHost;

$ User: User Name

$ Password: Database Password

Note: Open Port 4040 of the firewall. The default port of MySQL-Proxy is 4040. You can access port 4040 by accessing port 3306.

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.