Load of Percona xtradb cluster based on Haproxy

Source: Internet
Author: User
Tags curl percona haproxy

Haproxy is a highly available, load-balanced, and TCP-and HTTP-based agent software, Haproxy is completely free, with Haproxy can quickly and reliably provide a proxy solution based on TCP and HTTP applications. Haproxy applies to those Web sites that are heavily loaded, which typically require session maintenance or seven-tier processing. Haproxy can support tens of thousands of concurrent connections, and Haproxy's mode of operation allows it to be easily and securely integrated into the architecture while protecting the Web server from being exposed to the network.


Note that this blog post is based on (PXC installation) . The installation of PXC is not repeated,


Environmental planning

Server IP Node name
192.168.255.143 node143 (PXC)
192.168.255.144 node144 (PXC)
192.168.255.145 node145 (PXC)
192.168.255.146 node146 (Haproxy)

Actions on the node146 node

1.yum install-y Haproxy

2.vim/etc/haproxy/haproxy.cfg

Global
Log 127.0.0.1 Local0
Log 127.0.0.1 Local1 Notice
Maxconn 4096
UID 99
GID 99
Daemon
#quiet

Defaults
Log Global
Mode http
Option Tcplog
Option Dontlognull
Retries 3
Option Redispatch
Maxconn 2000
Timeout Connect 5000
Timeout client 50000
Timeout server 50000

Frontend Pxc-front
Bind *:3306
Mode TCP
Default_backend Pxc-back

Frontend Statas-front
Bind *:8088
Mode http
Default_backend Stats-back

Backend Pxc-back
Mode TCP
Balance Leastconn
Option Httpchk
Server Node1 192.168.255.143:3306 Check Port 9200 Inter 12000 Rise 3 Fall 3 #9200用于检测
Server Node2 192.168.255.144:3306 Check Port 9200 Inter 12000 rise 3 Fall 3
Server Node2 192.168.255.145:3306 Check Port 9200 Inter 12000 rise 3 Fall 3

Backend Stats-back
Mode http
Balance Roundrobin
Stats Uri/haproxy/stats
Stats Auth Pxcstats:test

3. View listening port: Netstat-lntup | grep ha

Actions on the cluster node:

1. After entering the background http://192.168.255.146:8088/haproxy/stats (username, password in the configuration file)


The Haproxy node was successfully installed.


Actions on the cluster node

1.clustercheck Adjustment

A. Use the username and the full path to the MySQL command (vim/usr/local/mysql/bin/clustercheck)

Mysql_username= "Pxc-monitor"
Mysql_password= ""

Mysql_cmdline= "/usr/local/mysql/bin/mysql

B. Run/usr/local/mysql/bin/clustercheck 200 indicates Clustercheck validation succeeded

2.XINETD Configuration

A.yum install-y xinetd.x86_64

b.cp/usr/local/mysql/xinetd.d/mysqlchk/etc/xinetd.d/

D.vim/etc/xinetd.d/mysqlchk changes the server to/usr/local/mysql/bin/clustercheck (server=/usr/local/mysql/bin/ Clustercheck)

E. Change of authority chmod +x Mysqlchk

F.vim/etc/services the last New line Mysqlchk 9200/tcp # Mysqlchk

G.service xinetd Start/restart

F. Check to see if it starts successfully netstat-tlnup | grep 9200

3. Access between nodes in turn:

Curl Http://192.168.255.143:9200/

Curl Http://192.168.255.144:9200/

Curl Http://192.168.255.145:9200/

Tip Percona xtradb Cluster Node is synced represents success

The last time you visit http://192.168.255.146:8088/haproxy/stats


Test

A. Run for i in ' seq 1 100 '; Do/usr/local/mysql/bin/mysql-h 192.168.255.145-p3306-utest-ptest-e "SELECT @ @hostname;"; Done >/tmp/1.txt

B. View the results of the run Cat/tmp/1.txt

Indicates that the environment has been successfully installed.


Note :

1. When the Curl Http://192.168.255.144:9200/appears as shown in the illustration:

The solution executes on the 192.168.255.144 iptables-f this is due to a firewall problem.

2. Still cannot forward, install the method operation shown in the following figure.


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.