http://www.178linux.com/18401
varnish如何存儲緩存對象:
file: 單個檔案;不支援持久機制;
malloc: 緩存在記憶體中;
persistent:基于檔案的持久存儲;(此方式不建議使用)
vcl:配置緩存系統的緩存機制;【線程中緩存功能的工作機制】
yum install varnish 安裝
[root@vs1 ~]
# vim /etc/varnish/varnish.params
# Varnish environment configuration description. This was derived from
# the old style sysconfig/defaults settings
# Set this to 1 to make systemd reload try to switch vcl without restart.
RELOAD_VCL=1
# Main configuration file. You probably want to change it.
VARNISH_VCL_CONF=
/etc/varnish/default
.vcl
#讀取vcl配置檔案的位置
# Default address and port to bind to. Blank address means all IPv4
# and IPv6 interfaces, otherwise specify a host name, an IPv4 dotted
# quad, or an IPv6 address in brackets.
# VARNISH_LISTEN_ADDRESS=192.168.1.5
VARNISH_LISTEN_PORT=6081
#監聽的服務端口為6081
# Admin interface listen address and port
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
#監聽的管理位址為本機
VARNISH_ADMIN_LISTEN_PORT=6082
#監聽的管理端口為6082
# Shared secret file for admin interface
VARNISH_SECRET_FILE=
/etc/varnish/secret
#密鑰檔案位置
# Backend storage specification, see Storage Types in the varnishd(5)
# man page for details.
VARNISH_STORAGE=
"file,/var/lib/varnish/varnish_storage.bin,1G"
#緩存以檔案的方式的存儲位置和大小
#VARNISH_STORAGE="malooc,256M" #以記憶體方式緩存,緩存大小為256M
# Default TTL used when the backend does not specify one
VARNISH_TTL=120
#聯系後端伺服器逾時時長
# User and group for the varnishd worker processes
VARNISH_USER=varnish
#主程序所使用的使用者
VARNISH_GROUP=varnish
#主程序所使用的組
# Other options, see the man page varnishd(1) #程序選項,線程池的最大值最小值和逾時時長
DAEMON_OPTS=
"-p thread_pool_min=5 -p thread_pool_max=500 -p thread_pool_timeout=300"
[root@vs1 ~]
# varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082
help
help [<
command
>]
#擷取幫助資訊
ping
[<timestamp>]
#測試伺服器是否正常
auth <response>
#
quit
#退出
banner
status
#顯示伺服器狀态資訊
start
#啟動子程序
stop
#停止子程序
vcl.load <configname> <filename>
#載入哪個檔案為配置檔案
vcl.inline <configname> <quoted_VCLstring>
vcl.use <configname>
#使用哪個vcl檔案
vcl.discard <configname>
#删除哪個vcl檔案
vcl.list
#列出所有可用的vcl檔案
param.show [-l] [<param>]
#顯示運作時參數
param.
set
<param> <value>
panic.show
#顯示恐慌資訊,顯示程序或子程序上次挂掉的原因
panic.
clear
#清除恐慌資訊
storage.list
#顯示緩存資訊
vcl.show [-
v
] <configname>
#顯示vcl檔案的詳細資訊,vcl編譯前的樣子
backend.list [<backend_expression>]
#顯示後端伺服器清單
backend.set_health <backend_expression> <state>
#手動上線下線後端伺服器
ban <field> <operator> <arg> [&& <field> <oper> <arg>]...
#清理緩存中的緩存對象
ban.list
#顯示定義的清理緩存規則
配置檔案說明:
http://book.varnish-software.com/4.0/chapters/VCL_Basics.html
http://book.varnish-software.com/4.0/_p_w_picpaths/simplified_fsm.svg