varnish流程图

wKioL1Zm-a-QvWxZAALfdfC9CeQ790.jpg


[root@node200 tmp]# rpm -ivh var*

Preparing...                ########################################### [100%]

   1:varnish-libs           ########################################### [ 33%]

   2:varnish                ########################################### [ 67%]

   3:varnish-docs           ########################################### [100%]


[root@node200 ~]# yum info varnish

已加载插件:fastestmirror, refresh-packagekit, security

Loading mirror speeds from cached hostfile

epel/metalink                                        | 4.6 kB     00:00     

 * base: mirrors.sina.cn

 * epel: mirrors.opencas.cn

 * extras: mirrors.163.com

 * updates: mirrors.sina.cn

base                                                 | 3.7 kB     00:00     

epel                                                 | 4.3 kB     00:00     

epel/primary_db                                      | 5.8 MB     00:19     

extras                                               | 3.4 kB     00:00     

extras/primary_db                                    |  33 kB     00:00     

updates                                              | 3.4 kB     00:00     

updates/primary_db                                   | 2.6 MB     00:04     

已安装的软件包

Name        : varnish

Arch        : x86_64

Version     : 3.0.5

Release     : 1.el6

Size        : 1.1 M

Repo        : installed

Summary     : High-performance HTTP accelerator

URL         : http://www.varnish-cache.org/

License     : BSD

Description : This is Varnish Cache, a high-performance HTTP accelerator.

            : Documentation wiki and additional information about Varnish is

            : available on the following web site:

            : http://www.varnish-cache.org/



[root@node200 ~]# rpm -ql varnish

/etc/logrotate.d/varnish

/etc/rc.d/init.d/varnish

/etc/rc.d/init.d/varnishlog----从内存里提取日志永久保存(方式1)

/etc/rc.d/init.d/varnishncsa----从内存里提取日志永久保存(方式2)

/etc/sysconfig/varnish-------配置varnish工作特性(监听端口)

/etc/varnish

/etc/varnish/default.vcl---------配置缓存策略

/usr/bin/varnish_reload_vcl

/usr/bin/varnishadm

/usr/bin/varnishhist

/usr/bin/varnishlog

/usr/bin/varnishncsa

/usr/bin/varnishreplay

/usr/bin/varnishsizes

/usr/bin/varnishstat

/usr/bin/varnishtest

/usr/bin/varnishtop

/usr/lib64/varnish

/usr/lib64/varnish/libvarnish.so

/usr/lib64/varnish/libvarnishcompat.so

/usr/lib64/varnish/libvcl.so

/usr/lib64/varnish/libvgz.so

/usr/lib64/varnish/vmods

/usr/lib64/varnish/vmods/libvmod_std.so

/usr/sbin/varnishd

/usr/share/doc/varnish-3.0.5

/usr/share/doc/varnish-3.0.5/ChangeLog

/usr/share/doc/varnish-3.0.5/LICENSE

/usr/share/doc/varnish-3.0.5/README

/usr/share/doc/varnish-3.0.5/README.redhat

/usr/share/doc/varnish-3.0.5/examples

/usr/share/doc/varnish-3.0.5/examples/default.vcl

/usr/share/doc/varnish-3.0.5/examples/zope-plone.vcl

/usr/share/man/man1/varnishadm.1.gz

/usr/share/man/man1/varnishd.1.gz

/usr/share/man/man1/varnishhist.1.gz

/usr/share/man/man1/varnishlog.1.gz

/usr/share/man/man1/varnishncsa.1.gz

/usr/share/man/man1/varnishreplay.1.gz

/usr/share/man/man1/varnishsizes.1.gz

/usr/share/man/man1/varnishstat.1.gz

/usr/share/man/man1/varnishtest.1.gz

/usr/share/man/man1/varnishtop.1.gz

/usr/share/man/man3/vmod_std.3.gz

/usr/share/man/man7/varnish-cli.7.gz

/usr/share/man/man7/varnish-counters.7.gz

/usr/share/man/man7/vcl.7.gz

/var/lib/varnish

/var/log/varnish


[root@node200 ~]# man varnishd

SYNOPSIS

       varnishd [-a address[:port]] [-b host[:port]] [-d] [-F] [-f config]

OPTIONS

       -a address[:port][,address[:port][...]------监听的地址和端口(默认端口6081)

       -b host[:port]------指明后端主机( 属于反代,一般在vcl里指明)

       -h type[,options]------指明hash算法

       -l shmlogsize-----指明共享内存的大小默认80M

       -s [name=]type[,options]------指明缓存的存储后端(缓存不能随便重启,重启意味着内存中保存的缓存将没有,除了第3个)

            (1)malloc[,size]-----内存中缓存

            (2)file[,path[,size[,granularity]]]-------保存到磁盘(一个文件保存所有的缓存)

            (3)persistent,path,size(未用于生产环境)

       -T address[:port]-----提供一个管理接口 (默认:6082)

      



剪辑脚本文件

[root@node200 ~]# vim /etc/sysconfig/varnish 

## Alternative 3, Advanced configuration

#

# See varnishd(1) for more information.

#

# # Main configuration file. You probably want to change it :)

VARNISH_VCL_CONF=/etc/varnish/default.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=

VARNISH_LISTEN_PORT=6081

#

VARNISH_ADMIN_LISTEN_PORT=6082

#

# # Shared secret file for admin interface

# # The minimum number of worker threads to start

# # The Maximum number of worker threads to start

VARNISH_MAX_THREADS=1000

#

# # Idle timeout for worker threads

VARNISH_THREAD_TIMEOUT=120

#

# # Cache file location

VARNISH_STORAGE_FILE=/var/lib/varnish/varnish_storage.bin

#

 53 

 54 

 55 ## Alternative 3, Advanced configuration

 56 #

 57 # See varnishd(1) for more information.

 58 #

 59 # # Main configuration file. You probably want to change it :)

 60 VARNISH_VCL_CONF=/etc/varnish/default.vcl

 61 #

 62 # # Default address and port to bind to

 63 # # Blank address means all IPv4 and IPv6 interfaces, otherwise specify

 64 # # a host name, an IPv4 dotted quad, or an IPv6 address in brackets.

 65 # VARNISH_LISTEN_ADDRESS=

 66 VARNISH_LISTEN_PORT=80

 67 #

 70 VARNISH_ADMIN_LISTEN_PORT=6082

 71 #

 72 # # Shared secret file for admin interface

 75 # # The minimum number of worker threads to start

 83 #

 84 # # Cache file location

 85 VARNISH_STORAGE_FILE=/var/lib/varnish/varnish_storage.bin

 86 #

 87 # # Cache file size: in bytes, optionally using k / M / G / T suffix,

 88 # # or in percentage of available disk space using the % suffix.

 89 VARNISH_STORAGE_SIZE=1G

 90 VARNISH_STORAGE_SHM=64M

 91 # 92 # # Backend storage specification

 93 #VARNISH_STORAGE="file,${VARNISH_STORAGE_FILE},${VARNISH_STORAGE_SIZE}"

 94 VARNISH_STORAGE="malloc,${VARNISH_STORAGE_SHM}"

 95 

 96 #

 97 # # Default TTL used when the backend does not specify one 98 VARNISH_TTL=120 99 #100 # # DAEMON_OPTS is used by the init script.  If you add or remove option    s, make

101 # # sure you update this section, too.102 DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \103              -f ${VARNISH_VCL_CONF} \104              -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_P    ORT} \       

105              -t ${VARNISH_TTL} \106              -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_    THREAD_TIMEOUT} \

107              -u varnish -g varnish \

108              -S ${VARNISH_SECRET_FILE} \

109              -s ${VARNISH_STORAGE}"

[root@node200 ~]# vim /etc/sysconfig/varnish 

[root@node200 ~]# service varnish restart

Stopping Varnish Cache:                                    [失败]

Starting Varnish Cache:                                    [确定]

[root@node200 ~]# ss -tanlp

State       Recv-Q Send-Q                  Local Address:Port                    Peer Address:Port 

LISTEN      0      10                          127.0.0.1:6082                               *:*      users:(("varnishd",32526,6))

LISTEN      0      128                                :::80                                :::*      users:(("varnishd",32528,8))

LISTEN      0      128                                 *:80                                 *:*

[root@node200 ~]# curl http://node2.zye.com

<h1>node 2</h1>

[root@node200 ~]# curl http://192.168.112.140

<h1>node 3</h1>

[root@node200 ~]# vim /etc/varnish/default.vcl 

[root@node200 ~]# cd /etc/varnish/

[root@node200 varnish]# ls

default.vcl  secret

[root@node200 varnish]# cp default.vcl{,.bak}

[root@node200 varnish]# ls

default.vcl  default.vcl.bak  secret

[root@node200 varnish]# vim /etc/varnish/default.vcl ------指明后端主机

 7 backend default {

  8   .host = "192.168.112.130";

  9   .port = "80";

 10 }

[root@node200 varnish]# service varnish restart

Stopping Varnish Cache:                                    [确定]

Starting Varnish Cache:                                    [确定]

wKiom1ZdGk3wHTy5AAB9WMeHDE0643.jpg

[root@node200 ~]# varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082------ 使用内部管理命令(相当于reload)

200        

-----------------------------

Varnish Cache CLI 1.0

-----------------------------

Linux,2.6.32-573.el6.x86_64,x86_64,-smalloc,-smalloc,-hcritbit

varnish-3.0.5 revision 1a89b1f


Type 'help' for command list.

Type 'quit' to close CLI session.


varnish> help

200        

help [command]

ping [timestamp]

auth response

quit

banner

status

start

stop

vcl.load <configname> <filename>

vcl.inline <configname> <quoted_VCLstring>

vcl.use <configname>

vcl.discard <configname>

vcl.list

vcl.show <configname>

param.show [-l] [<param>]

param.set <param> <value>

panic.show

panic.clear

storage.list

backend.list

backend.set_health matcher state

ban.url <regexp>

ban <field> <operator> <arg> [&& <field> <oper> <arg>]...

ban.list


varnish> ping-----测试服务器

200        

PONG 1448942309 1.0

varnish> status

200        

Child in state running

varnish> vcl.list

200        

active          2 boot


varnish> vcl.show boot

200      


[root@node200 ~]# vim /etc/varnish/default.vcl

  1 # This is a basic VCL configuration file for varnish.  See the vcl(7)

  2 # man page for details on VCL syntax and semantics.

  3 # 

  4 # Default backend definition.  Set this to point to your content

  5 # server.

  6 # 

  7 backend default {

  8   .host = "192.168.112.140";

  9   .port = "80";

 10 }


[root@node200 ~]# varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082

varnish> vcl.list

200        

active          2 boot


varnish> vcl.load test1 default.vcl

200        

VCL compiled.

varnish> vcl.list

200        

active          2 boot

available       0 test1


varnish> vcl.use test1

200        


varnish> vcl.list

200        

available       2 boot

active          0 test1

wKioL1ZlD-mCVZv7AAB-hHe3CNQ748.jpg 


# This is a basic VCL configuration file for varnish.  See the vcl(7)

# man page for details on VCL syntax and semantics.

# Default backend definition.  Set this to point to your content

# server.

backend default {

  .host = "192.168.112.130";

  .port = "80";

}

# Below is a commented-out copy of the default VCL logic.  If you

# redefine any of these subroutines, the built-in logic will be

# appended to your code.

# sub vcl_recv {

#     if (req.restarts == 0) {

# if (req.http.x-forwarded-for) {

#    set req.http.X-Forwarded-For =

# req.http.X-Forwarded-For + ", " + client.ip;

# } else {

#    set req.http.X-Forwarded-For = client.ip;

# }

#     }

#     if (req.request != "GET" &&

#       req.request != "HEAD" &&

#       req.request != "PUT" &&

#       req.request != "POST" &&

#       req.request != "TRACE" &&

#       req.request != "OPTIONS" &&

#       req.request != "DELETE") {

#         /* Non-RFC2616 or CONNECT which is weird. */

#         return (pipe);

#     }

#     if (req.request != "GET" && req.request != "HEAD") {

#         /* We only deal with GET and HEAD by default */

#         return (pass);

#     }

#     if (req.http.Authorization || req.http.Cookie) {

#         /* Not cacheable by default */

#         return (pass);

#     }

#     return (lookup);

# }

# sub vcl_pipe {

#     # Note that only the first request to the backend will have

#     # X-Forwarded-For set.  If you use X-Forwarded-For and want to

#     # have it set for all requests, make sure to have:

#     # set bereq.http.connection = "close";

#     # here.  It is not set by default as it might break some broken web

#     # applications, like IIS with NTLM authentication.

#     return (pipe);

# }

# sub vcl_pass {

#     return (pass);

# }

# sub vcl_hash {

#     hash_data(req.url);

#     if (req.http.host) {

#         hash_data(req.http.host);

#     } else {

#         hash_data(server.ip);

#     }

#     return (hash);

# }

# sub vcl_hit {

#     return (deliver);

# }

# sub vcl_miss {

#     return (fetch);

# }

# sub vcl_fetch {

#     if (beresp.ttl <= 0s ||

#         beresp.http.Set-Cookie ||

#         beresp.http.Vary == "*") {

# /*

# * Mark as "Hit-For-Pass" for the next 2 minutes

# */

# set beresp.ttl = 120 s;

# return (hit_for_pass);

#     }

#     return (deliver);

# }

# sub vcl_deliver {

#     return (deliver);

# }

# sub vcl_error {

#     set obj.http.Content-Type = "text/html; charset=utf-8";

