首页 > 解决方案 > varnish 服务启动失败

问题描述

尝试在 cpanel+cloudlinux VPS 上安装 varnish 但无法启动软件。varnish.service 失败。

$varnishd -V varnishd 

(varnish-6.0.8 修订版 97e54ada6ac578af332e52b44d2038bb4fa4cd4a) 版权所有 (c) 2006 Verdens Gang AS 版权所有 (c) 2006-2020 Varnish Software AS

尝试开始清漆...

$systemctl start varnish

varnish.service 的作业失败,因为控制进程以错误代码退出。有关详细信息,请参阅“systemctl status varnish.service”和“journalctl -xe”。

我的 apache 在端口 8080 上列出...

$netstat -pnltu

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:587             0.0.0.0:*               LISTEN      656/exim
tcp        0      0 127.0.0.1:11211         0.0.0.0:*               LISTEN      1272/memcached
tcp        0      0 0.0.0.0:110             0.0.0.0:*               LISTEN      1275/dovecot
tcp        0      0 0.0.0.0:2095            0.0.0.0:*               LISTEN      337953/cpsrvd
tcp        0      0 127.0.0.1:783           0.0.0.0:*               LISTEN      1499/perl
tcp        0      0 0.0.0.0:143             0.0.0.0:*               LISTEN      1275/dovecot
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      830454/httpd
tcp        0      0 0.0.0.0:2096            0.0.0.0:*               LISTEN      337953/cpsrvd
tcp        0      0 0.0.0.0:465             0.0.0.0:*               LISTEN      656/exim
tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      1290/pdns_server
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      1276/pure-ftpd (SER
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      656/exim
tcp        0      0 127.0.0.1:953           0.0.0.0:*               LISTEN      1290/pdns_server
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      830454/httpd
tcp        0      0 0.0.0.0:38908           0.0.0.0:*               LISTEN      1225059/checkstatus
tcp        0      0 0.0.0.0:2077            0.0.0.0:*               LISTEN      2364/cpdavd - accep
tcp        0      0 0.0.0.0:2078            0.0.0.0:*               LISTEN      2364/cpdavd - accep
tcp        0      0 0.0.0.0:2079            0.0.0.0:*               LISTEN      2364/cpdavd - accep
tcp        0      0 0.0.0.0:2080            0.0.0.0:*               LISTEN      2364/cpdavd - accep
tcp        0      0 0.0.0.0:993             0.0.0.0:*               LISTEN      1275/dovecot
tcp        0      0 0.0.0.0:2082            0.0.0.0:*               LISTEN      337953/cpsrvd
tcp        0      0 0.0.0.0:2083            0.0.0.0:*               LISTEN      337953/cpsrvd
tcp        0      0 127.0.0.1:579           0.0.0.0:*               LISTEN      1939/cPhulkd - proc
tcp        0      0 0.0.0.0:995             0.0.0.0:*               LISTEN      1275/dovecot
tcp        0      0 0.0.0.0:2086            0.0.0.0:*               LISTEN      337953/cpsrvd
tcp        0      0 0.0.0.0:36454           0.0.0.0:*               LISTEN      5439/sshd
tcp        0      0 0.0.0.0:2087            0.0.0.0:*               LISTEN      337953/cpsrvd
tcp6       0      0 :::3306                 :::*                    LISTEN      1215674/mysqld
tcp6       0      0 :::587                  :::*                    LISTEN      656/exim
tcp6       0      0 :::465                  :::*                    LISTEN      656/exim
tcp6       0      0 :::53                   :::*                    LISTEN      1290/pdns_server
tcp6       0      0 :::21                   :::*                    LISTEN      1276/pure-ftpd (SER
tcp6       0      0 :::4949                 :::*                    LISTEN      749/perl
tcp6       0      0 :::25                   :::*                    LISTEN      656/exim
tcp6       0      0 :::36454                :::*                    LISTEN      5439/sshd
udp        0      0 0.0.0.0:53              0.0.0.0:*                           1290/pdns_server
udp        0      0 127.0.0.1:323           0.0.0.0:*                           571/chronyd
udp        0      0 127.0.0.1:11211         0.0.0.0:*                           1272/memcached
udp6       0      0 :::53                   :::*                                1290/pdns_server
udp6       0      0 ::1:323                 :::*                                571/chronyd

我的清漆状态...

$systemctl status varnish.service

varnish.service - Varnish Cache,一种高性能 HTTP 加速器已加载:已加载(/usr/lib/systemd/system/varnish.service;已禁用;供应商预设:已禁用)活动:自 2021 年星期五以来失败(结果:退出代码) -10-08 08:32:43 IDT;5分钟前 进程:1498287 ExecStart=/usr/sbin/varnishd -a :80 -a localhost:8443,PROXY -p feature=+http2 -f /etc/varnish/default.vcl -s malloc,256m (code=exited,状态=255)

和我的 /etc/varnish/default.vcl 文件...

$cat /etc/varnish/default.vcl

后端默认 { .host = "127.0.0.1"; .port = "8080";}

$journalctl -xe

10 月 11 日 18:54:19 服务器 1。varnishd[1765617]:将您的 VCL 更新到版本 4 Oct 11 18:54:19 server1。清漆[1765617]:vcl 4.1;10 月 11 日 18:54:19 服务器 1。varnishd[1765617]:在 VCL 的第一行 Oct 11 18:54:19 server1. varnishd[1765617]: ('/etc/varnish/default.vcl' Oct 11 18:54:19 server1.varnishd[1765617]: backend default { Oct 11 18:54:19 server1.varnishd[1765617]: ### ####--------- 10 月 11 日 18:54:19 server1.varnishd[1765617]:运行 VCC 编译器失败,10 月 11 日 18:54:19 server1.varnishd[1765617]:VCL 编译10 月 11 日 18:54:19 server1.systemd[1]: varnish.service: 控制进程前 10 月 11 日 18:54:19 server1.systemd[1]: 无法启动 Varnish Cache,嗨主题:Unit varnish.service定义失败:systemd 支持: http: //lists.freedesktop.org/mailman/listinfo/systemd-develUnit varnish.service 失败。结果失败了。10 月 11 日 18:54:19 服务器 1。systemd[1]: Unit varnish.service 在 10 月 11 日 18:54:19 server1 输入失败。systemd[1]: varnish.service 失败。10 月 11 日 18:54:19 服务器 1。polkitd [533]:未注册的身份验证代理 10 月 11 日 18:54:24 server1。dovecot [506582]:lmtp(1764533):从 lo Oct 11 18:54:24 server1 连接。dovecot[506582]: lmtp(develop@wordwpressplugins Oct 11 18:54:24 server1.dovecot[506582]: lmtp(1764533): 断开连接

感谢你

标签: varnish

解决方案


我的假设

以下错误消息很明显:

Oct 11 18:54:19 server1. varnishd[1765617]: Update your VCL to Version 4

它指的是您没有在 VCL 文件中指定 VCL 版本。

我的测试返回一个不同的错误:

但是,当它使用运行https://aws.amazon.com/marketplace/pp/prodview-ptcusqlqcvvki?sr=0-2&ref_=beagle&applicationId=AWSMPContessa的 AWS 实例对其进行测试时,我收到以下错误:

Oct 12 08:06:33  varnishd[44646]: Error:
Oct 12 08:06:33  varnishd[44646]: Message from VCC-compiler:
Oct 12 08:06:33  varnishd[44646]: VCL version declaration missing
Oct 12 08:06:33  varnishd[44646]: Update your VCL to Version 4 syntax, and add
Oct 12 08:06:33  varnishd[44646]:         vcl 4.1;
Oct 12 08:06:33  varnishd[44646]: on the first line of the VCL files.
Oct 12 08:06:33  varnishd[44646]: ('/etc/varnish/default.vcl' Line 1 Pos 1)
Oct 12 08:06:33  varnishd[44646]: backend default {
Oct 12 08:06:33  varnishd[44646]: #######----------
Oct 12 08:06:33  varnishd[44646]: Running VCC-compiler failed, exited with 2
Oct 12 08:06:33  varnishd[44646]: VCL compilation failed
Oct 12 08:06:33  systemd[1]: varnish.service: Control process exited, code=exited status=255
Oct 12 08:06:33  systemd[1]: varnish.service: Failed with result 'exit-code'.

如您所见,我在 AWS 上的 CloudLinux 8 cPanel 实例返回了更具体的错误消息。

怎么修

从 Varnish 4 开始,引入了 VCL 版本标签。您需要在 VCL 文件的开头指定它。

以下是我将如何重构您的示例:

vcl 4.1;

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

我使用vcl 4.1;VCL 版本标签是因为您运行的是 Varnish 6。早期版本的 Varnish 仅支持vcl 4.0;


推荐阅读