系統環境:
centos release 5.5 (final) 64-bit
所需軟體:
varnish
-2.1.4.tar.gz
varnish官方**:
-cache.org/
安裝前準備:
建立www使用者和組,以及varnish快取檔案存放目錄(/elain/data/vcache):
/usr/sbin/groupadd www -g 600
/usr/sbin/useradd -u 600 -g www www
mkdir -p /elain/data/vcache
chmod +w /elain/data/vcache
chown -r www:www /elain/data/vcache
建立varnish日誌目錄(/elain/logs/varnish):
配置檔案解釋:
(1)、varnish通過反向**請求後端ip為172.16.2.223,埠為80的web伺服器;
(2)、varnish允許localhost、127.0.0.1、172.16.2.233 三個**ip通過purge方法清除快取;
(3)、varnish對網域名稱為www.elain.org的請求進行處理,非www.elain.org網域名稱的請求則返回「elain cache server」;
(4)、varnish對http協議中的get、head請求進行快取,對post請求透過,讓其直接訪問後端web伺服器。之所以這樣配置,是因為post請求一般是傳送資料給伺服器的,需要伺服器接收、處理,所以不快取;
(5)、varnish對以.txt和.js結尾的url快取時間設定1小時,對其他的url快取時間設定為30天。
引數:-u 以什麼用執行
-g 以什麼組執行
-f varnish 配置檔案
-a 繫結 ip 和埠
-s varnish 快取檔案位置與大小
-w 最小,最大執行緒和超時時間
-t varnish 管理埠,主要用來清除快取
停止varnish
pkill varnish
配置開機自動啟動varnish
vi /etc/rc.local
在末尾增加以下內容:
優化linux核心引數
vi /etc/sysctl.conf
在末尾增加以下內容:
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 5000 65000
sysctl -p
varnish日誌切割指令碼
cat /root/scripts/cut_varnish_log.sh
chmod 700 /root/scripts/cut_varnish_log.sh
設定在每天00:00定時執行:
crontab -e
# info : 每天切割varnish日誌
# author : dingtm
# ctime : 2011.04.08
0 0 * * * /root/scripts/cut_varnish_log.sh
官方文件:
-cache.org/docs/2.1/
推薦參考文件見附件
varnish安裝部署文件
附件:
Varnish 3安裝部署及使用
varnish安裝 varnish配置與管理 varnish高階使用 處理http響應的子程式 建議在寫自己的vcl 之前,先閱讀varnish缺省內嵌的vcl配置檔案default.vcl cat usr local varnish etc varnish default.vclvarnish負載...
Sentinel安裝部署文件
1 j a環境 該環境為安裝測試環境 j a version如果沒有安裝j a環境需提前安裝 2 nacos環境 該環境為安裝測試環境,以下配置需根據實際情況修改 配置內容 注意 後面有空格 檔案位置 修改nacos位址配置 根據實際配置 sentinel預設埠 sentinel使用者密碼 sent...
varnish安裝配置
1.安裝需要用到的包,歷史教訓告訴我一定要裝穩定版本,要不有些東西不能用 automake autoconf libtool ncurses devel libxslt groff pcre devel pkgconfig yum y install automake autoconf libtoo...