【问题标题】:varnish service has failed to startvarnish 服务启动失败
【发布时间】:2021-11-30 10:26:09
【问题描述】:

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

$varnishd -V varnishd 

(varnish-6.0.8 修订版 97e54ada6ac578af332e52b44d2038bb4fa4cd4a) 版权所有 (c) 2006 Verdens Gang AS 版权所有 (c) 2006-2020 Varnish 软件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

mY 清漆状态...

$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 特征=+http2 -f /etc/varnish/default.vcl -s malloc,256m (代码=退出,状态=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 10 月 11 日 18:54:19 server1.清漆[1765617]: ('/etc/varnish/default.vcl' Oct 11 18:54:19 server1. varnishd [1765617]:后端默认 { Oct 11 18:54:19 server1. 清漆 [1765617]:#######---------- 10 月 11 日 18:54:19 server1。 varnishd [1765617]:运行 VCC 编译器失败,10 月 11 日 18:54:19 服务器1。 varnishd[1765617]:VCL 编译失败 10 月 11 日 18:54:19 服务器 1。 systemd[1]: varnish.service: 控制进程 前 10 月 11 日 18:54:19 server1。 systemd[1]: 启动失败 清漆缓存,嗨主题:单元清漆服务失败 定义者:systemd 支持: http://lists.freedesktop.org/mailman/listinfo/systemd-devel单位 varnish.service 失败。结果失败了。 10 月 11 日 18:54:19 服务器1。 systemd[1]: Unit varnish.service 输入失败 11 18:54:19 服务器1。 systemd[1]: varnish.service 失败。十月 11 18:54:19 服务器1。 polkitd[533]:未注册的身份验证 代理 10 月 11 日 18:54:24 server1。鸽舍 [506582]: lmtp(1764533): 从 lo Oct 11 18:54:24 server1 连接。鸽舍[506582]: lmtp(develop@wordwpressplugins 10 月 11 日 18:54:24 server1. dovecot[506582]: lmtp(1764533): 断开连接

谢谢你

【问题讨论】:

    标签: varnish


    【解决方案1】:

    我的假设

    以下错误消息很明显:

    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;

    【讨论】:

    • 非常感谢您的帮助。正如你所建议的,我添加了“vcl 4.1;” /etc/varnish/default.vcl 的行解决了这个问题。现在我可以毫无问题地启动 Varnish。
    猜你喜欢
    • 2013-01-12
    • 2017-08-08
    • 2020-05-23
    • 2016-12-30
    • 2016-07-04
    • 2013-08-11
    • 2017-01-11
    • 1970-01-01
    相关资源
    最近更新 更多