无法打开清漆日志(不是VSL块)

时间:2016-01-13 08:06:08

标签: magento varnish

我试图使用Magento运行Varnish,但似乎甚至无法使用最基本的Varnish配置HIT缓存(删除所有缓存标头和Cookie)。

运行varnishlog(有或没有sudo)时,我总是收到此错误消息:

Can't open log (Not a VSL chunk
)

Varnish肯定正在运行并按预期工作作为代理(我在Chrome Inspector中看到了Varnish-Headers)。

我正在运行Varnish 4.0.3-2~可靠,这是我的VCL:

vcl 4.0;

backend default {
    .host = "127.0.0.1";
    .port = "8080";
}

sub vcl_recv {
    unset req.http.cookie;
}

sub vcl_backend_response {
    set beresp.do_esi = true;
    unset beresp.http.set-cookie;

    if (beresp.ttl < 120s) {
        set beresp.ttl = 120s;
        unset beresp.http.Cache-Control;
    }
}

sub vcl_deliver {

}

1 个答案:

答案 0 :(得分:4)

你有不同版本的varnish和libvarnishapi1(这是Ubuntu,RedHat可能有不同的包名)。

# varnishtop
Can't open log (Not a VSL chunk
)

# dpkg -s varnish
Package: varnish
Status: install ok installed
Priority: optional
Section: varnish-4.0/web
Installed-Size: 1501
Maintainer: Varnish Package Maintainers <varnish-dist@varnish-cache.org>
Architecture: amd64
Source: varnish (4.0.3-2)
Version: 4.0.3-2~precise
Provides: varnish, varnishabi-1.2, varnishabi-strict-b8c4a34
Depends: libc6 (>= 2.14), libedit2 (>= 2.11-20080614-1), libjemalloc1 (>= 2.1.1), libncurses5 (>= 5.5-5~), libpcre3 (>= 8.10), libtinfo5, libvarnishapi1 (>= 4.0.3-2~precise), adduser, gcc, libc6-dev | libc6.1-dev | libc-dev
Suggests: varnish-doc
Conffiles:
 /etc/init.d/varnishlog 3140554883a28e29559798a3213c143a
 /etc/init.d/varnishncsa bd1d80256f5c845539c366a735006bb0
 /etc/init.d/varnish b271bbb97276346e35f538bc9cbafb9f
 /etc/logrotate.d/varnish 95fbe75ebf5104ecaa532e7876d4ac8b
 /etc/varnish/default.vcl 43f33efc867d0ecd6f2ab08878a936bb
 /etc/default/varnishlog 71b0d3e5cc0b90cfb4461f76272578a5
 /etc/default/varnishncsa 3d10b15a363d07252122cef47c88ba9b
 /etc/default/varnish dce6e7d01bb20e598f417131c1d5a1c6
Description: state of the art, high-performance web accelerator
 Varnish Cache is a state of the art web accelerator written with
 performance and flexibility in mind.
 .
 Varnish Cache stores web pages in memory so web servers don't have to
 create the same web page over and over again. Varnish serves pages
 much faster than any application server; giving the website a
 significant speed up.
 .
 Some of the features include:
  * A modern design
  * VCL - a very flexible configuration language
  * Load balancing with health checking of backends
  * Partial support for ESI - Edge Side Includes
  * URL rewriting
  * Graceful handling of "dead" backends
Homepage: https://varnish-cache.org/

# dpkg -s libvarnishapi1
Package: libvarnishapi1
Status: install ok installed
Priority: optional
Section: varnish-4.1/libs
Installed-Size: 202
Maintainer: Varnish Package Maintainers <varnish-dist@varnish-cache.org>
Architecture: amd64
Source: varnish (4.1.0-1)
Version: 4.1.0-1~precise
Provides: libvarnish1
Depends: libc6 (>= 2.14), libpcre3 (>= 8.10)
Pre-Depends: multiarch-support
Conflicts: libvarnish1
Description: shared libraries for Varnish
 Shared libraries for Varnish Cache HTTP accelerator.
Homepage: https://varnish-cache.org/

在这里你可以看到安装了varnish 4.0.3但安装了libvarnishapi1 4.1给出错误。要解决此问题,您需要安装相同的版本,因此请查看我们提供的版本:

# apt-cache policy libvarnishapi1
libvarnishapi1:
  Installed: 4.1.0-1~precise
  Candidate: 4.1.0-1~precise
  Version table:
 *** 4.1.0-1~precise 0
        100 /var/lib/dpkg/status
     4.0.3-2~precise 0
        500 http://repo.varnish-cache.org/ubuntu/ precise/varnish-4.0 amd64 Packages
     4.0.3-1~precise 0
        500 http://repo.varnish-cache.org/ubuntu/ precise/varnish-4.0 amd64 Packages
     4.0.2-1~precise 0
        500 http://repo.varnish-cache.org/ubuntu/ precise/varnish-4.0 amd64 Packages
     4.0.1-2~precise 0
        500 http://repo.varnish-cache.org/ubuntu/ precise/varnish-4.0 amd64 Packages
     4.0.1-1~precise 0
        500 http://repo.varnish-cache.org/ubuntu/ precise/varnish-4.0 amd64 Packages
     4.0.0-1~precise 0
        500 http://repo.varnish-cache.org/ubuntu/ precise/varnish-4.0 amd64 Packages
     4.0.0~beta1-2~precise 0
        500 http://repo.varnish-cache.org/ubuntu/ precise/varnish-4.0 amd64 Packages
     4.0.0~~tp2-1~precise 0
        500 http://repo.varnish-cache.org/ubuntu/ precise/varnish-4.0 amd64 Packages
     4.0.0~~tp1-1~precise 0
        500 http://repo.varnish-cache.org/ubuntu/ precise/varnish-4.0 amd64 Packages
     3.0.2-1ubuntu0.1 0
        500 http://mirror.bytemark.co.uk/ubuntu/ precise-updates/universe amd64 Packages
     3.0.2-1 0
        500 http://mirror.bytemark.co.uk/ubuntu/ precise/universe amd64 Packages

现在我们想要4.0.3-2~精确的一个(与清漆相同)

# apt-get install libvarnishapi1=4.0.3-2~precise
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  liblwgeom-2.1.7 python-meld3 python-medusa
Use 'apt-get autoremove' to remove them.
The following packages will be DOWNGRADED:
  libvarnishapi1
0 to upgrade, 0 to newly install, 1 to downgrade, 0 to remove and 123 not to upgrade.
Need to get 70.6 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://repo.varnish-cache.org/ubuntu/ precise/varnish-4.0 libvarnishapi1 amd64 4.0.3-2~precise [70.6 kB]
Fetched 70.6 kB in 0s (321 kB/s)
Committing  to: /etc/
modified default/varnish
modified varnish/default.vcl
modified varnish/secret
Committed revision 357.
dpkg: warning: downgrading libvarnishapi1 from 4.1.0-1~precise to 4.0.3-2~precise.
(Reading database ... 138915 files and directories currently installed.)
Preparing to replace libvarnishapi1 4.1.0-1~precise (using .../libvarnishapi1_4.0.3-2~precise_amd64.deb) ...
Unpacking replacement libvarnishapi1 ...
Setting up libvarnishapi1 (4.0.3-2~precise) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

varnishtop / varnishlog等现在正常工作