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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.21">
<TITLE>SQUID Frequently Asked Questions: Installing and Running Squid</TITLE>
<LINK HREF="FAQ-4.html" REL=next>
<LINK HREF="FAQ-2.html" REL=previous>
<LINK HREF="FAQ.html#toc3" REL=contents>
</HEAD>
<BODY>
<A HREF="FAQ-4.html">Next</A>
<A HREF="FAQ-2.html">Previous</A>
<A HREF="FAQ.html#toc3">Contents</A>
<HR>
<H2><A NAME="s3">3.</A> <A HREF="FAQ.html#toc3">Installing and Running Squid</A></H2>
<H2><A NAME="ss3.1">3.1</A> <A HREF="FAQ.html#toc3.1">How big of a system do I need to run Squid?</A>
</H2>
<P>There are no hard-and-fast rules. The most important resource
for Squid is physical memory. Your processor does not need
to be ultra-fast. Your disk system will be the major bottleneck,
so fast disks are important for high-volume caches. Do not use
IDE disks if you can help it.</P>
<P>In late 1998, if you are buying a new machine for
a cache, I would recommend the following configuration:
<UL>
<LI>300 MHz Pentium II CPU</LI>
<LI>512 MB RAM</LI>
<LI>Five 9 GB UW-SCSI disks</LI>
</UL>
Your system disk, and logfile disk can probably be IDE without losing
any cache performance.</P>
<P>Also, see
<A HREF="http://wwwcache.ja.net/servers/squids.html">Squid Sizing for Intel Platforms</A> by Martin Hamilton This is a
very nice page summarizing system configurations people are using for
large Squid caches.</P>
<H2><A NAME="ss3.2">3.2</A> <A HREF="FAQ.html#toc3.2">How do I install Squid?</A>
</H2>
<P>After
<A HREF="FAQ-2.html#compiling">compiling Squid</A>, you can install it
with this simple command:
<PRE>
% make install
</PRE>
If you have enabled the
<A HREF="FAQ-7.html#using-icmp">ICMP features</A>
then you will also want to type
<PRE>
% su
# make install-pinger
</PRE>
</P>
<P>After installing, you will want to edit and customize
the <EM>squid.conf</EM> file. By default, this file is
located at <EM>/usr/local/squid/etc/squid.conf</EM>.</P>
<P>Also, a QUICKSTART guide has been included with the source
distribution. Please see the directory where you
unpacked the source archive.</P>
<H2><A NAME="ss3.3">3.3</A> <A HREF="FAQ.html#toc3.3">What does the <EM>squid.conf</EM> file do?</A>
</H2>
<P>The <EM>squid.conf</EM> file defines the configuration for
<EM>squid</EM>. the configuration includes (but not limited to)
HTTP port number, the ICP request port number, incoming and outgoing
requests, information about firewall access, and various timeout
information.</P>
<H2><A NAME="ss3.4">3.4</A> <A HREF="FAQ.html#toc3.4">Do you have a <EM>squid.conf</EM> example?</A>
</H2>
<P>Yes, after you <CODE>make install</CODE>, a sample <EM>squid.conf</EM> file will
exist in the ``etc" directory under the Squid installation directory.</P>
<P>The sample <EM>squid.conf</EM> file contains comments explaining each
option.</P>
<H2><A NAME="ss3.5">3.5</A> <A HREF="FAQ.html#toc3.5">How do I start Squid?</A>
</H2>
<P>First you need to make your Squid configuration. The Squid configuration
can be found in /usr/local/squid/etc/squid.conf and by default includes
documentation on all directives.</P>
<P>In the Suqid distribution there is a small QUICKSTART guide indicating
which directives you need to look closer at and why. At a absolute minimum
you need to change the http_access configuration to allow access from
your clients.</P>
<P>To verify your configuration file you can use the -k parse option
<PRE>
% /usr/local/squid/sbin/squid -k parse
</PRE>
If this outputs any errors then these are syntax errors or other fatal
misconfigurations and needs to be corrected before you continue. If it is
silent and immediately gives back the command promt then your squid.conf
is syntactically correct and could be understood by Squid.</P>
<P>After you've finished editing the configuration file, you can
start Squid for the first time. The procedure depends a little
bit on which version you are using.</P>
<P>First, you must create the swap directories. Do this by
running Squid with the -z option:
<PRE>
% /usr/local/squid/sbin/squid -z
</PRE>
</P>
<P>NOTE: If you run Squid as root then you may need to first create
/usr/local/squid/var/logs and your cache_dir directories and assign ownership
of these to the cache_effective_user configured in your squid.conf.</P>
<P>Once the creation of the cache directories completes, you can start Squid
and try it out. Probably the best thing to do is run it from your terminal
and watch the debugging output. Use this command:
<PRE>
% /usr/local/squid/sbin/squid -NCd1
</PRE>
If everything is working okay, you will see the line:
<PRE>
Ready to serve requests.
</PRE>
If you want to run squid in the background, as a daemon process,
just leave off all options:
<PRE>
% /usr/local/squid/sbin/squid
</PRE>
</P>
<P>NOTE: depending on which http_port you select you may need to start
squid as root (http_port <1024).</P>
<P>NOTE: In Squid-2.4 and earlier Squid was installed in bin by default, not sbin.</P>
<H2><A NAME="ss3.6">3.6</A> <A HREF="FAQ.html#toc3.6">How do I start Squid automatically when the system boots?</A>
</H2>
<P>Squid-2 has a restart feature built in. This greatly simplifies
starting Squid and means that you don't need to use <EM>RunCache</EM>
or <EM>inittab</EM>. At the minimum, you only need to enter the
pathname to the Squid executable. For example:
<PRE>
/usr/local/squid/sbin/squid
</PRE>
</P>
<P>Squid will automatically background itself and then spawn
a child process. In your <EM>syslog</EM> messages file, you
should see something like this:
<PRE>
Sep 23 23:55:58 kitty squid[14616]: Squid Parent: child process 14617 started
</PRE>
That means that process ID 14563 is the parent process which monitors the child
process (pid 14617). The child process is the one that does all of the
work. The parent process just waits for the child process to exit. If the
child process exits unexpectedly, the parent will automatically start another
child process. In that case, <EM>syslog</EM> shows:
<PRE>
Sep 23 23:56:02 kitty squid[14616]: Squid Parent: child process 14617 exited with status 1
Sep 23 23:56:05 kitty squid[14616]: Squid Parent: child process 14619 started
</PRE>
</P>
<P>If there is some problem, and Squid can not start, the parent process will give up
after a while. Your <EM>syslog</EM> will show:
<PRE>
Sep 23 23:56:12 kitty squid[14616]: Exiting due to repeated, frequent failures
</PRE>
When this happens you should check your <EM>syslog</EM> messages and
<EM>cache.log</EM> file for error messages.</P>
<P>When you look at a process (<EM>ps</EM> command) listing, you'll see two squid processes:
<PRE>
24353 ?? Ss 0:00.00 /usr/local/squid/bin/squid
24354 ?? R 0:03.39 (squid) (squid)
</PRE>
The first is the parent process, and the child process is the one called ``(squid)''.
Note that if you accidentally kill the parent process, the child process will not
notice.</P>
<P>If you want to run Squid from your termainal and prevent it from
backgrounding and spawning a child process, use the <EM>-N</EM> command
line option.
<PRE>
/usr/local/squid/bin/squid -N
</PRE>
</P>
<H3>From inittab</H3>
<P>On systems which have an <EM>/etc/inittab</EM> file (Digital Unix,
Solaris, IRIX, HP-UX, Linux), you can add a line like this:
<PRE>
sq:3:respawn:/usr/local/squid/sbin/squid.sh < /dev/null >> /tmp/squid.log 2>&1
</PRE>
We recommend using a <EM>squid.sh</EM> shell script, but you could instead call
Squid directly with the -N option and other options you may require. A sameple <EM>squid.sh</EM> script is shown below:
<PRE>
#!/bin/sh
C=/usr/local/squid
PATH=/usr/bin:$C/bin
TZ=PST8PDT
export PATH TZ
# User to notify on restarts
notify="root"
# Squid command line options
opts=""
cd $C
umask 022
sleep 10
while [ -f /var/run/nosquid ]; do
sleep 1
done
/usr/bin/tail -20 $C/logs/cache.log \
| Mail -s "Squid restart on `hostname` at `date`" $notify
exec bin/squid -N $opts
</PRE>
</P>
<H3>From rc.local</H3>
<P>On BSD-ish systems, you will need to start Squid from the ``rc'' files,
usually <EM>/etc/rc.local</EM>. For example:
<PRE>
if [ -f /usr/local/squid/sbin/squid ]; then
echo -n ' Squid'
/usr/local/squid/sbin/squid
fi
</PRE>
</P>
<H3>From init.d</H3>
<P>Squid ships with a init.d type startup script in contrib/squid.rc which
works on most init.d type systems. Or you can write your own using any
normal init.d script found in your system as template and add the
start/stop fragments shown below.</P>
<P>Start:
<PRE>
/usr/local/squid/sbin/squid
</PRE>
</P>
<P>Stop:
<PRE>
/usr/local/squid/sbin/squid -k shutdown
n=120
while /usr/local/squid/sbin/squid -k check && [ $n -gt 120 ]; do
sleep 1
echo -n .
n=`expr $n - 1`
done
</PRE>
</P>
<H2><A NAME="ss3.7">3.7</A> <A HREF="FAQ.html#toc3.7">How do I tell if Squid is running?</A>
</H2>
<P>You can use the <EM>squidclient</EM> program:
<PRE>
% squidclient http://www.netscape.com/ > test
</PRE>
</P>
<P>There are other command-line HTTP client programs available
as well. Two that you may find useful are
<A HREF="ftp://gnjilux.cc.fer.hr/pub/unix/util/wget/">wget</A>
and
<A HREF="ftp://ftp.internatif.org/pub/unix/echoping/">echoping</A>.</P>
<P>Another way is to use Squid itself to see if it can signal a running
Squid process:
<PRE>
% squid -k check
</PRE>
And then check the shell's exit status variable.</P>
<P>Also, check the log files, most importantly the <EM>access.log</EM> and
<EM>cache.log</EM> files.</P>
<H2><A NAME="ss3.8">3.8</A> <A HREF="FAQ.html#toc3.8"><EM>squid</EM> command line options</A>
</H2>
<P>These are the command line options for <B>Squid-2</B>:
<DL>
<DT><B>-a</B><DD><P>Specify an alternate port number for incoming HTTP requests.
Useful for testing a configuration file on a non-standard port.</P>
<DT><B>-d</B><DD><P>Debugging level for ``stderr'' messages. If you use this
option, then debugging messages up to the specified level will
also be written to stderr.</P>
<DT><B>-f</B><DD><P>Specify an alternate <EM>squid.conf</EM> file instead of the
pathname compiled into the executable.</P>
<DT><B>-h</B><DD><P>Prints the usage and help message.</P>
<DT><B>-k reconfigure</B><DD><P>Sends a <EM>HUP</EM> signal, which causes Squid to re-read
its configuration files.</P>
<DT><B>-k rotate</B><DD><P>Sends an <EM>USR1</EM> signal, which causes Squid to
rotate its log files. Note, if <EM>logfile_rotate</EM>
is set to zero, Squid still closes and re-opens
all log files.</P>
<DT><B>-k shutdown</B><DD><P>Sends a <EM>TERM</EM> signal, which causes Squid to
wait briefly for current connections to finish and then
exit. The amount of time to wait is specified with
<EM>shutdown_lifetime</EM>.</P>
<DT><B>-k interrupt</B><DD><P>Sends an <EM>INT</EM> signal, which causes Squid to
shutdown immediately, without waiting for
current connections.</P>
<DT><B>-k kill</B><DD><P>Sends a <EM>KILL</EM> signal, which causes the Squid
process to exit immediately, without closing
any connections or log files. Use this only
as a last resort.</P>
<DT><B>-k debug</B><DD><P>Sends an <EM>USR2</EM> signal, which causes Squid
to generate full debugging messages until the
next <EM>USR2</EM> signal is recieved. Obviously
very useful for debugging problems.</P>
<DT><B>-k check</B><DD><P>Sends a ``<EM>ZERO</EM>'' signal to the Squid process.
This simply checks whether or not the process
is actually running.</P>
<DT><B>-s</B><DD><P>Send debugging (level 0 only) message to syslog.</P>
<DT><B>-u</B><DD><P>Specify an alternate port number for ICP messages.
Useful for testing a configuration file on a non-standard port.</P>
<DT><B>-v</B><DD><P>Prints the Squid version.</P>
<DT><B>-z</B><DD><P>Creates disk swap directories. You must use this option when
installing Squid for the first time, or when you add or
modify the <EM>cache_dir</EM> configuration.</P>
<DT><B>-D</B><DD><P>Do not make initial DNS tests. Normally, Squid looks up
some well-known DNS hostnames to ensure that your DNS
name resolution service is working properly.</P>
<DT><B>-F</B><DD><P>If the <EM>swap.state</EM> logs are clean, then the cache is
rebuilt in the ``foreground'' before any requests are
served. This will decrease the time required to rebuild
the cache, but HTTP requests will not be satisified during
this time.</P>
<DT><B>-N</B><DD><P>Do not automatically become a background daemon process.</P>
<DT><B>-R</B><DD><P>Do not set the SO_REUSEADDR option on sockets.</P>
<DT><B>-V</B><DD><P>Enable virtual host support for the httpd-accelerator mode.
This is identical to writing <EM>httpd_accel_host virtual</EM>
in the config file.</P>
<DT><B>-X</B><DD><P>Enable full debugging while parsing the config file.</P>
<DT><B>-Y</B><DD><P>Return ICP_OP_MISS_NOFETCH instead of ICP_OP_MISS while
the <EM>swap.state</EM> file is being read. If your cache has
mostly child caches which use ICP, this will allow your
cache to rebuild faster.</P>
</DL>
</P>
<H2><A NAME="ss3.9">3.9</A> <A HREF="FAQ.html#toc3.9">How do I see how Squid works?</A>
</H2>
<P>
<UL>
<LI>Check the <EM>cache.log</EM> file in your logs directory. It logs
interesting (and boring) things as a part of its normal operation.</LI>
<LI>Install and use the
<A HREF="FAQ-9.html#cachemgr-section">Cache Manager</A>.</LI>
</UL>
</P>
<H2><A NAME="ss3.10">3.10</A> <A HREF="FAQ.html#toc3.10">Can Squid benefit from SMP systems?</A>
</H2>
<P>Squid is a single process application and can not make use of SMP.
If you want to make Squid benefit from a SMP system you will need to run
multiple instances of Squid and find a way to distribute your users on the
different Squid instances just as if you had multiple Squid boxes.</P>
<P>Having two CPUs is indeed nice for running other CPU intensive
tasks on the same server as the proxy, such as if you have a lot of logs
and need to run various statistics collections during peak hours.</P>
<P>The authentication and group helpers barely use any CPU and does
not benefit from dual-CPU configuration.</P>
<H2><A NAME="ss3.11">3.11</A> <A HREF="FAQ.html#toc3.11">Is it okay to use separate drives and RAID on Squid?</A>
</H2>
<P>RAID1 is fine, and so are separate drives.</P>
<P>RAID0 (striping) with Squid only gives you the drawback that if
you lose one of the drives the whole stripe set is lost. There is no
benefit in performance as Squid already distributes the load on the drives
quite nicely. </P>
<P>Squid is the worst case application for RAID5, whether hardware or
software, and will absolutely kill the performance of a RAID5. Once the
cache has been filled Squid uses a lot of small random writes which the
worst case workload for RAID5, effectively reducing write speed to only
little more than that of one single drive.</P>
<P>Generally seek time is what you want to optimize for Squid, or
more precisely the total amount of seeks/s your system can sustain.
Choosing the right RAID solution generally decreases the amount of seeks/s
your system can sustain significantly.</P>
<HR>
<A HREF="FAQ-4.html">Next</A>
<A HREF="FAQ-2.html">Previous</A>
<A HREF="FAQ.html#toc3">Contents</A>
</BODY>
</HTML>
|