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.
最佳答案
这显然是上游 Debian 中的故意行为:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=749272
/etc/default/varnish 专门由/etc/init.d/varnish 使用。
"如果你想自己使用/etc/default/varnish,你可以覆盖 /lib/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在官方文档中添加了:
例如我刚刚在 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您需要将您的配置放在两个地方。
关于ubuntu - Varnish 忽略/etc/default/varnish 中的设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41538633/