91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

發布時間:2020-04-20 11:06:57 來源:億速云 閱讀:274 作者:三月 欄目:云計算

下文給大家帶來掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法,希望能夠給大家在實際運用中帶來一定的幫助,負載均衡涉及的東西比較多,理論也不多,網上有很多書籍,今天我們就用億速云在行業內累計的經驗做一個解答。

描述:
1、前端兩臺NGINX,通過keepalived虛擬IP漂移,實現前端兩臺NGINX高可用;
2、利用NGINX反向代理功能對后端varnish實現高可用集群,

3、再通過varnish實現動靜分離


注:1、先裝Nginx +keepalived
2、裝varnish
3、裝lamp
需要6臺虛擬機(100-101裝Nginx +keepalived:100主,101備)需要聯網(102-103裝varnish)需要聯網(104-105裝lamp)需要聯網
掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

所有主機必做的步驟
systemctl stop firewalld      //關閉防火墻
setenforce 0         //關閉監控
1、裝Nginx +keepalived(兩臺機子都要做的)(100主101備)
systemctl stop firewalld      //關閉防火墻
setenforce 0         //關閉監控
cd /etc/yum.repos.d/
mv back/* ./

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

yum install -y epel-release

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

yum install -y nginx

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

yum install keepalived -y  

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

————————————————————————————————

主(80.100)

vi /etc/keepalived/keepalived.conf(把里面內容全刪了添加以下內容)
! 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
    }
}

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

scp /etc/keepalived/keepalived.conf root@192.168.80.101:/etc/keepalived/keepalived.conf

備(80.101)

vi /etc/keepalived/keepalived.conf(修改以下畫圈部分)

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法
主(80.100)

vi /opt/nginx.sh(添加以下內容)
#!/bin/bash
A=$(ps -ef | grep keepalived | grep -v grep | wc -l)
if [ $A -gt 0 ];then
        systemctl start nginx
else
        systemctl sop nginx
fi

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

chmod +x /opt/nginx.sh
ll /opt/nginx.sh

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

netstat -anpt | grep nginx
systemctl start keepalived
netstat -anpt | grep nginx

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

ip addr show ens32

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法
備(80.101)

vi /opt/nginx.sh(添加以下內容)
#!/bin/bash

A=$(ip addr | grep 192.168.80.188/32 | grep -v grep | wc -l)
if [ $A -gt 0 ];then
        systemctl start nginx 
else
        systemctl stop nginx
fi

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

chmod +x /opt/nginx.sh
systemctl start keepalived
cat /var/log/messages

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法
主(80.100)

cat /var/log/messages

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

vi /etc/nginx/nginx.conf(修改以下內容)
upstream varnish_pool {
              server 192.168.80.102:80;
              server 192.168.80.103:80;
       }

proxy_pass http://varnish_pool;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法
掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

nginx -t

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

scp /etc/nginx/nginx.conf 192.168.80.101:/etc/nginx/nginx.conf
systemctl restart nginx
2、裝varnish(80.102,80.103)(兩臺機子都需要做)
systemctl stop firewalld      //關閉防火墻
setenforce 0         //關閉監控
cd /etc/yum.repos.d/
mv back/* ./
yum  install epel-release -y  //需要聯網

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

yum install -y varnish

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

————————————————————————————————

vi /etc/varnish/varnish.params(修改環圈部分)

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

vi /etc/varnish/default.vcl(修改添加以下部分)
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;
}

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

systemctl  start varnish
netstat -anpt | grep varnish

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法
80.103

vi /etc/varnish/varnish.params(修改以下內容)

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法
(80.102)

scp /etc/varnish/default.vcl 192.168.80.103:/etc/varnish/default.vcl

80.103

systemctl start varnish
netstat -anpt | grep varnish

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

3、裝lamp(兩臺機子都要做的)(100主101備)
systemctl stop firewalld      //關閉防火墻
setenforce 0         //關閉監控
cd /etc/yum.repos.d/
mv back/* ./
安裝wget
yum install -y  wget

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

yum install -y httpd

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

systemctl start httpd
systemctl enable httpd
獲取rpm軟件包:
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

安裝rpm包
rpm -ivh mysql-community-release-el7-5.noarch.rpm

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

安裝mysql
yum install -y mysql-community-server

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

啟動 
systemctl start mysql
systemctl enable mysql

修改root密碼并設置允許遠程連接
進入mysql  
mysql -uroot

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

設置root密碼為123456
set password for 'root'@'localhost' =password('123456');

設置允許用root賬戶進行遠程連接,并設置其密碼為123456
grant all privileges on *.* to root@'%'identified by '123456';

修改的配置立即生效
flush privileges;

退出:
exit

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

部署php
yum install -y php
安裝組件是php支持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

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

————————————————————————————————

80.104

vi /etc/httpd/conf/httpd.conf(修改以下內容)
ServerName www.example.com:80去掉#號

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法
掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

systemctl start httpd
echo "<h3>192.168.80.101</h3>" > /var/www/html/index.php

80.105

vi /etc/httpd/conf/httpd.conf(修改以下內容)
ServerName www.example.com:80去掉#號

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

systemctl start httpd
echo "<h3>192.168.80.102</h3>" > /var/www/html/index.html

任務欄搜索192.168.80.100

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

任務欄搜索192.168.80.102

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

任務欄搜索192.168.80.103

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

任務欄搜索192.168.80.104

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

任務欄搜索192.168.80.105

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

任務欄搜索192.168.80.188

掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法

看了以上關于掌握Nginx +keepalived+varnish+lamp實現高可用、負載均衡集群的方法,如果大家還有什么地方需要了解的可以在億速云行業資訊里查找自己感興趣的或者找我們的專業技術工程師解答的,億速云技術工程師在行業內擁有十幾年的經驗了。

 

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

甘泉县| 彭山县| 民权县| 汨罗市| 华安县| 三门峡市| 当雄县| 罗平县| 荆门市| 临武县| 社旗县| 怀宁县| 霍城县| 松潘县| 孙吴县| 垣曲县| 沧州市| 纳雍县| 明水县| 鹤庆县| 当涂县| 巴南区| 旬阳县| 饶河县| 汤阴县| 平果县| 清镇市| 富源县| 定日县| 林芝县| 保山市| 聂荣县| 永福县| 潢川县| 南安市| 鄱阳县| 阜新| 沅陵县| 资溪县| 家居| 长寿区|