Editing Varnish

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 39: Line 39:
  
 
The log file is about 80MB in size and split into two parts. Half of the log file handles counters and stats, the other half actually logs what data has been requested. The log file is meant to be written to in RAM, not on disk so the information in the log can be very verbose since there is a low overhead to writing data to RAM versus writing data to disk. You can use utilities to parse this log data later on, or use something like varnishstat to view real time activity.  
 
The log file is about 80MB in size and split into two parts. Half of the log file handles counters and stats, the other half actually logs what data has been requested. The log file is meant to be written to in RAM, not on disk so the information in the log can be very verbose since there is a low overhead to writing data to RAM versus writing data to disk. You can use utilities to parse this log data later on, or use something like varnishstat to view real time activity.  
 +
 +
==Varnish 4.0 Configuration Files==
 +
 +
===Ubuntu and Debian Varnish Server Config===
 +
 +
On most Debian and Ubuntu servers you can find the main configuration file for varnish in
 +
<pre>
 +
vim /etc/default/varnish
 +
</pre>
 +
 +
===CentOS 6 and 7 Varnish Server Config===
 +
 +
On most CentOS 6.x  servers you can find the main configuration file for varnish in
 +
<pre>
 +
/etc/sysconfig/varnish
 +
</pre>
 +
 +
For CentOS 7 the file is located in
 +
<pre>
 +
/etc/varnish/varnish.params
 +
</pre>
 +
 +
===Varnish 4.0.3 CentOS 7 Main Configuration Options===
 +
 +
If you want to have Varnish use malloc storage you can edit '''/etc/varnish/varnish.params''' and change the storage option. In this example I am using 1GB of memory and the malloc storage option, by default Varnish will use the file backend by default.
 +
<pre>
 +
RELOAD_VCL=1
 +
 +
VARNISH_VCL_CONF=/etc/varnish/default.vcl
 +
 +
VARNISH_LISTEN_ADDRESS=$IP_Varnish_Should_Listen_On
 +
VARNISH_LISTEN_PORT=80
 +
 +
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
 +
VARNISH_ADMIN_LISTEN_PORT=6082
 +
 +
VARNISH_SECRET_FILE=/etc/varnish/secret
 +
 +
VARNISH_STORAGE="malloc,1G"
 +
 +
VARNISH_TTL=120
 +
 +
VARNISH_USER=varnish
 +
VARNISH_GROUP=varnish
 +
 +
VARNISH_STORAGE="malloc,512m"
 +
</pre>
  
 
==Varnish Storage Backends==
 
==Varnish Storage Backends==
Line 121: Line 168:
 
</pre>
 
</pre>
  
==Varnish Shared Memory Log==
 
  
The Varnish log, sometimes known as “shm-log” should always be stored in memory, and not on disk otherwise it could cause large amounts of IO. You should ensure that this log is indeed in memory by placing it on a tmpfs location in memory.
 
 
The shmlog usually is located in /var/lib/varnish and you can feel free to remove any data found in this directory if needed. Varnish suggests make sure this location is mounted on tmpfs by using /etc/fstab to make sure this gets mounted on server reboot / start.
 
 
According to the official Varnish documentation, some Linux distros will try to place the cache in the same directory as the shm-log, which Varnish does not suggest doing. If this is the case for you, you should move one of these files out of the directory so that the cache and log file are not located in the same directory.
 
  
 
'''Shared memory log''' -- Not much needs to be done with this besides making sure the log is stored in RAM (/dev/shm)
 
'''Shared memory log''' -- Not much needs to be done with this besides making sure the log is stored in RAM (/dev/shm)
 
==Varnish 4.0 Configuration Files==
 
 
===Ubuntu and Debian Varnish Server Config===
 
 
On most Debian and Ubuntu servers you can find the main configuration file for varnish in
 
<pre>
 
vim /etc/default/varnish
 
</pre>
 
 
===CentOS 6 and 7 Varnish Server Config===
 
 
On most CentOS 6.x  servers you can find the main configuration file for varnish in
 
<pre>
 
/etc/sysconfig/varnish
 
</pre>
 
 
For CentOS 7 the file is located in
 
<pre>
 
/etc/varnish/varnish.params
 
</pre>
 
 
===Varnish 4.0.3 CentOS 7 Main Configuration Options===
 
 
If you want to have Varnish use malloc storage you can edit '''/etc/varnish/varnish.params''' and change the storage option. In this example I am using 1GB of memory and the malloc storage option, by default Varnish will use the file backend by default.
 
<pre>
 
RELOAD_VCL=1
 
 
VARNISH_VCL_CONF=/etc/varnish/default.vcl
 
 
VARNISH_LISTEN_ADDRESS=$IP_Varnish_Should_Listen_On
 
VARNISH_LISTEN_PORT=80
 
 
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
 
VARNISH_ADMIN_LISTEN_PORT=6082
 
 
VARNISH_SECRET_FILE=/etc/varnish/secret
 
 
VARNISH_STORAGE="malloc,1G"
 
 
VARNISH_TTL=120
 
 
VARNISH_USER=varnish
 
VARNISH_GROUP=varnish
 
 
VARNISH_STORAGE="malloc,512m"
 
</pre>
 
 
  
 
==Varnish 3 Configuration==
 
==Varnish 3 Configuration==

Please note that all contributions to wiki.mikejung.biz may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see wiki.mikejung.biz:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)