Varnish安裝使用(初學)

2022-09-03 01:00:25 字數 2416 閱讀 2516

varnish安裝使用(初學)

本人對varnish也是新手,這裡記錄一下安裝步驟!

環境:centos6.6

先上我的拓撲圖 (基礎拓撲為lvsdr環境)  lvs不在這裡講解

安裝yum -y install gcc gcc-c++ make autoconf automake

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

tar -zxf varnish-3.0.7.tar.gz

cd varnish-3.0.7

./configure --prefix=/usr/local/varnish

make;make install

拷貝檔案到系統

cp redhat/varnish.initrc /etc/init.d/varnish

cp redhat/varnish.sysconfig /etc/sysconfig/varnish

cp redhat/varnish_reload_vcl /usr/local/varnish/bin

修改varnish配置檔案

vim /etc/sysconfig/varnish

修改為如下內容 (裡面有許多varnish的效能配置)

varnish_vcl_conf=/usr/local/varnish/etc/varnish/default.vcl

varnish_listen_port=80

varnish_secret_file=/usr/local/varnish/etc/varnish/secret

vim /etc/init.d/varnish

pidfile=/var/run/varnish.pid

exec="/usr/local/varnish/sbin/varnishd"

reload_exec="/usr/local/varnish/bin/varnish_reload_vcl"

# done parsing, set up command

varnishadm="/usr/local/varnish/bin/varnishadm $secret -t $varnish_admin_listen_address:$varnish_admin_listen_port"

注:也可以將/usr/local/varnish/bin新增到系統的path中,這樣就不需要編輯varnish_reload_vcl

生成varnish管理秘鑰:

/usr/bin/uuidgen > /usr/local/varnish/etc/varnish/secret

chmod 644 /usr/local/varnish/etc/varnish/secret

vcl配置(對應拓撲圖)

#獲取客戶端ip

#     if (req.restarts == 0) else

#   }

}檢查vcl配置是否正確:

/etc/init.d/varnish configtest

或/usr/local/varnish/sbin/varnishd -c -f /usr/local/varnish/etc/varnish/fdfs.vcl    #啟動varnish:

service varnish start    #檢視varnish狀態:

/etc/init.d/varnish status   # 動態載入vcl配置:

/etc/init.d/varnish reload   # 停止varnish:

/etc/init.d/varnish stop

先就說這麼多吧

Varnish的安裝及使用教程

1.在server1上安裝varnish 2.在server2上安裝httpd服務並啟動,在預設發布目錄寫上 server two 3.在server1上vim etc sysconfig varnish,修改varnish的監聽埠 執行vim etc varnish default.vcl,對配置...

Varnish 3安裝部署及使用

varnish安裝 varnish配置與管理 varnish高階使用 處理http響應的子程式 建議在寫自己的vcl 之前,先閱讀varnish缺省內嵌的vcl配置檔案default.vcl cat usr local varnish etc varnish default.vclvarnish負載...

varnish安裝配置

1.安裝需要用到的包,歷史教訓告訴我一定要裝穩定版本,要不有些東西不能用 automake autoconf libtool ncurses devel libxslt groff pcre devel pkgconfig yum y install automake autoconf libtoo...