And install nginx nginx load balancing

install a

[root@localhost ~]# yum -y install gcc automake autoconf libtool make
yum install gcc gcc-c++

安装pcre
cd /usr/local/src
wget    https://netix.dl.sourceforge.net/project/pcre/pcre/8.40/pcre-8.40.tar.gz
tar -zxvf pcre-8.40.tar.gz
cd pcre-8.40
./configure
make && make install

安装zlib

cd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz      wget  http://www.zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install
yum install -y zlib zlib-devel

安装openssl
cd /user/local/scr
wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
tar -zxvf openssl-1.0.1t.tar.gz


安装nginx
cd /user/local/scr
wget http://nginx.org/download/nginx-1.1.10.tar.gz
tar zxvf nginx-1.1.10.tar.gz 
cd nginx-1.1.10
./configure
make && make install
启动nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

cd ~
开启端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl start firewalld.service








firewall-cmd --zone=public --add-port=80/tcp --permanent

systemctl stop firewalld.service
systemctl start firewalld.service

Set up load balancing

Prepare two computers:

nginx1 192.168.142.131 nginx as a load balancer

nginx2 192.168.142.135 web services to provide a page

 

1. Configure web page

vim /usr/local/nginx/html

Then start nginx

2. Prepare the load balancer, modify the following configuration

 

Do reverse proxy

 

 

 

 

 

Log Viewer are open in the load balancer and web pages

tail -f /usr/local/nginx/logs/access.log 

  

 

 

 

 Remarks:

The load balancing algorithm 
			scheduling algorithm outlined 
			polling chronologically assigned individually to different backend server (default) 
			weight WRR, the larger the weight, the higher the probability assigned to the access 
			ip_hash request hash of each IP Access the results allocations, so that the same fixed IP access from a back-end server 
			url_hash in accordance with the hash result access URL to allocation request, each URL is directed to the same back-end server 
			least_conn minimum number of links, the fewer the number of links on the distribution machine 

			1. polling (not configured, the default polling) 

			2.weight weight (priority) 

			3.ip_hash configuration, according to the distribution client ip hash, can not be used together with the weight

  

Guess you like

Origin www.cnblogs.com/wqzn/p/11599680.html