#     set obj.http.Retry-After = "5";

#     synthetic {"

# <?xml version="1.0" encoding="utf-8"?>

# <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

#  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

# <html>

#   <head>

#     <title>"} + obj.status + " " + obj.response + {"</title>

#   </head>

#   <body>

#     <h1>Error "} + obj.status + " " + obj.response + {"</h1>

#     <p>"} + obj.response + {"</p>

#     <h3>Guru Meditation:</h3>

#     <p>XID: "} + req.xid + {"</p>

#     <hr>

#     <p>Varnish cache server</p>

#   </body>

# </html>

# "};

#     return (deliver);

# }

# sub vcl_init {

# return (ok);

# }

# sub vcl_fini {

# return (ok);

# }


varnish>



[root@node200 ~]# vim /etc/varnish/default.vcl

wKiom1ZdNs3QltO_AABr3NVAx9o807.jpg

[root@node200 ~]# varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082

varnish> vcl.list

200        

active          2 boot

varnish> vcl.list

200        

active          2 boot


varnish> vcl.load test1 default.vcl

200        

VCL compiled.

varnish> vcl.list

200        

active          2 boot

available       0 test1


varnish> vcl.use test1

200        


varnish> vcl.list

200        

available       2 boot

active          0 test1


varnish> vcl.show test1

200        

# This is a basic VCL configuration file for varnish.  See the vcl(7)

# man page for details on VCL syntax and semantics.

# Default backend definition.  Set this to point to your content

# server.

backend default {

  .host = "192.168.112.140";

  .port = "80";

}

# Below is a commented-out copy of the default VCL logic.  If you

# redefine any of these subroutines, the built-in logic will be

# appended to your code.

# sub vcl_recv {

#     if (req.restarts == 0) {

# if (req.http.x-forwarded-for) {

#    set req.http.X-Forwarded-For =

# req.http.X-Forwarded-For + ", " + client.ip;

# } else {

#    set req.http.X-Forwarded-For = client.ip;

# }

#     }

#     if (req.request != "GET" &&

#       req.request != "HEAD" &&

#       req.request != "PUT" &&

#       req.request != "POST" &&

#       req.request != "TRACE" &&

#       req.request != "OPTIONS" &&

#       req.request != "DELETE") {

#         /* Non-RFC2616 or CONNECT which is weird. */

#         return (pipe);

#     }

#     if (req.request != "GET" && req.request != "HEAD") {

#         /* We only deal with GET and HEAD by default */

#         return (pass);

#     }

#     if (req.http.Authorization || req.http.Cookie) {

#         /* Not cacheable by default */

#         return (pass);

#     }

#     return (lookup);

# }

# sub vcl_pipe {

#     # Note that only the first request to the backend will have

#     # X-Forwarded-For set.  If you use X-Forwarded-For and want to

#     # have it set for all requests, make sure to have:

#     # set bereq.http.connection = "close";

#     # here.  It is not set by default as it might break some broken web

#     # applications, like IIS with NTLM authentication.

#     return (pipe);

# }

# sub vcl_pass {

#     return (pass);

# }

# sub vcl_hash {

#     hash_data(req.url);

#     if (req.http.host) {

#         hash_data(req.http.host);

#     } else {

#         hash_data(server.ip);

#     }

#     return (hash);

# }

# sub vcl_hit {

#     return (deliver);

# }

# sub vcl_miss {

#     return (fetch);

# }

# sub vcl_fetch {

#     if (beresp.ttl <= 0s ||

#         beresp.http.Set-Cookie ||

#         beresp.http.Vary == "*") {

# /*

# * Mark as "Hit-For-Pass" for the next 2 minutes

# */

# set beresp.ttl = 120 s;

# return (hit_for_pass);

#     }

#     return (deliver);

# }

# sub vcl_deliver {

#     return (deliver);

# }

# sub vcl_error {

#     set obj.http.Content-Type = "text/html; charset=utf-8";

#     set obj.http.Retry-After = "5";

#     synthetic {"

# <?xml version="1.0" encoding="utf-8"?>

# <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

#  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

# <html>

#   <head>

#     <title>"} + obj.status + " " + obj.response + {"</title>

#   </head>

#   <body>

#     <h1>Error "} + obj.status + " " + obj.response + {"</h1>

#     <p>"} + obj.response + {"</p>

#     <h3>Guru Meditation:</h3>

#     <p>XID: "} + req.xid + {"</p>

#     <hr>

#     <p>Varnish cache server</p>

#   </body>

# </html>

# "};

#     return (deliver);

# }

# sub vcl_init {

# return (ok);

# }

# sub vcl_fini {

# return (ok);

# }

wKiom1ZdOCPx2QVeAACP3oy9SGM256.jpg


[root@node200 ~]# vim /etc/varnish/default.vcl

 90  sub vcl_deliver {

 91         if (obj.hits>0) {

 92                 set resp.http.X-Cache = "HIT";

 93         } else {

 94                 set resp.http.X-Cache = "MISS";

 95         }

 96      return (deliver);

 97  }


[root@node200 ~]# varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082

varnish> vcl.load test2 default.vcl

200        

VCL compiled.

varnish> vcl.use test2

200        


varnish> vcl.list

200        

available       0 boot

available       2 test1

active          0 test2

wKiom1ZdPNPgldv9AAKJBgp4-y0215.jpg


缓存

wKioL1ZdikLBjQytAAB8lTK8rOo946.jpg

[root@node3 ~]# tail /var/log/httpd/access_log

192.168.112.200 - - [01/Dec/2015:19:44:38 +0800] "GET / HTTP/1.1" 200 16 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

You have new mail in /var/spool/mail/root

[root@node3 ~]# tail /var/log/httpd/access_log

192.168.112.200 - - [01/Dec/2015:19:44:38 +0800] "GET / HTTP/1.1" 200 16 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

[root@node3 ~]# tail /var/log/httpd/access_log

192.168.112.200 - - [01/Dec/2015:19:44:38 +0800] "GET / HTTP/1.1" 200 16 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

[root@node3 ~]# tail /var/log/httpd/access_log

192.168.112.200 - - [01/Dec/2015:19:44:38 +0800] "GET / HTTP/1.1" 200 16 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

192.168.112.1 - - [01/Dec/2015:19:47:35 +0800] "GET / HTTP/1.1" 200 16 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

192.168.112.1 - - [01/Dec/2015:19:47:35 +0800] "GET /favicon.ico HTTP/1.1" 404 290 "http://192.168.112.140/" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

192.168.112.1 - - [01/Dec/2015:19:47:37 +0800] "GET / HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

192.168.112.1 - - [01/Dec/2015:19:47:37 +0800] "GET / HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

 [root@node3 ~]# vim /etc/httpd/conf/httpd.conf 

 497 LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combin     ed

 498 LogFormat "%h %l %u %t \"%r\" %>s %b" common

 499 LogFormat "%{Referer}i -> %U" refere

[root@node3 ~]# service httpd reload

重新载入 httpd:


[root@node200 ~]# vim /etc/varnish/default.vcl

15  sub vcl_recv {

 16      if (req.restarts == 0) {

 17         if (req.http.x-forwarded-for) {

 18             set req.http.X-Forwarded-For =

 19                 req.http.X-Forwarded-For + ", " + client.ip;

 20         } else {

 21             set req.http.X-Forwarded-For = client.ip;

 22         }

 23      }

 24      if (req.request != "GET" &&

 25        req.request != "HEAD" &&

 26        req.request != "PUT" &&

 27        req.request != "POST" &&

 28        req.request != "TRACE" &&

 29        req.request != "OPTIONS" &&

 30        req.request != "DELETE") {

 31          /* Non-RFC2616 or CONNECT which is weird. */

 32          return (pipe);

 33      }

 34      if (req.request != "GET" && req.request != "HEAD") {

 35          /* We only deal with GET and HEAD by default */

 36          return (pass);

 37      }

 38      if (req.http.Authorization || req.http.Cookie) {

 39          /* Not cacheable by default */

 40          return (pass);

 41      }

 42      return (lookup);

 43  }

[root@node200 ~]# varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082

varnish> vcl.load test3 default.vcl

200        

VCL compiled.

varnish> vcl.use test3

200  


wKioL1ZdjlaBSAeHAAB_HAtVGhk419.jpg

[root@node3 ~]# tail /var/log/httpd/access_log

- - - [01/Dec/2015:20:03:04 +0800] "GET / HTTP/1.1" 200 16 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

- - - [01/Dec/2015:20:03:05 +0800] "GET /favicon.ico HTTP/1.1" 404 290 "http://192.168.112.140/" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

- - - [01/Dec/2015:20:06:09 +0800] "GET / HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

- - - [01/Dec/2015:20:06:09 +0800] "GET / HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

- - - [01/Dec/2015:20:06:10 +0800] "GET / HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

- - - [01/Dec/2015:20:06:10 +0800] "GET / HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

192.168.112.1 - - [01/Dec/2015:20:07:01 +0800] "GET / HTTP/1.1" 200 16 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

192.168.112.1 - - [01/Dec/2015:20:07:01 +0800] "GET /favicon.ico HTTP/1.1" 404 290 "http://192.168.112.200/" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"

192.168.112.1 - - [01/Dec/2015:20:07:30 +0800] "GET / HTTP/1.1" 200 16 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"


禁止某个ip

[root@node200 ~]# vim /etc/varnish/default.vcl

 24 if (client.ip == “192.168.112.1”) {

 25 error 404 "zhuyouen";

 26 }    


[root@node200 ~]# varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082

varnish> vcl.load test2 default.vcl

200        

VCL compiled.

varnish> vcl.use test2

200 

wKiom1ZlmQuhN1JsAADhV0OiIeM028.jpg



purge删除缓存:

[root@node200 ~]# vim /etc/varnish/default.vcl

 15 acl purges {

 16 "127.0.0.1";

 17 #"192.168.0.0/16"

 18 } 

 28 if (req.request == "PURGE") {

 29         if (!client.ip ~ purges) {

 30 error 405 "Method not allowed";  

 31 }

 32 }  


[root@node200 ~]# varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082

varnish> vcl.list

200        

available       0 boot

available       0 test1

active          2 test2


varnish> vcl.load test3 default.vcl

200        

VCL compiled.

varnish> vcl.use test3

200        


[root@node200 ~]# curl -I -X PURGE http://192.168.112.200/index.html

HTTP/1.1 405 Method not allowed

Server: Varnish

Content-Type: text/html; charset=utf-8

Retry-After: 5

Content-Length: 416

Accept-Ranges: bytes

Date: Mon, 07 Dec 2015 10:20:15 GMT

X-Varnish: 1573998053

Age: 0

Via: 1.1 varnish

Connection: close

X-Cache: MISS


[root@node200 ~]# vim /etc/varnish/default.vcl

 65  sub vcl_pass {

 66 if (req.request == "PURGE") {

 67 error 502 "Purge on a passed object.";

 68 }

 69      return (pass);

 70  }

 82  sub vcl_hit {

 83   if (req.request == "PURGE") {

 84 purge;

 85 error 200 "Purged.";

 86 }    

 87      return (deliver);

 88  }

 89 # 

 90  sub vcl_miss { 

 91 if (req.request == "PURGE") {

 92 purge;

 93 error 404 "Not in cache.";}

 94      return (fetch);

 95  }


[root@node200 ~]# varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082

varnish> vcl.load test4 default.vcl

200        

VCL compiled.

varnish> vcl.use test4

200    

[root@node200 ~]# curl -I http://192.168.112.200/index.html

HTTP/1.1 200 OK

Server: Apache/2.2.15 (CentOS)

Last-Modified: Fri, 23 Oct 2015 09:03:25 GMT

ETag: "601aa-10-522c1e2666d3a"

Content-Type: text/html; charset=UTF-8

Content-Length: 16

Accept-Ranges: bytes

Date: Mon, 07 Dec 2015 10:35:56 GMT

X-Varnish: 1573998056 1573998055

Age: 10

Via: 1.1 varnish

Connection: keep-alive

X-Cache: HIT


[root@node200 ~]# curl -I -X PURGE http://192.168.112.200/index.html

HTTP/1.1 405 Method not allowed

Server: Varnish

Content-Type: text/html; charset=utf-8

Retry-After: 5

Content-Length: 416

Accept-Ranges: bytes

Date: Mon, 07 Dec 2015 10:36:24 GMT

X-Varnish: 1573998057

Age: 0

Via: 1.1 varnish

Connection: close

X-Cache: MISS


