Squid details 2

xiaoxiao2021-03-06  111

Squid details 1

I have been separated for a long time, I can write this experience. I have been engaged in qmail in the previous period, and I can finally be empty :)

First look at Squid an important thing, and for me is the only configuration file that needs to be configured. There are many options, of course, the default squid.conf file has a more detailed description of each option, but I still want to understand what I understand and must be configured, so that I will forget it later. ^ _ ^

The following configuration I want to learn from the Web Server to Sina, Sohu, 163, try to build a such environment to see how the effect is. So the Squid here is not used to do agents, but reverse as a website cache. In fact, the principle is almost, but the direction is reversed, I believe it can understand this.

The test server used is Dell 2650 dual CPU to strong 2.4G memory DDR 2G. OS is FreeBSD 5.2.1 (here, from actual use, the effect of Squid runs on FreeBSD is the fastest and best. This is determined by the OS file system, must not be used, Solaris, I feel that Solaris's file system is too slow, although it is very stable, and the effect of running multi-thread is the best. LINUX ~~~ Nothing test, but feel below FreeBSD, Solaris.)

Squid.conf configuration instructions for several important parameters:

Http_port 61.155.143.54:80 #squid Server listening port. Suppose my homepage's DNS Server refers to 61.155.143.54, so I must let Squid to listen to this port of this IP.

Cache_MEM 32 MB # To provide additional memory to Squid, the additional refers to Squid will put the most commonly used caches in this memory. This directive is also understood after I read the official document. Because I started from the actual usage, I set up 32M, with a TOP command to see usually reached around 100M. This makes me remind me that I can't figure it out, huh, huh. Then go to the official document, find that Squid is calculated to calculate how much memory: Squid itself is about 10m-20m, then the size of the cache directory I set up is 500m, then he put it in the memory has probably It takes about 20m or so, then add the value of the Cache_MEM set here. Official documentation suggests that your actual memory size should be twice more of the total memory required for this Squid. It's a force. Cache_mem is of course, the bigger the better.

Cache_dir ufs / usr / local / squid-54 / var / cache 500 16 256 # Sets the position of the SQUID to store the Cache directory and size. The first number 500 refers to a total size of 500m (default is 100m). The second number 16 refers to 16 of the first level directory, and the third number 256 refers to the second-level directory of 256 me. I feel that if the website is large, and if the content is much, it is possible to consider changing the default 100M, otherwise it will be reported. I have experienced that the error I forgot to record (damn!) Roughly said that the limit of the max, I found a half-day to find the culprit is this directive, embarrassing ~~~.

Cache_access_log nonecache_log none

Cache_store_log none # I am all of these log records, and you can open them.

ACL Managerip SRC 10.10.10.10.10.0.0/24 #acl should be the most difficult understanding of the Squid configuration also take time. It should be said that only some of the small part is required, as I only add 2 records on the original basis, one of the previous means that I define 10.10.10.10 as the source path, and another means 10.10.10.0/24 This network segment. And ManagerIP, iPcanbrows will get the name. The specific rules require the following statements to be defined. 10.10.10.10 is the intranet IP of this server, and the IP of Apache Server is in 10.10.10.0/24, and the IP address is saved to some extent to some extent. HTTP_ACCESS Allow Manager ManagerIP IPCanBrows LocalHost # plus 2 allowed. The high-profile configuration I think I don't need it. Users can access it to achieve :)

HTTPD_ACCEL_HOST Virtual # Because my Apache Server is IP-based, the virtual host is made, so it is necessary to set it to Virtual.

HTTPD_ACCEL_PORT 80 #http accelerated port, because habits, etc., or the back Apache Server listens 80 ports.

HTTPD_ACCEL_USES_HOST_HEADER ON # If you choose Virtual, you must be set to ON.

It is only 5% option, but when I configure it, I only use this, so if I get a website accelerated, the basic setting is these. Of course, if you need more powerful features, you need to read the documentation of Squid's profile.

The final step:

1. Change the permissions of the var directory: chown -rnobody var

2. Create a cache directory: sbin / squid -z

3. Start Squid: BIN / RUNACCEL & (here I use the startup script with Squid to start Squid, there is a good place to start if the Squid process is dead, this script will automatically start Squid, for the server running online Say, this is too important.

Some experiences:

1. Squid is long, the speed will slow down, my suggestion is to drop the Squid process every 2 hours, and the runaccel script will automatically start.

2. Write a script, put it in crontab, empty the cache directory around 4 in the morning.

#! / Bin / sh # squid clean swap and restart script by marco lu SQUID_DIR = / usr / local / squid-54 / PID_FILE = $ {SQUID_DIR} var / logs / squid.pidCACHE_DIR = $ {SQUID_DIR} var / cachePPID = ` PS AUX | grep -i squid-54 | grep -v Grep | awk '{print $ 2}' `Kill -9 $ {PPID}> / dev / nullkill -9` Cat $ {pid_file} `> / dev / nullrm Rf $ cache_dir / * $ {squid_dir} sbin / squid -z> / dev / nullif [$? -eq 0] Then $ {squid_dir} bin / runaccel &> / dev / nullfi

Limited horizontal, I hope the majority of expert guidance!!!

转载请注明原文地址:https://www.9cbs.com/read-125354.html

New Post(0)