Online Book Reader

Home Category

Squid_ The Definitive Guide - Duane Wessels [31]

By Root 2056 0
the memory_pools directive on line 76.

It's a good idea to develop the habit of using squid -k parse every time you modify your configuration file. If you don't bother, and your file has some errors, Squid tells you about them and refuses to start anyway. If you end up managing a number of caches, it is likely that you'll develop some scripts to automate starting, stopping, and reconfiguring Squid. You can use this feature in your scripts to ensure that the configuration files are always valid.

Initializing Cache Directories

Before running Squid for the first time, and whenever you add a new cache_dir, you must initialize the cache directories. The command is simply:

% squid -z

For the UFS-related storage schemes (ufs, aufs, and diskd; see Chapter 8), this command creates the subdirectories needed under each cache_dir. You don't need to worry that Squid will wipe out your current cache directories (if any).

Ownership and permissions are a common problem at this stage. Squid runs under a certain user ID, specified with cache_effective_user in squid.conf. This user ID must have read and write permission under each cache_dir directory. If not, you'll see a message like this:

Creating Swap Directories

FATAL: Failed to make swap directory /usr/local/squid/var/cache/00:

(13) Permission denied

In this case, you should make sure that all components of /usr/local/squid/var/cache are accessible to the user ID given in squid.conf. The final component—the cache directory—must be writable by this user ID as well.

Cache directory initialization may take a couple of minutes, depending on the size and number of cache directories, and the speed of your disk drives. If you want to watch the progress, use the -X option:

% squid -zX

Testing Squid in a Terminal Window

Once you've initialized the cache directories, you should run Squid in a terminal window with logging to stderr. This way, you can easily spot any errors or problems and make sure that Squid successfully starts. Use the -N option to keep Squid in the foreground and the -d1 option to display level 1 debugging on stderr:

% squid -N -d1

You should see output like this:

2003/09/29 12:57:52| Starting Squid Cache

version 2.5.STABLE4 for i386-unknown-freebsd4.8...

2003/09/29 12:57:52| Process ID 294

2003/09/29 12:57:52| With 1064 file descriptors available

2003/09/29 12:57:52| DNS Socket created on FD 4

2003/09/29 12:57:52| Adding nameserver 206.107.176.2 from /etc/resolv.conf

2003/09/29 12:57:52| Adding nameserver 205.162.184.2 from /etc/resolv.conf

2003/09/29 12:57:52| Unlinkd pipe opened on FD 9

2003/09/29 12:57:52| Swap maxSize 102400 KB, estimated 7876 objects

2003/09/29 12:57:52| Target number of buckets: 393

2003/09/29 12:57:52| Using 8192 Store buckets

2003/09/29 12:57:52| Max Mem size: 8192 KB

2003/09/29 12:57:52| Max Swap size: 102400 KB

2003/09/29 12:57:52| Rebuilding storage in /usr/local/squid/var/cache (DIRTY)

2003/09/29 12:57:52| Using Least Load store dir selection

2003/09/29 12:57:52| Set Current Directory to /usr/local/squid/var/cache

2003/09/29 12:57:52| Loaded Icons.

2003/09/29 12:57:52| Accepting HTTP connections at 0.0.0.0, port 3128, FD 11.

2003/09/29 12:57:52| Accepting ICP messages at 0.0.0.0, port 3130, FD 12.

2003/09/29 12:57:52| WCCP Disabled.

2003/09/29 12:57:52| Ready to serve requests.

If you see an error message, you need to fix it before proceeding. Be sure to check the first few lines of output for warning messages. The most common errors are file/directory permissions and configuration file syntax errors. If you see an error message that doesn't make sense, have a look at Chapter 16 for advice and information on troubleshooting Squid. If that doesn't help, check the Squid FAQ, or search the mailing list archives for an explanation.

Once you see the Ready to serve requests message, test Squid with a few HTTP requests. You can do this by configuring your browser to use Squid as a proxy and then open a web page. If Squid is working correctly, the page should load as quickly as it would without using Squid.

Return Main Page Previous Page Next Page

®Online Book Reader