[root@node200 ~]# vim /etc/varnish/default.vcl

 34      if (req.request != "GET" &&

 35        req.request != "HEAD" &&

 36        req.request != "PUT" &&

 37        req.request != "POST" &&

 38        req.request != "TRACE" &&

 39        req.request != "OPTIONS" &&

 40        req.request != "DELETE" &&

 41        req.request != "PURGE") {

 42          /* Non-RFC2616 or CONNECT which is weird. */

 43          return (pipe);

[root@node200 ~]# curl -I http://192.168.112.200/index.html

HTTP/1.1 200 OK

Server: Apache/2.2.15 (CentOS)

Last-Modified: Fri, 23 Oct 2015 09:03:25 GMT

ETag: "601aa-10-522c1e2666d3a"

Content-Type: text/html; charset=UTF-8

Content-Length: 16

Accept-Ranges: bytes

Date: Mon, 07 Dec 2015 10:40:16 GMT

X-Varnish: 1573998060

Age: 0

Via: 1.1 varnish

Connection: keep-alive

X-Cache: MISS


[root@node200 ~]# curl -I http://192.168.112.200/index.html

HTTP/1.1 200 OK

Server: Apache/2.2.15 (CentOS)

Last-Modified: Fri, 23 Oct 2015 09:03:25 GMT

ETag: "601aa-10-522c1e2666d3a"

Content-Type: text/html; charset=UTF-8

Content-Length: 16

Accept-Ranges: bytes

Date: Mon, 07 Dec 2015 10:40:22 GMT

X-Varnish: 1573998061 1573998060

Age: 6

Via: 1.1 varnish

Connection: keep-alive

X-Cache: HIT


[root@node200 ~]# curl -I -X PURGE http://192.168.112.200/index.html

HTTP/1.1 405 Method not allowed

Server: Varnish

Content-Type: text/html; charset=utf-8

Retry-After: 5

Content-Length: 416

Accept-Ranges: bytes

Date: Mon, 07 Dec 2015 10:40:31 GMT

X-Varnish: 1573998062

Age: 0

Via: 1.1 varnish

Connection: close

X-Cache: MISS


[root@node200 ~]# vim /etc/varnish/default.vcl

 45      if (req.request != "GET" && req.request != "HEAD" && req.request != "PURGE") {

 46          /* We only deal with GET and HEAD by default */

 47          return (pass);

 48      }   


varnish> vcl.load test6 default.vcl

200        

VCL compiled.

varnish> vcl.use test6

200   

[root@node200 ~]# vim /etc/varnish/default.vcl

[root@node200 ~]# ^C

[root@node200 ~]# curl -I http://192.168.112.200/index.html

HTTP/1.1 200 OK

Server: Apache/2.2.15 (CentOS)

Last-Modified: Fri, 23 Oct 2015 09:03:25 GMT

ETag: "601aa-10-522c1e2666d3a"

Content-Type: text/html; charset=UTF-8

Content-Length: 16

Accept-Ranges: bytes

Date: Mon, 07 Dec 2015 10:43:51 GMT

X-Varnish: 1573998063

Age: 0

Via: 1.1 varnish

Connection: keep-alive

X-Cache: MISS


[root@node200 ~]# curl -I http://192.168.112.200/index.html

HTTP/1.1 200 OK

Server: Apache/2.2.15 (CentOS)

Last-Modified: Fri, 23 Oct 2015 09:03:25 GMT

ETag: "601aa-10-522c1e2666d3a"

Content-Type: text/html; charset=UTF-8

Content-Length: 16

Accept-Ranges: bytes

Date: Mon, 07 Dec 2015 10:43:53 GMT

X-Varnish: 1573998064 1573998063

Age: 2

Via: 1.1 varnish

Connection: keep-alive

X-Cache: HIT


[root@node200 ~]# curl -I -X PURGE http://192.168.112.200/index.html

HTTP/1.1 405 Method not allowed

Server: Varnish

Content-Type: text/html; charset=utf-8

Retry-After: 5

Content-Length: 416

Accept-Ranges: bytes

Date: Mon, 07 Dec 2015 10:43:56 GMT

X-Varnish: 1573998065

Age: 0

Via: 1.1 varnish

Connection: close

X-Cache: MISS


[root@node200 ~]# vim /etc/varnish/default.vcl

 15 acl purges {

 16 "127.0.0.1";

 17 "192.168.0.0"/16;

 18 }

[root@node200 ~]# curl -I http://192.168.112.200/index.html

HTTP/1.1 200 OK

Server: Apache/2.2.15 (CentOS)

Last-Modified: Fri, 23 Oct 2015 09:03:25 GMT

ETag: "601aa-10-522c1e2666d3a"

Content-Type: text/html; charset=UTF-8

Content-Length: 16

Accept-Ranges: bytes

Date: Mon, 07 Dec 2015 11:09:13 GMT

X-Varnish: 1573998069

Age: 0

Via: 1.1 varnish

Connection: keep-alive

X-Cache: MISS


[root@node200 ~]# curl -I http://192.168.112.200/index.html

HTTP/1.1 200 OK

Server: Apache/2.2.15 (CentOS)

Last-Modified: Fri, 23 Oct 2015 09:03:25 GMT

ETag: "601aa-10-522c1e2666d3a"

Content-Type: text/html; charset=UTF-8

Content-Length: 16

Accept-Ranges: bytes

Date: Mon, 07 Dec 2015 11:09:16 GMT

X-Varnish: 1573998070 1573998069

Age: 3

Via: 1.1 varnish

Connection: keep-alive

X-Cache: HIT


[root@node200 ~]# curl -I -X PURGE http://192.168.112.200/index.html

HTTP/1.1 200 Purged.

Server: Varnish

Content-Type: text/html; charset=utf-8

Retry-After: 5

Content-Length: 383

Accept-Ranges: bytes

Date: Mon, 07 Dec 2015 11:09:19 GMT

X-Varnish: 1573998071

Age: 0

Via: 1.1 varnish

Connection: close

X-Cache: MISS


[root@node200 ~]# curl -I http://192.168.112.200/index.html

HTTP/1.1 200 OK

Server: Apache/2.2.15 (CentOS)

Last-Modified: Fri, 23 Oct 2015 09:03:25 GMT

ETag: "601aa-10-522c1e2666d3a"

Content-Type: text/html; charset=UTF-8

Content-Length: 16

Accept-Ranges: bytes

Date: Mon, 07 Dec 2015 11:10:07 GMT

X-Varnish: 1573998072

Age: 0

Via: 1.1 varnish

Connection: keep-alive

X-Cache: MISS


[root@node200 ~]# curl -I http://192.168.112.200/index.html

HTTP/1.1 200 OK

Server: Apache/2.2.15 (CentOS)

Last-Modified: Fri, 23 Oct 2015 09:03:25 GMT

ETag: "601aa-10-522c1e2666d3a"

Content-Type: text/html; charset=UTF-8

Content-Length: 16

Accept-Ranges: bytes

Date: Mon, 07 Dec 2015 11:10:12 GMT

X-Varnish: 1573998073 1573998072

Age: 5

Via: 1.1 varnish

Connection: keep-alive

X-Cache: HIT


[root@node200 ~]# curl -I -X PURGE http://192.168.112.200/index.html

HTTP/1.1 200 Purged.

Server: Varnish

Content-Type: text/html; charset=utf-8

Retry-After: 5

Content-Length: 383

Accept-Ranges: bytes

Date: Mon, 07 Dec 2015 11:10:34 GMT

X-Varnish: 1573998074

Age: 0

Via: 1.1 varnish

Connection: close

X-Cache: MISS


[root@node200 ~]# vim /etc/varnish/default.vcl

  7 backend web1 {

  8   .host = "192.168.112.140";

  9   .port = "80";

 10 }

 11 

 12 backend web2 {

 13   .host = "192.168.112.130";

 14   .port = "80";

 15 }

 33 if (req.url ~ "test.html") {

 34 set req.backend = web1;

 35 } else {

 36 set req.backend = web2;

 37 }


[root@node200 ~]# varnishadm -S /etc/varnish/secret -T 127.0.0.1:6082

varnish> vcl.load test1 default.vcl

200        

VCL compiled.

varnish> vcl.use test1

200  

wKiom1Zm1fyDuGj1AACG6rpgh6E288.jpg

 

wKiom1Zm1mug7LmhAAAGlg_px0A934.jpg

[root@node3 ~]# vim /var/www/html/test.html

<h1>test page on,web1.</h1>


wKioL1Zm2ifAAqr1AAAWX_hnMzg380.jpg

[root@node2 ~]# vim /var/www/html/test.html

<h1>node on page,node2.</h1>

wKioL1Zm22rymIfcAAClyU5VJmQ664.jpg


动静分离

1.配置动态页面

[root@node3 ~]# yum install php -y

[root@node3 ~]# vim /var/www/html/index.php

    <?php

    phpinfo();

    ?>

[root@node3 ~]# curl http://192.168.112.140/index.php

2.varnish配置

[root@node200 ~]# vim /etc/varnish/default.vcl

  7 backend appsvr {

  8   .host = "192.168.112.140";

  9   .port = "80";

 10 }


 11 

 12 backend static {

 13   .host = "192.168.112.130";

 14   .port = "80";

 15 }


 35 if (req.url ~ "\.php$") {

 36 set req.backend = appsvr;

 37 } else {

 38 set req.backend = static;

 39 }



varnish> vcl.load test2 default.vcl

200        

VCL compiled.

varnish> vcl.use test2

200        


varnish> vcl.lit

101        

Unknown request.

Type 'help' for more info.


wKioL1Zm31vRHf31AACkt46s0VI125.jpg

wKiom1Zm33DSZrIjAAORe3Tl888764.jpg


定义后端的健康检测

[root@node200 ~]# vim /etc/varnish/default.vcl

  7 probe chk {

  8         .url = "/test.html";

  9         .window = 5;

 10         .threshold = 3;

 11         .interval = 3s;

 12         .timeout = 1s;

 13 }

 14 

 15 

 16 backend appsvr {

 17   .host = "192.168.112.140";

 18   .port = "80";

 19   .probe = chk;

 20 }

 21 

 22 backend static {

 23   .host = "192.168.112.130";

 24   .port = "80";

 25   .probe = chk;

 26 }


varnish> vcl.load test3 default.vcl

200        

VCL compiled.

varnish> vcl.use test3

200        

varnish> backend.list

200        

Backend name                   Refs   Admin      Probe

default(192.168.112.140,,80)   1      probe      Healthy (no probe)

web1(192.168.112.140,,80)      1      probe      Healthy (no probe)

web2(192.168.112.130,,80)      1      probe      Healthy (no probe)

appsvr(192.168.112.140,,80)    3      probe      Healthy 5/5

static(192.168.112.130,,80)    3      probe      Healthy 5/5


[root@node2 html]# mv test.html 2.html


varnish> backend.list

200        

Backend name                   Refs   Admin      Probe

default(192.168.112.140,,80)   1      probe      Healthy (no probe)

web1(192.168.112.140,,80)      1      probe      Healthy (no probe)

web2(192.168.112.130,,80)      1      probe      Healthy (no probe)

appsvr(192.168.112.140,,80)    3      probe      Healthy 5/5

static(192.168.112.130,,80)    3      probe      Sick 0/5


[root@node2 html]# mv 2.html test.html

varnish> backend.list

200        

Backend name                   Refs   Admin      Probe

default(192.168.112.140,,80)   1      probe      Healthy (no probe)

web1(192.168.112.140,,80)      1      probe      Healthy (no probe)

web2(192.168.112.130,,80)      1      probe      Healthy (no probe)

appsvr(192.168.112.140,,80)    3      probe      Healthy 5/5

static(192.168.112.130,,80)    3      probe      Healthy 5/5


使用多台后端主机

[root@node200 ~]# vim /etc/varnish/default.vcl

 22 backend static {

 23   .host = "192.168.112.130";

 24   .port = "80";

 25   .probe = chk;

 26 }

 27 director mysrvs random {

 28   .retries = 3;

 29   {

 30   .backend = appsvrs;

 31   .weight = 1;

 32  }

 33   {

 34   .backend = static;

 35   .weight = 1;

 36   }

 37 }


 57 if (req.url ~ "\.php$") {

 58 set req.backend = appsvr;

 59 } else {

 60 set req.backend = mysrvs;

 61 }


varnish> vcl.load test6 default.vcl

200        

VCL compiled.

varnish> vcl.use test6

200  

wKiom1Zm90aR_zUDAAKlI79rO3I207.jpg

wKiom1Zm90ag-SqfAACI9rnWZlY634.jpg



不查缓存

[root@node200 ~]# vim /etc/varnish/default.vcl

 57 if (req.url ~ "test.html") {

 58 return (pass);

 59 }

 60 

 61 if (req.url ~ "\.php$") {

 62 set req.backend = appsvr;

 63 } else {

 64 set req.backend = mysrvs;

 65 }


varnish> vcl.load test7 default.vcl

200        

VCL compiled.

varnish> vcl.use test7

200   


wKioL1Zm-12jKcLTAAJOWZZsY3E420.jpg



查看默认值

varnish> param.show -l

200        

thread_pool_max             3000 [threads]

                            Default is 500

                            The maximum number of worker threads in each

                            pool.

                            

                            Do not set this higher than you have to, since

                            excess worker threads soak up RAM and CPU and

                            generally just get in the way of getting work

                            done.

                            

                            NB: This parameter may take quite some time to

                            take (full) effect.

                            

                            NB: We do not know yet if it is a good idea to

                            change this parameter, or if the default value is

                            even sensible.  Caution is advised, and feedback

                            is most welcome.


thread_pool_min             50 [threads]

                            Default is 5

                            The minimum number of worker threads in each

                            pool.

                            

                            Increasing this may help ramp up faster from low

                            load situations where threads have expired.

                            

                            Minimum is 2 threads.

thread_pools                2 [pools]

                            Default is 2

thread_pool_purge_delay     1000 [milliseconds]

                            Default is 1000

                            Wait this long between purging threads.

thread_pool_stack           unlimited [bytes]

                            Default is -1

                            Worker thread stack size.

thread_pool_timeout         120 [seconds]

                            Default is 300

                            Thread idle threshold.

                            

                            Threads in excess of thread_pool_min, which have

                            been idle for at least this long are candidates

                            for purging.


修改:

varnish> param.set thread_pool_max 2000

200   


varnish> param.show thread_pool_max

200        

thread_pool_max             2000 [threads]

                            Default is 500

                            The maximum number of worker threads in each

                            pool.

                            

                            Do not set this higher than you have to, since

                            excess worker threads soak up RAM and CPU and

                            generally just get in the way of getting work

                            done.

                            

                            NB: This parameter may take quite some time to

                            take (full) effect.

                            

                            NB: We do not know yet if it is a good idea to

                            change this parameter, or if the default value is

                            even sensible.  Caution is advised, and feedback

                            is most welcome.


[root@node200 ~]# varnishtop -I ^User-Agent -1

   124.00 RxHeader User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36

[root@node200 ~]# varnishtop -i RxHeader -1

   124.00 RxHeader Host: node200.zye.com

   124.00 RxHeader Connection: keep-alive

   124.00 RxHeader User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36

   124.00 RxHeader Accept-Encoding: gzip, deflate, sdch

   124.00 RxHeader Accept-Language: zh-CN,zh;q=0.8

   104.00 RxHeader Accept: text/html,application/xhtml+xml,application/xml;q=0.9,p_w_picpath/webp,*/*;q=0.8

   104.00 RxHeader Upgrade-Insecure-Requests: 1

    64.00 RxHeader Cache-Control: max-age=0

    49.00 RxHeader Pragma: no-cache

    49.00 RxHeader Cache-Control: no-cache

    21.00 RxHeader Server: Apache/2.2.15 (CentOS)

    21.00 RxHeader Connection: close

    18.00 RxHeader If-None-Match: "60191-10-522544a055f1b"

    18.00 RxHeader If-Modified-Since: Sat, 17 Oct 2015 22:18:18 GMT

    14.00 RxHeader Content-Type: text/html; charset=UTF-8

    14.00 RxHeader Referer: http://node200.zye.com/

    12.00 RxHeader Accept: */*

    11.00 RxHeader If-None-Match: "601aa-10-522c1e2666d3a"

    11.00 RxHeader If-Modified-Since: Fri, 23 Oct 2015 09:03:25 GMT

    11.00 RxHeader If-None-Match: "6019f-1d-52662e542bfc3"

    11.00 RxHeader If-Modified-Since: Tue, 08 Dec 2015 13:24:38 GMT

    10.00 RxHeader Accept-Ranges: bytes

     8.00 RxHeader Accept: p_w_picpath/webp,p_w_picpath/*,*/*;q=0.8

     6.00 RxHeader Referer: http://node200.zye.com/index.php

     6.00 RxHeader If-None-Match: "601c0-1c-52662dc04a9f1"

     6.00 RxHeader If-Modified-Since: Tue, 08 Dec 2015 13:22:03 GMT

     6.00 RxHeader X-Powered-By: PHP/5.3.3

     5.00 RxHeader Content-Length: 16

     5.00 RxHeader Content-Type: text/html; charset=iso-8859-1

     4.00 RxHeader Transfer-Encoding: chunked

     4.00 RxHeader Content-Length: 288

     3.00 RxHeader Date: Tue, 08 Dec 2015 13:45:38 GMT

     3.00 RxHeader Date: Tue, 08 Dec 2015 15:28:45 GMT

     3.00 RxHeader Last-Modified: Tue, 08 Dec 2015 13:22:03 GMT

     3.00 RxHeader ETag: "601c0-1c-52662dc04a9f1"

     3.00 RxHeader Content-Length: 28

     3.00 RxHeader Last-Modified: Sat, 17 Oct 2015 22:18:18 GMT

     3.00 RxHeader ETag: "60191-10-522544a055f1b"

     3.00 RxHeader Date: Wed, 09 Dec 2015 05:52:07 GMT

     2.00 RxHeader Last-Modified: Fri, 23 Oct 2015 09:03:25 GMT

     2.00 RxHeader ETag: "601aa-10-522c1e2666d3a"

     2.00 RxHeader Last-Modified: Tue, 08 Dec 2015 13:24:38 GMT

     2.00 RxHeader ETag: "6019f-1d-52662e542bfc3"

     2.00 RxHeader Content-Length: 29

     2.00 RxHeader Date: Wed, 09 Dec 2015 05:49:49 GMT

     2.00 RxHeader Content-Length: 2146

     2.00 RxHeader Content-Type: p_w_picpath/gif


查看状态

[root@node200 ~]#  varnishstat 

[root@node200 ~]#  varnishstat -f clients_conn

[root@node200 ~]#  varnishstat -l

Varnishstat -f option fields:

Field name                     Description

----------                     -----------

client_conn                    Client connections accepted

client_drop                    Connection dropped, no sess/wrk

client_req                     Client requests received

cache_hit                      Cache hits

cache_hitpass                  Cache hits for pass

cache_miss                     Cache misses

backend_conn                   Backend conn. success

backend_unhealthy              Backend conn. not attempted

backend_busy                   Backend conn. too many

backend_fail                   Backend conn. failures

backend_reuse                  Backend conn. reuses

backend_toolate                Backend conn. was closed

backend_recycle                Backend conn. recycles

backend_retry                  Backend conn. retry

fetch_head                     Fetch head

fetch_length                   Fetch with Length

fetch_chunked                  Fetch chunked

fetch_eof                      Fetch EOF

fetch_bad                      Fetch had bad headers

fetch_close                    Fetch wanted close

fetch_oldhttp                  Fetch pre HTTP/1.1 closed

fetch_zero                     Fetch zero len

fetch_failed                   Fetch failed

fetch_1xx                      Fetch no body (1xx)

fetch_204                      Fetch no body (204)

fetch_304                      Fetch no body (304)

n_sess_mem                     N struct sess_mem

n_sess                         N struct sess

n_object                       N struct object

n_vampireobject                N unresurrected objects

n_objectcore                   N struct objectcore

n_objecthead                   N struct objecthead

n_waitinglist                  N struct waitinglist

n_vbc                          N struct vbc

n_wrk                          N worker threads

n_wrk_create                   N worker threads created

n_wrk_failed                   N worker threads not created

n_wrk_max                      N worker threads limited

n_wrk_lqueue                   work request queue length

n_wrk_queued                   N queued work requests

n_wrk_drop                     N dropped work requests

n_backend                      N backends

n_expired                      N expired objects

n_lru_nuked                    N LRU nuked objects

n_lru_moved                    N LRU moved objects

losthdr                        HTTP header overflows

n_objsendfile                  Objects sent with sendfile

n_objwrite                     Objects sent with write

n_objoverflow                  Objects overflowing workspace

s_sess                         Total Sessions

s_req                          Total Requests

s_pipe                         Total pipe

s_pass                         Total pass

s_fetch                        Total fetch

s_hdrbytes                     Total header bytes

s_bodybytes                    Total body bytes

sess_closed                    Session Closed

sess_pipeline                  Session Pipeline

sess_readahead                 Session Read Ahead

sess_linger                    Session Linger

sess_herd                      Session herd

shm_records                    SHM records

shm_writes                     SHM writes

shm_flushes                    SHM flushes due to overflow

shm_cont                       SHM MTX contention

shm_cycles                     SHM cycles through buffer

sms_nreq                       SMS allocator requests

sms_nobj                       SMS outstanding allocations

sms_nbytes                     SMS outstanding bytes

sms_balloc                     SMS bytes allocated

sms_bfree                      SMS bytes freed

backend_req                    Backend requests made

n_vcl                          N vcl total

n_vcl_avail                    N vcl available

n_vcl_discard                  N vcl discarded

n_ban                          N total active bans

n_ban_gone                     N total gone bans

n_ban_add                      N new bans added

n_ban_retire                   N old bans deleted

n_ban_obj_test                 N objects tested

n_ban_re_test                  N regexps tested against

n_ban_dups                     N duplicate bans removed

hcb_nolock                     HCB Lookups without lock

hcb_lock                       HCB Lookups with lock

hcb_insert                     HCB Inserts

esi_errors                     ESI parse errors (unlock)

esi_warnings                   ESI parse warnings (unlock)

accept_fail                    Accept failures

client_drop_late               Connection dropped late

uptime                         Client uptime

dir_dns_lookups                DNS director lookups

dir_dns_failed                 DNS director failed lookups

dir_dns_hit                    DNS director cached lookups hit

dir_dns_cache_full             DNS director full dnscache

vmods                          Loaded VMODs

n_gzip                         Gzip operations

n_gunzip                       Gunzip operations

sess_pipe_overflow             Dropped sessions due to session pipe overflow

LCK.sms.creat                  Created locks

LCK.sms.destroy                Destroyed locks

LCK.sms.locks                  Lock Operations

LCK.sms.colls                  Collisions

LCK.smp.creat                  Created locks

LCK.smp.destroy                Destroyed locks

LCK.smp.locks                  Lock Operations

LCK.smp.colls                  Collisions

LCK.sma.creat                  Created locks

LCK.sma.destroy                Destroyed locks

LCK.sma.locks                  Lock Operations

LCK.sma.colls                  Collisions

LCK.smf.creat                  Created locks

LCK.smf.destroy                Destroyed locks

LCK.smf.locks                  Lock Operations

LCK.smf.colls                  Collisions

LCK.hsl.creat                  Created locks

LCK.hsl.destroy                Destroyed locks

LCK.hsl.locks                  Lock Operations

LCK.hsl.colls                  Collisions

LCK.hcb.creat                  Created locks

LCK.hcb.destroy                Destroyed locks

LCK.hcb.locks                  Lock Operations

LCK.hcb.colls                  Collisions

LCK.hcl.creat                  Created locks

LCK.hcl.destroy                Destroyed locks

LCK.hcl.locks                  Lock Operations

LCK.hcl.colls                  Collisions

LCK.vcl.creat                  Created locks

LCK.vcl.destroy                Destroyed locks

LCK.vcl.locks                  Lock Operations

LCK.vcl.colls                  Collisions

LCK.stat.creat                 Created locks

LCK.stat.destroy               Destroyed locks

LCK.stat.locks                 Lock Operations

LCK.stat.colls                 Collisions

LCK.sessmem.creat              Created locks

LCK.sessmem.destroy            Destroyed locks

LCK.sessmem.locks              Lock Operations

LCK.sessmem.colls              Collisions

LCK.wstat.creat                Created locks

LCK.wstat.destroy              Destroyed locks

LCK.wstat.locks                Lock Operations

LCK.wstat.colls                Collisions

LCK.herder.creat               Created locks

LCK.herder.destroy             Destroyed locks

LCK.herder.locks               Lock Operations

LCK.herder.colls               Collisions

LCK.wq.creat                   Created locks

LCK.wq.destroy                 Destroyed locks

LCK.wq.locks                   Lock Operations

LCK.wq.colls                   Collisions

LCK.objhdr.creat               Created locks

LCK.objhdr.destroy             Destroyed locks

LCK.objhdr.locks               Lock Operations

LCK.objhdr.colls               Collisions

LCK.exp.creat                  Created locks

LCK.exp.destroy                Destroyed locks

LCK.exp.locks                  Lock Operations

LCK.exp.colls                  Collisions

LCK.lru.creat                  Created locks

LCK.lru.destroy                Destroyed locks

LCK.lru.locks                  Lock Operations

LCK.lru.colls                  Collisions

LCK.cli.creat                  Created locks

LCK.cli.destroy                Destroyed locks

LCK.cli.locks                  Lock Operations

LCK.cli.colls                  Collisions

LCK.ban.creat                  Created locks

LCK.ban.destroy                Destroyed locks

LCK.ban.locks                  Lock Operations

LCK.ban.colls                  Collisions

LCK.vbp.creat                  Created locks

LCK.vbp.destroy                Destroyed locks

LCK.vbp.locks                  Lock Operations

LCK.vbp.colls                  Collisions

LCK.vbe.creat                  Created locks

LCK.vbe.destroy                Destroyed locks

LCK.vbe.locks                  Lock Operations

LCK.vbe.colls                  Collisions

LCK.backend.creat              Created locks

LCK.backend.destroy            Destroyed locks

LCK.backend.locks              Lock Operations

LCK.backend.colls              Collisions

SMA.s0.c_req                   Allocator requests

SMA.s0.c_fail                  Allocator failures

SMA.s0.c_bytes                 Bytes allocated

SMA.s0.c_freed                 Bytes freed

SMA.s0.g_alloc                 Allocations outstanding

SMA.s0.g_bytes                 Bytes outstanding

SMA.s0.g_space                 Bytes available

SMA.Transient.c_req            Allocator requests

SMA.Transient.c_fail           Allocator failures

SMA.Transient.c_bytes          Bytes allocated

SMA.Transient.c_freed          Bytes freed

SMA.Transient.g_alloc          Allocations outstanding

SMA.Transient.g_bytes          Bytes outstanding

SMA.Transient.g_space          Bytes available

VBE.default(192.168.112.140,,80).vcls VCL references

VBE.default(192.168.112.140,,80).happy Happy health probes

VBE.web1(192.168.112.140,,80).vcls VCL references

VBE.web1(192.168.112.140,,80).happy Happy health probes

VBE.web2(192.168.112.130,,80).vcls VCL references

VBE.web2(192.168.112.130,,80).happy Happy health probes

VBE.appsvr(192.168.112.140,,80).vcls VCL references

VBE.appsvr(192.168.112.140,,80).happy Happy health probes

VBE.static(192.168.112.130,,80).vcls VCL references

VBE.static(192.168.112.130,,80).happy Happy health probes


varnishlog

[root@node200 ~]# service varnishlog start

Starting varnish logging daemon:                           [确定]

[root@node200 ~]# service varnishlog stop

Stopping varnish logging daemon:                           [确定]