日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

Varnish Cache 3.0.0安装

發(fā)布時間:2023/11/27 生活经验 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Varnish Cache 3.0.0安装 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

?https://www.varnish-cache.org/installation/redhat

?

?

Installation on RedHat

?

先按需要的模塊

在安裝軟件包之前首先看看主機上的

automake

autoconf

libtool

ncurses-devel

libxslt

groff

pcre-devel

pkgconfig軟件包是否已經安裝?如果沒有那么就要首先安裝,我直接用yum安裝的。

#yum?install?-y?automake?autoconf?libtool?ncurses-devel?libxslt?groff?pcre-devel?pkgconfig?

?

Varnish is distributed in the EPEL (Extra Packages for Enterprise Linux) package repositories. However, while EPEL allows new versions to be distributed, it does not allow for backwards-incompatible changes. Therefore, new major versions will not hit EPEL and it is therefore not necessarily up to date. If you require a newer major version than what is available in EPEL, you should use the repository provided by varnish-cache.org.

To use the varnish-cache.org repository, run

rpm --nosignature?-i http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release-3.0-1.noarch.rpm

and then run

yum install varnish

The --no-signature is only needed on initial installation, since the Varnish GPG key is not yet in the yum keyring

?

安裝安成后我們的配置文件在?/usr/local/etc/varnish/default.vcl?下

好了接下來就開始我們的配置之旅吧。

首先將下面這些開始的注釋去掉,并將8080改為80

#?backend?default?{

#?????.host?=?"127.0.0.1";

#?????.port?=?"8080";

#?}

?backend?default?{

?????.host?=?"127.0.0.1";

?????.port?=?"80";

?}

現(xiàn)在,這塊配置定義了一個?varnish默認訪問的后端服務器,當varnish?需要從后端

服務器獲取內容的時候,它就會訪問自己(127.0.0.1)的80端口。?Varnish?可以定義多個后端服務器而且您可以通過定義多個后端服務器達到負載均衡的目的。?

現(xiàn)在我們完成了基本的?varnish?配置,我們可以在?8080?端口上啟動?varnish,并做一些基本的測試。?

下面我們啟動varnish。

[root@db?varnish]#?varnishd -f /etc/varnish/default.vcl -s malloc,1G? -T 127.0.0.1:2000 -a 0.0.0.0:8080

會出現(xiàn)下面的內容說明啟動成功了。

storage_malloc:?max?size?1024?MB.

Creating?new?SHMFILE

其中-f指定varnish的配置文件

–s?選項用來確定varnish使用的存儲類型和存儲容量

-T指定監(jiān)聽本地端口

-a?0.0.0.0:8080

用來制定?varnish?監(jiān)聽所有?IP?發(fā)給?8080?端口的?http?請求,如果在生產環(huán)境下,您應該讓varnish監(jiān)聽80,這也是默認的。

我們在瀏覽器里輸入http://192.168.0.131:8080/可以看到web程序正在運行。

為了讓我們知道varnish到底做了什么,那么我們就來設置日志吧。

Varnish一個特別的優(yōu)點就是它如何記錄數(shù)據的。使用內存段代替普通的日志文件,當內存段使用完以后,又從頭開始,覆蓋最舊的記錄。這樣就可以非常快的記錄數(shù)據,,并且不需要磁盤空間。 缺點就是您沒有把數(shù)據寫到磁盤上,可能會消失。在命令行執(zhí)行

#varnishlog

將會得到一些信息。

如果varnish一切運行?OK,我們就可以把它調整到80端口上。?

首先關閉varnish

[root@db?~]#?pkill?varnished

然后停止您的?web服務器,修改web服務器配置,把?web服務器修改成監(jiān)聽8080

端口,然后修改varnish?的default.vcl和改變默認的后端服務器端口為8080.?先重啟web服務器然后重新啟動varnish

?

總結

以上是生活随笔為你收集整理的Varnish Cache 3.0.0安装的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。