In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The following brings you to master Nginx + keepalived+varnish+lamp to achieve high availability, load balancing cluster methods, hoping to give you some help in practical application, load balancing involves more things, there are not many theories, there are many books online, today we use the accumulated experience in the industry to do an answer.
Description:
1. Two front-end NGINX, through keepalived virtual IP drift, to achieve high availability of the front-end two NGINX
2. Using NGINX reverse proxy function to realize high availability cluster for back-end varnish.
3. The static and dynamic separation is realized by varnish.
Note: 1. Install Nginx + keepalived first.
2. Install varnish
3. Install lamp
Need 6 virtual machines (100101installed Nginx + keepalived:100 master, 10101standby) need networking (102103installed varnish) need networking (104105installed lamp) need networking
Steps required for all hosts: systemctl stop firewalld / / turn off firewall setenforce 0 / / turn off monitoring 1, install Nginx + keepalived (both machines) (100master / 101standby) systemctl stop firewalld / / turn off firewall setenforce 0 / / turn off monitoring cd / etc/yum.repos.d/mv back/*. /
Yum install-y epel-release
Yum install-y nginx
Yum install keepalived-y
-- Master (80.100) vi / etc/keepalived/keepalived.conf (delete all the contents and add the following)! Configuration File for keepalived global_defs {route_id NGINX-01} vrrp_script nginx {script "/ opt/nginx.sh" interval 2 weight-10} vrrp_instance VI_1 {state MASTER interface ens32 virtual_router_id 51 priority 150 advert_int 1 authentication {auth_type PASS auth_pass 1111} track_script {nginx} Virtual_ipaddress {192.168.80.188}}
Scp / etc/keepalived/keepalived.conf root@192.168.80.101:/etc/keepalived/keepalived.conf prepares (80.101) vi / etc/keepalived/keepalived.conf (modify the circle below)
Main (80.100) vi / opt/nginx.sh (add the following) #! / bin/bashA=$ (ps-ef | grep keepalived | grep-v grep | wc-l) if [$A-gt 0]; then systemctl start nginxelse systemctl sop nginxfi
Chmod + x / opt/nginx.shll / opt/nginx.sh
Netstat-anpt | grep nginxsystemctl start keepalivednetstat-anpt | grep nginx
Ip addr show ens32
Prepare (80.101) vi / opt/nginx.sh (add the following) #! / bin/bashA=$ (ip addr | grep 192.168.80.188 grep 32 | grep-v grep | wc-l) if [$A-gt 0]; then systemctl start nginx else systemctl stop nginxfi
Chmod + x / opt/nginx.shsystemctl start keepalivedcat / var/log/messages
Main (80.100) cat / var/log/messages
Vi / etc/nginx/nginx.conf (modify the following) upstream varnish_pool {server 192.168.80.102 upstream varnish_pool; server 192.168.80.103 upstream varnish_pool 80;} proxy_pass http://varnish_pool;proxy_set_header Host $host;proxy_set_header X-Forwarded-For $remote_addr
Nginx-t
Scp / etc/nginx/nginx.conf 192.168.80.101:/etc/nginx/nginx.confsystemctl restart nginx2, install varnish (80.102 and 80.103) (both machines need to do) systemctl stop firewalld / / turn off firewall setenforce 0 / / turn off monitoring cd / etc/yum.repos.d/mv back/*. / yum install epel-release-y / / need to be connected to the network
Yum install-y varnish
-- vi / etc/varnish/varnish.params (modify the loop part)
Vi / etc/varnish/default.vcl (modify and add the following) backend web1 {.host = "192.168.80.104"; .port = "80";} backend web2 {.host = "192.168.80.105"; .port = "80";} sub vcl_recv {if (req.url ~ "(? I)\ .php $") {set req.backend_hint = web1;} else {set req.backend_hint = web2;}
Systemctl start varnishnetstat-anpt | grep varnish
80.103vi / etc/varnish/varnish.params (modify the following)
(80.102) scp / etc/varnish/default.vcl 192.168.80.103:/etc/varnish/default.vcl80.103systemctl start varnishnetstat-anpt | grep varnish
3. Install lamp (both machines) systemctl stop firewalld / / turn off firewall setenforce 0 / / turn off monitoring cd / etc/yum.repos.d/mv back/*. / install wgetyum install-y wget
Yum install-y httpd
Systemctl start httpdsystemctl enable httpd acquires rpm package: wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Install rpm package rpm-ivh mysql-community-release-el7-5.noarch.rpm
Install mysqlyum install-y mysql-community-server
Start systemctl start mysqlsystemctl enable mysql to change the root password and set to allow remote connections to enter mysql mysql-uroot
Set the root password to 123456set password for 'root'@'localhost' = password (' 123456'); set to allow remote connections using the root account, and set the password to 123456grant all privileges on *. * to root@'%'identified by '123456password; the modified configuration takes effect immediately: flush privileges; exit: exit
Deployment of phpyum install-y php installation component is php support mysql yum install-y\ php-mysql\ php-gd\ libjpeg*\ php-ldap\ php-odbc\ php-pear\ php-xml\ php-xmlrpc\ php-mbstring\ php-bcmath\ php-mhash
-- 80.104vi / etc/httpd/conf/httpd.conf (modify the following) ServerName www.example.com:80 remove the #
Systemctl start httpdecho "192.168.80.101" > / var/www/html/index.php80.105vi / etc/httpd/conf/httpd.conf (modify the following) ServerName www.example.com:80 remove #
Systemctl start httpdecho "192.168.80.102" > / var/www/html/index.html taskbar search 192.168.80.100
Taskbar search 192.168.80.102
Taskbar search 192.168.80.103
Taskbar search 192.168.80.104
Taskbar search 192.168.80.105
Taskbar search 192.168.80.188
After reading the above about how to master Nginx + keepalived+varnish+lamp to achieve high availability and load balancing clusters, if there is anything else you need to know, you can find what you are interested in in the industry information or find our professional and technical engineers for answers. Technical engineers have more than ten years of experience in the industry.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.