简体   繁体   English

清漆缓存日志不起作用

[英]Varnish Cache log not working

varnishlog is returning: varnishlog返回:

_.vsm: No such file or directory

Has anyone else seen this before? 有人看过吗?

It looks like varnishlog is not pointing to the correct directory, or has not access to it. 看起来varnishlog没有指向正确的目录,或者无法访问它。

Please check the command line options of varnishd . 请检查varnishd的命令行选项。 If the deamon run with -n <instancename> argument, you have to add it to varnishlog as well. 如果守护程序使用-n <instancename>参数运行,则还必须将其添加到varnishlog中。

The second thing, is to see the permissions of varnish directory. 第二件事,是查看清漆目录的权限。 In order to see the current directory used, you must log into root and run the command below : 为了查看当前使用的目录,您必须登录到root并运行以下命令:

$ lsof -p <PID of varnishd> | grep vsm

Once revealed, you just had to be sure the full path has read permission for your user. 一旦显示出来,您只需要确保完整路径具有用户的读取权限即可。

In Varnish 4.1 the root cause can be due to incorrect rights for reading _.vsm file. 在Varnish 4.1中,根本原因可能是由于读取_.vsm文件的权限不正确。 For example: 例如:

# service varnishncsa start
 * Starting HTTP accelerator log deamon                                                                                                                                                               [fail] 
Can't open log - retrying for 5 seconds
Can't open VSM file (Cannot open /var/lib/varnish/dev-me/_.vsm: Permission denied

Varnishncsa works from varnishlog user. Varnishncsa来自varnishlog用户。 But /var/lib/varnish/dev-me/_.vsm can be readable from varnish group or root user only: 但是/var/lib/varnish/dev-me/_.vsm只能从varnish组或root用户读取:

# ls -l /var/lib/varnish/dev-me/_.vsm
-rw-r----- 1 root varnish 84934656 Apr 15 05:58 /var/lib/varnish/dev-me/_.vsm

So you can fix this problem in the following way: 因此,您可以通过以下方式解决此问题:

# usermod -a -G varnish varnishlog
# id varnishlog
uid=110(varnishlog) gid=116(varnishlog) groups=116(varnishlog),115(varnish)

And now you can start varnishncsa. 现在您可以启动varnishncsa。

In our case the hostname of the server was changed. 在本例中,服务器的主机名已更改。

If you do not specify an instance name, varnish uses the hostname. 如果您未指定实例名称,则varnish将使用主机名。 It was looking for a directory holding the shared memory logging configuration with the new hostname, but the instance was still running from the directory with the old hostname. 它正在寻找一个目录,该目录包含具有新主机名的共享内存日志记录配置,但是该实例仍在具有旧主机名的目录中运行。

Restarting varnish solved the problem. 重启清漆解决了问题。

I just had the same error message while trying to issue varnishadm commands. 尝试发出varnishadm命令时,我遇到了同样的错误消息。 Turned out that I renamed my machine without stopping varnish. 原来,我重命名了我的机器而没有停止清漆。 There was some directory in /var/varnish/ corresponding to the machine name that varnish needed access to. / var / varnish /中有一些目录与varnish需要访问的机器名称相对应。 "sudo service varnish restart" fixed this for me. “ sudo服务清漆重新启动”为我修复了此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM