CONTENT
- CHANGES
Szukaj
#top Instalacja¶
Instalację serwera proxy Varnish można wykonać na różne sposoby: od kompilacji ze źdródeł poprzez instalację pojedynczych paczek rpm za pomocą polecenia rpm skończywszy na instalacja z użyciem menedżera pakietów, który zainstaluje wszystkie niezbędne paczki wraz zależnościami.
Celem niniejszego dokumentu nie jest rozważanie różnych metod instalacji tylko nieco usprawnienie użyteczności konfiguracji serwera Varnish po zainstalowaniu oraz wprowadzenie porządku / hierarchi położenia plików z których korzysta usługa w strukturze katalogowej.
Zgodnie definicja FHS: katalog
/srv
zawiera: Data for services provided by this system
toteż jako katalog w którym Varnish będzie przechowywał dane został wybrany: /srv/varnish
i zostanie on utworzony z odpowiednimi atrybutami.Wszystko to zostało opisane poniżej.
#top Postinstalacyjna konfiguracja¶
#top Keep oryginal start script¶
mv /etc/init.d/varnishlog /etc/init.d/varnishlog-rpm cp -av /etc/init.d/varnishlog-rpm /etc/init.d/varnishlog mv /etc/init.d/varnishncsa /etc/init.d/varnishncsa-rpm cp -av /etc/init.d/varnishncsa-rpm /etc/init.d/varnishncsa
#top Create directory root structure¶
mkdir /srv/varnish chcon -t varnishd_var_lib_t /srv/varnish
#top Update /etc/sysconfig/varnish file¶
Update
/etc/sysconfig/varnish
file, set command line arguments for varnish process:## Alternative 4, Do It Yourself. See varnishd(1) for more information. # # DAEMON_OPTS="" # Specify a name for this instance. Amonst other things, this name is used to construct the name of the directory # in which varnishd keeps temporary files and persistent state. If the specified name begins with a forward slash, # it is interpreted as the absolute path to the directory which should be used for this purpose. VARNISH_WORKDIR=/srv/varnish # 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=0.0.0.0 VARNISH_LISTEN_PORT=86 # Telnet admin interface listen address and port VARNISH_ADMIN_LISTEN_ADDRESS=0.0.0.0 VARNISH_ADMIN_LISTEN_PORT=6082 # The minimum number of worker threads to start VARNISH_MIN_THREADS=1 # The Maximum number of worker threads to start VARNISH_MAX_THREADS=1000 # Idle timeout for worker threads VARNISH_THREAD_TIMEOUT=120 # Cache file location VARNISH_STORAGE_FILE=$VARNISH_WORKDIR/varnish_storage.bin # 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=1G # Backend storage specification VARNISH_STORAGE="file,${VARNISH_STORAGE_FILE},${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="-n $VARNISH_WORKDIR/default \ -a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \ -f ${VARNISH_VCL_CONF} \ -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \ -t ${VARNISH_TTL} \ -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT} \ -u varnish -g varnish \ -s ${VARNISH_STORAGE}"
#top Update /etc/sysconfig/varnishlog file¶
Update
/etc/sysconfig/varnishlog
file, set command line arguments for varnishlog process:sed 's,^\(.*/etc/sysconfig/varnishlog.*\)$,\1\n\nDAEMON_OPTS="-a -w $logfile -D -P $pidfile $OPTIONS",g' -i /etc/init.d/varnishlog echo -en > /etc/sysconfig/varnishlog echo '# Specifies the name of the varnishd instance to get logs from.' >> /etc/sysconfig/varnishlog echo '# If -n is not specified, the host name is used.' >> /etc/sysconfig/varnishlog echo 'VARNISH_WORKDIR=/srv/varnish' >> /etc/sysconfig/varnishlog echo 'OPTIONS="-n $VARNISH_WORKDIR/default"' >> /etc/sysconfig/varnishlog
#top Update /etc/sysconfig/varnishncsa file¶
Update
/etc/sysconfig/varnishncsa
file, set command line arguments for varnishncsa process:sed 's,^\(.*/etc/sysconfig/varnishncsa.*\)$,\1\n\nDAEMON_OPTS="-a -w $logfile -D -P $pidfile $OPTIONS",g' -i /etc/init.d/varnishncsa echo -en > /etc/sysconfig/varnishncsa echo '# Specifies the name of the varnishd instance to get logs from.' >> /etc/sysconfig/varnishncsa echo '# If -n is not specified, the host name is used.' >> /etc/sysconfig/varnishncsa echo 'VARNISH_WORKDIR=/srv/varnish' >> /etc/sysconfig/varnishncsa echo 'OPTIONS="-n $VARNISH_WORKDIR/default"' >> /etc/sysconfig/varnishncsa
#top Configure default backend for varnish¶
/etc/varnish/default.vcl
# Default backend definition. Set this to point to your content # server. # backend default { .host = "127.0.0.1"; .port = "80"; }
#top Start varnish processes¶
/etc/init.d/varnish start /etc/init.d/varnishlog start /etc/init.d/varnishncsa start
Zmodyfikowany ostatnio: 2015/03/14 12:31:07 (10 lat temu),
textsize: 5,16 kB,
htmlsize: 11,4 kB
Zapraszam do komentowania, zgłaszania sugestii, propozycji, własnych przykładów, ...
Dodaj komentarzKomentarze użytkowników