Recently, the company had a project where users worried that a single machine could not afford the most users, and they required to use the application cluster. We designed the application cluster architecture based on the application situation.
The architecture diagram is as follows:
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; margin: 0px; border-top: 0px; border-right: 0px "title =" logical architecture "border =" 0 "alt =" logical architecture "src =" http://www.bkjia.com/uploads/allimg/131227/1AH9EB-0.jpg "height =" 432 "/>
Application cluster deployment features:
1. Front-end Proxy Server Load balancer
Because the basic architecture of the user environment adopts the virtualized cluster platform, and the servers adopt virtual machines, a single Haproxy is used for the design.
Front-end selection of haproxy: it has the largest feature of HTTP 7th layer key health status check, which is consistent with our actual needs. Due to frequent application pressure, applications cannot respond, this feature is used to check the health status to ensure transparent access. Previously, the master-slave mode of haporxy was used as the master-slave application cluster. The active/standby mode is also a major feature of haproxy.
This solution adopts the source mode in the load balancing mode.
2. Application Server session replication
Configure the jboss application session replication function to ensure that the user logs on to the three servers for sharing.
3. shared storage space
Shared storage space is an essential feature of cluster applications. nfs is used here. It is used to achieve data consistency between codes and attachments.
4. The key points of haproxy configuration file are recorded as follows:
1) Cancel logging in the/var/log/messages directory.
Haproxy logs are also recorded in/var/log/message by default.
# vi /etc/syslog.conflocal3.* /var/log/haproxy.loglocal0.* /var/log/haproxy.log*.info;mail.none;authpriv.none;cron.none;local3.none /var/log/messages
2) haproxy log Cutting
The haproyx log cutting script is not ready-to-use. It specifically writes a log cutting script to achieve daily log cutting. To add it to the scheduled task, su root-c must force the root permission to execute it. To retain access logs, you can modify the script implementation.
#!/bin/bash# author: koumm# desc:# date: 2013-01-31# version: v1.0# modify:# cut haproxy logmv /var/log/haproxy.log /var/log/haproxy.log.bakif [ -e /var/log/haproxy.log.bak ]; thenlogrotate -f /etc/logrotate.confchown nobody:nobody /var/log/haproxy.logchmod +x /var/log/haproxy.logfisleep 1if [ -e /var/log/haproxy.log ]; thenrm -rf /var/log/haproxy.log.bakfi
3) haproxy configuration file records
globallog 127.0.0.1 local0maxconn 65535chroot /usr/local/haproxyuid 99gid 99stats socket /usr/local/haproxy/HaproxSocket level admindaemonnbproc 1pidfile /usr/local/haproxy/haproxy.pid#debugdefaultslog 127.0.0.1 local3mode httpoption httplogoption httplog clfoption httpclose#option dontlognulloption forwardforoption redispatchretries 2maxconn 2000balance source#balance roundrobinstats uri /haproxy-statsstats refresh 10scontimeout 5000clitimeout 50000srvtimeout 50000listen APP_Cluster 0.0.0.0:80mode httpoption httpchk GET /test.html HTTP/1.0\r\nHost:192.168.0.110server 192.168.0.111_node1 192.168.0.111:80 weight 3 check inter 2000 rise 2 fall 1server 192.168.0.112_node2 192.168.0.112:80 weight 3 check inter 2000 rise 2 fall 1server 192.168.0.113_node3 192.168.0.113:80 weight 3 check inter 2000 rise 2 fall 1listen stats_auth 0.0.0.0:91mode httpstats enablestats uri /adminstats realm "LOGIN"stats auth admin:123456#stats hide-versionstats refresh 10sstats admin if TRUE
This article is from the "koumm linux technology blog" blog, please be sure to keep this source http://koumm.blog.51cto.com/703525/1282152