3

We're trying to setup a varnish on a Cent OS 6.5 64 but can't get it working as a service. What could be the reason for the following error?

[root@server]# service varnish start
Starting Varnish Cache: 0
                                                           [FAILED]

This works perfect, it's the same args as in DAEMON_OPTS in the config.

varnishd -a :80 -T localhost:6082 -b localhost:8080 -u varnish -g varnish  -s file,/var/lib/varnish/varnish_storage.bin,1G

I found some information on how to debug in the varnish forum which gives me this:

[root@server]# varnishd -C -f /etc/sysconfig/varnish
Message from VCC-compiler:
VCL version declaration missing
Update your VCL to Version 4 syntax, and add
    vcl 4.0;
on the first line the VCL files.
('input' Line 8 Pos 1)
NFILES=131072
######-------

Running VCC-compiler failed, exit 1

VCL compilation failed

But we're not using any VCL so why is it complaining about VCL?

The varnish config file:

# Configuration file for varnish
#
# /etc/init.d/varnish expects the variable $DAEMON_OPTS to be set from this
# shell script fragment.
#

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

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

# Maximum number of threads (for ulimit -u)
NPROCS="unlimited"

# Maximum size of corefile (for ulimit -c). Default in Fedora is 0
# DAEMON_COREFILE_LIMIT="unlimited"

# Set this to 1 to make init script reload try to switch vcl without restart.
# To make this work, you need to set the following variables
# explicit: VARNISH_VCL_CONF, VARNISH_ADMIN_LISTEN_ADDRESS,
# VARNISH_ADMIN_LISTEN_PORT, VARNISH_SECRET_FILE, or in short,
# use Alternative 3, Advanced configuration, below
#RELOAD_VCL=1

# This file contains 4 alternatives, please use only one.

## Alternative 1, Minimal configuration, no VCL
#
# Listen on port 6081, administration on localhost:6082, and forward to
# content server on localhost:8080.  Use a fixed-size cache file.
#
DAEMON_OPTS="-a :80 -T localhost:6082 -b localhost:8080 -u varnish -g varnish  -s file,/var/lib/varnish/varnish_storage.bin,1G"


## Alternative 2, Configuration with VCL
#
# Listen on port 6081, administration on localhost:6082, and forward to
# one content server selected by the vcl file, based on the request.  Use a
# fixed-size cache file.
#
# DAEMON_OPTS="-a :80 -T localhost:6699 -f /etc/varnish/default.vcl -u varnish -g varnish -S /etc/varnish/secret -s malloc,1G"


## Alternative 3, Advanced configuration
#
# See varnishd(1) for more information.
#
# # Main configuration file. You probably want to change it :)
#VARNISH_VCL_CONF=/etc/varnish/default.vcl
#
# # Default address and port to bind to
# # Blank address means all IPv4 and IPv6 interfaces, otherwise specify
# # a host name, an IPv4 dotted quad, or an IPv6 address in brackets.
# VARNISH_LISTEN_ADDRESS=
#VARNISH_LISTEN_PORT=80
#
# # Telnet admin interface listen address and port
#VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
#VARNISH_ADMIN_LISTEN_PORT=6082
#
# # Shared secret file for admin interface
#VARNISH_SECRET_FILE=/etc/varnish/secret
#
# # The minimum number of worker threads to start
#VARNISH_MIN_THREADS=50
#
# # The Maximum number of worker threads to start
#VARNISH_MAX_THREADS=1000
#
# # Idle timeout for worker threads
#VARNISH_THREAD_TIMEOUT=120
#
# # Cache file size: in bytes, optionally using k / M / G / T suffix,
# # or in percentage of available disk space using the % suffix.
#VARNISH_STORAGE_SIZE=256M
#
# # Backend storage specification
#VARNISH_STORAGE="malloc,${VARNISH_STORAGE_SIZE}"
#
# # Default TTL used when the backend does not specify one
VARNISH_TTL=120
#
# # DAEMON_OPTS is used by the init script.  If you add or remove options, make
# # sure you update this section, too.
#DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
#             -f ${VARNISH_VCL_CONF} \
#             -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
#             -t ${VARNISH_TTL} \
#             -p thread_pool_min=${VARNISH_MIN_THREADS} \
#             -p thread_pool_max=${VARNISH_MAX_THREADS} \
#             -p thread_pool_timeout=${VARNISH_THREAD_TIMEOUT} \
#             -u varnish -g varnish \
#             -S ${VARNISH_SECRET_FILE} \
#             -s ${VARNISH_STORAGE}"
#


## Alternative 4, Do It Yourself. See varnishd(1) for more information.
#
# DAEMON_OPTS=""

Note: The /var/log/varnish is also empty and gives no clues.

UPDATE:

[root@server]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 54665
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 54665
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

UPDATE 2:

Varnish starts if I do this:

bash -x /etc/init.d/varnish start

but not

/etc/init.d/varnish start

What makes the difference?

6
  • which version of varnish are you using?And what is the output of ulimit -a command Jul 23, 2014 at 10:32
  • And also check /etc/varnish/default.vcl for vcl file Jul 23, 2014 at 10:39
  • @TBIInfotech Varnish 4.0.el6 and I've updated the question with ulimit -a output. Jul 23, 2014 at 10:44
  • @TBIInfotech yes, the default.vcl starts with "vcl 4.0;" on the first line, top of file. But why does varnish care about that when we're using Alternative 1 without a VCL file? Jul 23, 2014 at 10:44
  • check it by increasing the ulimit value open files Jul 23, 2014 at 12:38

4 Answers 4

1

I ran into the very same issue, I found the cause.

It is caused by SELinux, you can disable it temporary with echo 0 >/selinux/enforce but this is not recommended and you should create a policy file for it to run. I might come back to this when I have some free time.

0

Execute bash -x /etc/init.d/varnish restart to find with what options varnish really tries to start, and then try running with them on cli.

3
  • Can't find anything other than what I already tried. It runs the same commands as I tried as far as I can see? pastebin.com/Y9bD7iM9 Jul 23, 2014 at 12:38
  • I updated the question. I can actually start varnish if I do just "start" with bash -x, but not restart and not without bash? Jul 23, 2014 at 15:01
  • You started varnish without all the daemon options so it is not comparable
    – eckes
    Apr 26, 2017 at 9:26
0

assuming you did NOT alter your init.d's Varnish script (try md5 it)

[root@6svprx01 ~]# head -1 /etc/init.d/varnish
#! /bin/sh
[root@6svprx01 ~]# rpm -q varnish
varnish-3.0.6-1.el5.centos.x86_64
[root@6svprx01 ~]# md5sum /etc/init.d/varnish
a69b3b55a8d5da5b9b9c24a62774aa80  /etc/init.d/varnish
[root@6svprx01 ~]# service varnish 
Usage: /etc/init.d/varnish {start|stop|status|restart|condrestart|try-restart|reload|force-reload}
[root@6svprx01 ~]# service varnish status
varnishd (pid  6188) is running...
[root@6svprx01 ~]# 

also:

varnishd -C -f /etc/sysconfig/varnish

is incorrect, it should be:

varnishd -C -f /etc/varnish/default.vcl

0

I was having similar issue and found that with Ubuntu (I know this is CentOs but i think it might still be helpful) i needed to configure how the service starts within /etc/systemd/system/varnish.service.d/override.conf similar to below:

ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,1024m

This was in place of setting the daemon configurations /etc/default/varnish which just didn't seem to work for me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .