Varnish忽略/ etc / default / varnish中的设置

时间:2017-01-08 22:34:45

标签: ubuntu varnish

Varnish 4.1.1完全忽略Ubuntu 16.04 LTS上/ etc / default / varnish文件中的设置。我正在寻找解决方案。

/bin/systemctl status varnish.service

的结果
Warning: Journal has been rotated since unit was started. Log output is incomple
lines 1-14/14 (END)
● varnish.service - Varnish HTTP accelerator
   Loaded: loaded (/lib/systemd/system/varnish.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2017-01-09 01:24:09 UTC; 15h ago
     Docs: https://www.varnish-cache.org/docs/4.1/
           man:varnishd
 Main PID: 9470 (varnishd)
    Tasks: 218
   Memory: 67.5M
      CPU: 45.584s
   CGroup: /system.slice/varnish.service
           ├─9470 /usr/sbin/varnishd -j unix,user=vcache -F -a :6081 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret
           └─9483 /usr/sbin/varnishd -j unix,user=vcache -F -a :6081 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

3 个答案:

答案 0 :(得分:0)

默认情况下,Varnish会尝试加载位于此路径default.vcl的{​​{1}},如下所示:

/etc/varnish/default.vcl

如果您要加载另一个位于其他路径的文件,则需要打开此文件CGroup: /system.slice/varnish.service ├─9470 /usr/sbin/varnishd -j unix,user=vcache -F -a :6081 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret └─9483 /usr/sbin/varnishd -j unix,user=vcache -F -a :6081 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret 并修改此行的值:

/etc/varnish/varnish.params

这适用于Varnish 4 +

答案 1 :(得分:0)

这显然是上游Debian中的故意行为:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=749272

/ etc / default / varnish由/etc/init.d/varnish专门用于此目的。

"如果你想自己使用/ etc / default / varnish,你可以覆盖 /etc/systemd/system/varnish.service /etc/systemd/system/varnish.service,但我建议您只需编写所需的命令行选项 /etc/systemd/system/varnish.service,而不是阅读/ etc / default / varnish"

varnish.service采用.INI格式。本教程为Debian提供了一个示例:http://deshack.net/how-to-varnish-listen-port-80-systemd/

Varnish在官方文档中添加了:

https://www.varnish-cache.org/docs/trunk/tutorial/putting_varnish_on_port_80.html#debian-v8-ubuntu-v15-04

e.g。我刚刚在16.04设置的Varnish上的varnish.service有这一行(该框称为cache1):

ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -s file,/var/lib/varnish/cache1/varnish_storage.bin,85G -n cache1

一旦您更改了,请不要忘记重新加载systemd:

systemctl daemon-reload

然后重新启动Varnish。使用/ bin / systemctl status varnish.service检查结果。

tl; dr 您需要将配置放在两个位置。

答案 2 :(得分:0)

在Ubuntu 19.04上:

sudo vi /etc/systemd/system/multi-user.target.wants/varnish.service(更改端口)

sudo systemctl守护进程重新加载&& sudo systemctl重新启动清漆&& sudo systemctl状态清漆

curl本地主机