varnishd安裝與配置_Varish

來源:互聯網
上載者:User

https://www.varnish-cache.org/releases
# wget https://repo.varnish-cache.org/source/varnish-3.0.7.tar.gz
# tar xvzf varnish-3.0.7.tar.gz
# cd varnish-3.0.7
./configure --prefix=/usr/local/varnish PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
# make && make install

報錯:
varnishadm.c:48:33: error: editline/readline.h: No such file or directory
yum install *readline-devel*
yum install libedit libedit-dev*

安裝成功後,安裝的目錄是
cd /usr/local/varnish/sbin
./varnishd -V
查看版本,看是否安裝成功

設定檔
/usr/local/varnish/etc/varnish/default.vcl

這個對的:
/usr/local/varnish/sbin/varnishd -a :82 -b 127.0.0.1:80 -p thread_pool_max=1500 -p thread_pools=5 -p listen_depth=512  -w 1,10000,120

這個也可以
/usr/local/varnish/sbin/varnishd -a :82 -f /usr/local/varnish/etc/varnish/default.vcl -s malloc,1024m  -w 1,10000,120

這個不行
/usr/local/varnish/sbin/varnishd -f /usr/local/varnish/etc/varnish/default.vcl -s malloc,1024m  -a :82 -T 127.0.0.1:81

groupadd -g www
useradd -g www www
mkdir -p /var/vcache
chown -R www:www /var/vcache

/usr/local/varnish/sbin/varnishd -n /var/vcache -f /usr/local/varnish/etc/varnish/default.vcl -a 0.0.0.0:80 -s file,/var/vcache/varnish_cache.data,1G -g www -u www -w 30000,51200,10 -T 127.0.0.1:82

各參數的含義如下:
-f 指定 varnish 的設定檔位置
-s 指定 varnish 緩衝存放的方式,常用的方式有:“-s file,<dir_or_file>,<size>”。
-T address:port 設定 varnish 的 telnet 管理地址及其連接埠
-a address:port 表示 varnish 對 http 的監聽地址及其連接埠
-t 預設TTL
-w 最小線程,最大線程,逾時時間
http://blog.csdn.net/keda8997110/article/details/8777153
http://www.tuicool.com/articles/6rA32a


需要注意的是varnish返回的響應,varnish會增加三個相應頭資訊,分別是“X-Varnish”、“Via”和“Age”。這些頭資訊在Varnish的處理過程中非常有用。X-Varnish頭資訊的後面會有一個或兩個數字,如果是一個數字,就表明varnish在緩衝中沒有發現這個請求,這個數位含義是varnish為這個請求所做的標記ID。如果X-Varnish後是兩個數字,就表明varnish在緩衝中命中了這個請求,第一個數字是請求的標識ID,第二個數字是緩衝的標識ID。“Via”頭資訊表明這個請求將經過一個代理。“Age”頭資訊標識出這個請求將被緩衝多長時間(單位:秒)。首次請求的“Age”為0,後續的重複請求將會使Age值增大。如果後續的請求沒有是“Age”增加,那就說明varnish沒有緩衝這個響應的結果。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.