Senin, 10 Juni 2013

Install Varnish CentOS 6

This tutorial is intended for system administrators wanting to install Varnish on CentOS 6. The reader should know how to configure a web server or application server and have basic knowledge of the HTTP protocol. Once finished the reader should have a basic Varnish cache up and running with the default configuration.
Varnish is a web application accelerator. You install it in front of your web application and it will speed it up significantly.
Varnish web application accelerator homepage: https://www.varnish-cache.org

Install the Varnish YUM Repository

# rpm -Uvh http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release-3.0-1.noarch.rpm

Install Varnish web accelerator

# yum install varnish

Enable Varnish web accelerator at startup

# chkconfig varnish on

Basic default.vcl

# vi /etc/varnish/default.vcl
1
2
3
4
5
6
7
8
9
10
# This is a basic VCL configuration file for varnish.  See the vcl(7)
# man page for details on VCL syntax and semantics.
#
# Default backend definition.  Set this to point to your content
# server.
#
backend default {
  .host = "127.0.0.1";
  .port = "80";
}

Start Varnish web accelerator

# service varnish start
You will now have a basic Varnish web accelerator running on port 8080

Top 5 Varnish commands

varnishstat
Provides all the info you need to spot cache misses and errors.
varnishhist
Provides a histogram view of cache hits/misses
varnishlog
Provides detailed information on requests.
varnishtop
The varnishtop utility reads varnishd shared memory logs and presents a continuously updated list of the most commonly occurring log entries.
varnishadm
Command-line varnish administration used to reload vcl and purge urls.

Managing Varnish with Puppet

If you’re running Puppet we have included the manifest for installing Varnish on CentOS 6. If you’re not running Puppet then you can install it by following the instructions outlined in our CentOS 6 Puppet Install.
This is only the manifest and doesn’t include any of the files (i.e. default.vcl).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class varnish::repo {
 
 Package {
  provider => rpm,
  ensure => installed
 }
 
 package { "varnish-release": source => "http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release-3.0-1.noarch.rpm"
 }
}
 
class varnish::install {
 
 $packagelist = ["varnish"]
 
 package { $packagelist:
  require => Class ["varnish::repo"],
  ensure => installed
 }
}
 
class varnish::service {
 
 service { "varnish":
  ensure => true,
  enable => true,
  hasrestart => true,
  hasstatus => true,
  require => Class ["varnish::install"]
 }
}
 
class varnish::conf {
 
 File {
  require => Class ["varnish::install"],
  owner => "root",
  group => "root",
  mode => 644,
  notify => Class ["varnish::service"]
 }
 
 file { "/etc/varnish/default.vcl":
  source  => "puppet:///modules/varnish/default.vcl"
 }
 
 file { "/etc/sysconfig/varnish":
  source  => "puppet:///modules/varnish/varnish"
 }
}
 
class varnish {
 include varnish::repo, varnish::install, varnish::service, varnish::conf
}

Tidak ada komentar:

Posting Komentar