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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Draft//EN">
<HTML>
<HEAD>
<TITLE>SQUID Frequently Asked Questions: Installing and Running Squid</TITLE>
</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. Installing and Running Squid</A></H2>
<H2><A NAME="ss3.1">3.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 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 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 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>The sample <EM>squid.conf</EM> file contains comments explaining each
option.
<P>
<P>
<H2><A NAME="ss3.5">3.5 How do I start Squid?</A>
</H2>
<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>
<H3>Squid version 2.X</H3>
<P>First, you must create the swap directories. Do this by
running Squid with the -z option:
<PRE>
% /usr/local/squid/bin/squid -z
</PRE>
Once that 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/bin/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/bin/squid
</PRE>
<P>NOTE: depending on your configuration, you may need to start
squid as root.
<P>
<H3>Squid version 1.1.X</H3>
<P>With version 1.1.16 and later, you must first run Squid with the
<B>-z</B> option to create the cache swap directories.
<PRE>
% /usr/local/squid/bin/squid -z
</PRE>
Squid will exit when it finishes creating all of the directories.
Next you can start <EM>RunCache</EM>:
<PRE>
% /usr/local/squid/bin/RunCache &
</PRE>
<P>
<P>For versions before 1.1.6 you should just start <EM>RunCache</EM>
immediately, instead of running <EM>squid -z</EM> first.
<P>
<H2><A NAME="ss3.6">3.6 How do I start Squid automatically when the system boots?</A>
</H2>
<H3>Squid Version 2.X</H3>
<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/bin/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>Squid Version 1.1.X</H3>
<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/bin/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. 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
notify="root"
cd $C
umask 022
sleep 10
while [ -f /tmp/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 -CYs
</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/bin/RunCache ]; then
echo -n ' Squid'
(/usr/local/squid/bin/RunCache &)
fi
</PRE>
<P>
<H3>From init.d</H3>
<P>Some people may want to use the ``init.d'' startup system.
If you start Squid (or RunCache) from an ``init.d'' script, then you
should probably use <EM>nohup</EM>, e.g.:
<PRE>
nohup squid -sY $conf >> $logdir/squid.out 2>&1
</PRE>
Also, you may need to add a line to trap certain signals
and prevent them from being sent to the Squid process.
Add this line at the top of your script:
<PRE>
trap '' 1 2 3 18
</PRE>
<P>
<H2><A NAME="ss3.7">3.7 How do I tell if Squid is running?</A>
</H2>
<P>You can use the <EM>client</EM> program:
<PRE>
% client http://www.netscape.com/ > test
</PRE>
<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 <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.
<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.
<DT><B>-f</B><DD><P>Specify an alternate <EM>squid.conf</EM> file instead of the
pathname compiled into the executable.
<DT><B>-h</B><DD><P>Prints the usage and help message.
<DT><B>-k reconfigure</B><DD><P>Sends a <EM>HUP</EM> signal, which causes Squid to re-read
its configuration files.
<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.
<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>.
<DT><B>-k interrupt</B><DD><P>Sends an <EM>INT</EM> signal, which causes Squid to
shutdown immediately, without waiting for
current connections.
<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.
<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.
<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.
<DT><B>-s</B><DD><P>Send debugging (level 0 only) message to syslog.
<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.
<DT><B>-v</B><DD><P>Prints the Squid version.
<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.
<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.
<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.
<DT><B>-N</B><DD><P>Do not automatically become a background daemon process.
<DT><B>-R</B><DD><P>Do not set the SO_REUSEADDR option on sockets.
<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.
<DT><B>-X</B><DD><P>Enable full debugging while parsing the config file.
<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.
</DL>
<P>
<H2><A NAME="ss3.9">3.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>
<P>
<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>
|