Squid Chinese authoritative guide (1)

Source: Internet
Author: User
Squid Chinese authoritative guide (I)-Linux Enterprise Application-Linux server application information. The following is a detailed description. [I = s] This post was last edited by gary168

Chapter 4 run Squid

5.1 squid command line options

Before starting other tasks, let's take a look at the command line options of squid. You will never use many of the options here, and some of them are only useful for debugging problems.

-A port
Specifies the new http_port value. This option overwrites the value from squid. conf. However, note that you can specify multiple values in squid. conf. -Option a only overwrites the first value in the configuration file. (This option uses the letter a because the HTTP port is called the ASCII port in the Harvest cache)

-D level
Let squid write its debugging information to a standard error (IF configured, It is cache. log and syslog ). The level parameter specifies the maximum level of messages displayed in standard errors. In most cases, d1 works well. See Section 16.2 about the debugging level.

-F file
Specify another configuration file.

-H
Display usage.

-K function
Indicates that squid performs different management functions. Function parameters are one of the following: reconfigure, rotate, shutdown, interrupt, kill, debug, check, or parse.
+ Reconfigure causes the squid in the running to re-read the configuration file.
+ Rotate causes squid to scroll its logs, including disabling logs, renaming logs, and opening them again.
+ Shutdown sends a signal to shut down the squid process.
+ Interrupt immediately closes the squid and does not have to wait for the Active session to complete.
+ Kill sends a KILL signal to squid, which is the final guarantee for disabling squid.
+ Debug sets squid to the full debugging mode. If your cache is busy, it can quickly use up your disk space.
+ Check the running squid process. The returned value shows whether the squid is running.
+ Finally, parse parses the squid. conf file. If the configuration file contains errors, the process returns a non-zero value.

-S
Activate logging to the syslog process. Squid uses the LOCAL4 syslog device. Level 0 debugging information is recorded with priority LOG_WARNING, and level 1 message is recorded with LOG_NOTICE. More advanced debugging information will not be sent to syslogd. You can use the following interface in the/etc/syslogd. conf file:
Local4.warning/var/log/squid. log

-U port
Specify another ICP port to overwrite the icp_port In the squid. conf file.

-V
Print version information.

-Z
Initialize cache, or swap, directory. This option is required when you first run squid or add a new cache directory.

-C
Prevents the installation of certain signal handles that capture specific fatal signals such as SIGBUS and SIGSEGV. Normally, these signals are captured by squid so that it can be closed cleanly. However, capturing these signals may make debugging difficult in the future. With this option, fatal signals lead to their default actions, usually coredump.

-D
Do not initialize DNS tests. Normally, squid cannot be started until its DNS is verified to be available. This option prevents such detection. You can also change or delete the dns_testnames option in the squid. conf file.

-F
Let squid reject all requests until it re-establishes the storage metadata. If your system is busy, this option can reduce the time required to recreate and store metadata. However, if your cache is large, the reconstruction process may take a long time.

-N
Prevents squid from becoming a backend service process.

-R
Prevent squid from using the SO_REUSEADDR option before binding the HTTP port.

-V
Activate the VM acceleration mode. Similar to the httpd_accel_host virtual command in the squid. conf file.

-X
Force the complete debugging mode, as if you specify debug_options ALL, 9 in the squid. conf file.

-Y
When the metadata is re-stored, ICP_MISS_NOFETCH is returned to replace ICP_MISS. This option can cause minimal load when the parent cache is busy. See Chapter 10.6.1.2.


5.2 check configuration file errors

Verify the configuration file carefully before enabling squid. This is easy to do. Run the following command:
% Squid-k parse

If you do not see the output, the configuration file is valid and you can continue with the subsequent steps.

However, if the configuration file contains errors, squid will tell you:
Squid. conf line 62: http_access allow okay2
AclParseAccessLine: ACL name 'okay2' not found.

Here you can see that the ACL to which the http_access command of row 62 points does not exist. Sometimes there are few error messages:
FATAL: Bungled squid. conf line 76: memory_pools

In this case, we forget to place the on or off command after the 76-line memory_pools command.

We recommend that you use squid-k parse every time you modify the configuration file. If you don't want to bother and your configuration file has errors, squid will tell you about them and refuse to start. If you manage a large number of caches, you may edit the script to automatically start, stop, and reconfigure squid. You can use this function in the script to verify that the configuration file is valid.


5.3 initialize the cache directory.

Before you run squid for the first time, or whenever you add a new cache_dir, you must initialize the cache directory. The command is simple:
% Squid? Z

For the UFS-related storage mechanism (ufs, aufs, and diskd; see Chapter 8th), this command creates the required sub-directories under each cache_dir. You don't have to worry that squid will damage your current cache directory (if any ).

At this stage, the owner and permission are common problems. Squid runs under a specific user ID, which is specified in cache_inclutive_user In the squid. conf file. The User ID must have read and write permissions on each cache_dir directory. Otherwise, you will see the following information:
Creating Swap Directories
FATAL: Failed to make swap directory/usr/local/squid/var/cache/00:
(13) Permission denied

In this case, all the components of the/usr/local/squid/var/cache directory can be accessed by the user ID specified by squid. conf. The final component-cache directory-must be writable to this user ID.

The cache directory initialization may take some time, depending on the size and quantity of the cache directory, as well as the disk drive speed. If you want to observe this process, use the-X option:
% Squid? ZX


5.4 test squid in the terminal window

Once you have initialized the cache directory, you can run squid in the terminal window to record logs to standard errors. In this way, you can easily locate any errors or problems and check whether squid is successfully started. Use the-N option to keep squid running on the foreground. The-d1 option displays Level 1 debugging information in the standard error.
% Squid-N-d1

You will see the output similar to the following:
12:57:52 | Starting Squid Cache
Version 2.5.STABLE4 for i386-unknown-freebsd4.8...
12:57:52 | Process ID 294
12:57:52 | With 1064 file descriptors available
2003/09/29 12:57:52 | DNS Socket created on FD 4
12:57:52 | Adding nameserver 206.107.176.2 from/etc/resolv. conf
12:57:52 | Adding nameserver 205.162.184.2 from/etc/resolv. conf
12:57:52 | Unlinkd pipe opened on FD 9
12:57:52 | Swap maxSize 102400 KB, estimated 7876 objects
12:57:52 | Target number of buckets: 393
12:57:52 | Using 8192 Store buckets
12:57:52 | Max Mem size: 8192 KB
12:57:52 | Max Swap size: 102400 KB
12:57:52 | Rebuilding storage in/usr/local/squid/var/cache (DIRTY)
12:57:52 | Using Least Load store dir selection
12:57:52 | Set Current Directory to/usr/l

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.