Load balancing is built on the existing network structure, it provides a cheap, effective, and transparent method to expand the bandwidth of network devices and servers, increase throughput, enhance network data processing capabilities, and improve network flexibility and availability. I have recently learned many articles about server load balancer technology on the Internet, but I am not very clear about it. now I have published the test note diary for you to learn and use; this article only introduces entry-level server load balancer.
Load Balancing is built on the existing network structure, it provides a cheap, effective, and transparent method to expand the bandwidth of network devices and servers, increase throughput, enhance network data processing capabilities, and improve network flexibility and availability.
I have recently learned many articles about server load balancer technology on the Internet, but I am not very clear about it. now I have published the test note diary for you to learn and use; this article only introduces entry-level server load balancer, and is still learning ......
I. Basic information
Operating system: CentOS6.0
Servers: three servers (Load Balancing, WEB1, and WEB2)
Server load balancer technology: Nginx
Web service technology: apache
IP address: Nginx 192.168.1.113, Web1 192.168.1.77, and Web2 192.168.1.78
II. Web server installation and configuration
Please refer to this blog's apache server setup article: http://523514.blog.51cto.com/513514/1350015
III. installation and configuration of the server load balancer (Nginx)
3.1 install basic support Suite
Yum-y install gcc openssl-devel pcre-devel
3.2 install nginx
Cdwget http://nginx.org/download/nginx-1.5.8.tar.gztar xzvf nginx-1.5.8.tar.gzcd nginx-1.5.8./cofnigure -- prefix =/usr/local/nginxmakemake install
3.3 Configure nginx
Edit/usr/local/nginx/conf/nginx. conf
Cd/usr/local/nginx/conf/
Mv nginx. conf nginx. conf. bak
Vim nginx. conf
Add the following content
User apache;
Worker_processes 10;
Pid logs/nginx. pid;
Events {
Use epoll;
Worker_connections 2048;
}
Http {
Include mime. types;
Default_type application/octet-stream;
Log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request "'
'$ Status $ body_bytes_sent "$ http_referer "'
'"$ Http_user_agent" "$ http_x_forwarded_for "';
Access_log logs/access. log main;
Sendfile on;
Tcp_nopush on;
Upstream63638790 {
Server 192.168.1.77: 80;
Server 192.168.1.78: 80;
}
Keepalive_timeout 65;
Server {
Listen 80;
Server_name www.63638790.cn;
Access_log logs/63638790. access. log main;
Location /{
Proxy_pass http: // 63638790;
Proxy_set_header Host $ host;
Proxy_set_header X-Real-IP $ remote_addr;
Proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
}
Error_page 500 502 503 x.html;
Location =/50x.html {
Root html;
}
}
}
Note: You can change the red font based on your actual situation;
4. start Nginx
4.1 verify that nginx configuration is normal
#/Usr/local/nginx/sbin/nginx-t
Note: The following content is returned, otherwise it will be changed as prompted;
Nginx: the configuration file/usr/local/nginx/conf/nginx. conf syntax is OK
Nginx: configuration file/usr/local/nginx/conf/nginx. conf test is successful
4.2 start Nginx
#/Usr/local/nginx/sbin/nginx
4.3 stop Nginx
# Killall-9 nginx
4.4 DNS domain name resolution
If you have a domain name, you can go to the DNS service provider for resolution settings. I changed the hosts file on the local computer for testing. edit C: \ Windows \ System32 \ drivers \ etc \ hosts, add the following content in the last line:
192.168.1.113 www.63638790.cn
4.5 test access
Open the browser input http://www.63638790.cn to display the web server site content, stop one of the web server does not affect the normal use of the user;
Endpoint: it is as simple as implementing load balancing in Nginx. give 10 thousand likes and learn advanced configurations ......
This article from "square inch Hill" blog, please be sure to keep this source http://523514.blog.51cto.com/513514/1353548