Varnish is a high-performance open-source HTTP accelerator. The Varnish author Poul-HenningKamp is one of FreeBSD's kernel developers. He believes that today's computers are much more complex than they were in 1975. In 1975, there were only two storage media types: memory and hard disk. However, in addition to primary memory, the memory of the computer system also includes L1, L2 in the cpu, and even L3 cache. The hard disk also has its own cache device, so it is impossible for squidcache to learn about the architecture that handles object replacement by itself
Varnish is a high-performance open-source HTTP accelerator. The Varnish author Poul-Henning Kamp is one of FreeBSD's kernel developers. He believes that today's computers are much more complex than they were in 1975. In 1975, there were only two storage media types: memory and hard disk. However, in addition to primary memory, the memory of the computing machine system also includes L1, L2 in the cpu, and even L3 cache. The squid cache has its own caching device on the hard disk, so it is impossible for the architecture of squid cache to handle the replacement of objects on its own to know these conditions, but the operating system can know these situations, therefore, this part of work should be handed over to the operating system, which is the Varnish cache design architecture.
1. Install Pcre (PERL Compatible Regular Expression Library)
Wget http: // URL/pcre-8.02.tar.gz
Tar zxvf pcre-8.02.tar.gz
Cd pcre-8.02
./Configure -- libdir =/usr/lib
Make & make install
If Pcre is not installed and configure varnish2.0 or later versions, the system will prompt that the pcre Library cannot be found.
2. Install varnish
Wget http: // URL/varnish-2.1.1.tar.gz
Tar zxvf varnsh-2.1.1
Cd varnish-2.1.1
./Configure -- prefix =/usr/local/varnish
Make & make install
3. varnish startup
/Usr/local/varnish/sbin/varnishd-n/data/vcache-f/usr/local/varnish/etc/vhost. vcl-a 0.0.0.0: 80-s file,/data/vcache/varnish_cache.data, 1G-T 127.0.0.1: 3500-p client_http11 = on-p thread_pools = 8-p thread_pool_min = 16-p thread_pool_max = 512
For each option, see http://varnish-cache.org/static/getting-started.html
4. varnish stop, start, and enable log scripts
#! /Bin/sh
If["$1"="Start"]; Then
/Usr/local/varnish/sbin/varnishd-n/data/vcache \
-F/usr/local/varnish/etc/vhost. vcl-a 0.0.0.0: 80 \
-S file,/data/vcache/varnish_cache.data, 1G-T 127.0.0.1: 3500 \
-P client_http11 = on-p thread_pools = 8-p thread_pool_min = 16-p thread_pool_max = 512
Elif ["$1"="Stop"]; Then
Killall varnishd
Elif ["$1"="Status"]; Then
/Usr/local/varnish/bin/varnishadm-T 127.0.0.1: 3500 status
Elif ["$1"="Start-log"]; Then
/Usr/local/varnish/bin/varnishncsa-n/data/vcache-w/var/log/varnish. log &
Else
Echo $0"{Start | stop | status | start-log }"
Fi
Edit in windows. It will appear in AS5
-Bash:./varnishadmin:/bin/sh ^ M: bad interpreter: No such file or directory error, which is caused by different codes on both platforms.
Vi THIS_SHELLSCRIPT (script file name)
: Set ff-> the file format is fileformat = dos.
: Set ff = unix-> set fileformat = unix
: Wq
5. varnish log polling script
#! /Bin/sh
Vlog =/var/log/varnish-log
Date = $ (date-d"Yesterday"+"% Y-% m-% d")
Pkill-9 varnishncsa
Mv/var/log/varnish. log/var/log/varnish-$ {date}. log
/Usr/local/varnish/bin/varnishncsa-n/data/vcache-w/var/log/varnish. log &
Mkdir-p/var/log/varnish-log/
Cd/var/log
Tar-zcvf $ vlog/varnish-20.1_date0000.log.tar.gz varnish-$ {date}. log
Rm-f/var/log/$ {date}. log
Rm-f/var/log/varnish-log/$ (date-d"-1 month"+"% Y-% m *"Pai.log.tar.gz
You can put the above scripts into the task and execute them at every day.
0 0 ***/data/shell/cutvlogg. sh