helen's blog

ずっとおもしろいことしてたいな。

Varnishをアップデートすると設定値が反映されなくなる

という問い合わせを受けて調べた

環境

  • CentOS 7
  • Varnish
    • 6.0.1 から6.0.3にバージョンをあげようとしている

事前確認

$ varnishd -V
varnishd (varnish-6.0.1 revision 8d54bec5330c29304979ebf2c425ae14ab80493c)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2015 Varnish Software AS

バージョン上げ

下記で実施

Install Howto

1. Install GetPageSpeed repository:
# yum install https://extras.getpagespeed.com/release-el7-latest.rpm

2. Install varnish rpm package:
# yum install --enablerepo=getpagespeed-extras-varnish60 varnish

centos.pkgs.org

こうなる

$ varnishd -V
varnishd (varnish-6.0.3 revision 7d1ded3aa033a018317dbafc61587026ea2ef8a3)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2019 Varnish Software AS

このあとに再起動するとなぜか /etc/varnish/varnish.params が反映されなくなる

book.varnish-software.com

↑ だとバージョンは古いけど、
CentOSなら /etc/varnish/varnish.params が読まれるみたいなのになぁ

原因

/lib/systemd/system/varnish.service の ExecStart が変わってる!!

before
[Unit]
Description=Varnish Cache, a high-performance HTTP accelerator
After=network.target

[Service]
# If you want to make changes to this file, please copy it to
# /etc/systemd/system/varnish.service and make your changes there.
# This will override the file kept at /lib/systemd/system/varnish.service
#
# Environment variables may be found in /etc/varnish/varnish.params
#

# Maximum number of open files (for ulimit -n)
LimitNOFILE=131072

# Locked shared memory (for ulimit -l)
# Default log size is 82MB + header
LimitMEMLOCK=85983232

# On systemd >= 228 enable this to avoid "fork failed" on reload.
#TasksMax=infinity

# Maximum size of the corefile.
LimitCORE=infinity

EnvironmentFile=/etc/varnish/varnish.params

Type=forking
PIDFile=/var/run/varnish.pid
PrivateTmp=true
ExecStart=/usr/sbin/varnishd \
	-P /var/run/varnish.pid \
	-f $VARNISH_VCL_CONF \
	-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
	-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
	-S $VARNISH_SECRET_FILE \
	-s $VARNISH_STORAGE \
	$DAEMON_OPTS

ExecReload=/usr/sbin/varnish_reload_vcl

[Install]
WantedBy=multi-user.target
after
[Unit]
Description=Varnish Cache, a high-performance HTTP accelerator
After=network-online.target

[Service]
Type=forking
KillMode=process

# Maximum number of open files (for ulimit -n)
LimitNOFILE=131072

# Locked shared memory - should suffice to lock the shared memory log
# (varnishd -l argument)
# Default log size is 80MB vsl + 1M vsm + header -> 82MB
# unit is bytes
LimitMEMLOCK=85983232

# Enable this to avoid "fork failed" on reload.
TasksMax=infinity

# Maximum size of the corefile.
LimitCORE=infinity

ExecStart=/usr/sbin/varnishd -a :6081 -f /etc/varnish/default.vcl -s malloc,256m
ExecReload=/usr/sbin/varnishreload

[Install]
WantedBy=multi-user.target

Release Noteには何もなかった
なんだったんだろう

原因がわかるとなんだそれだけかってなるね