都是cache惹的禍

環境

Squid server:

IP:

eth0 192.168.77.222

eth1 192.168.7.222

Squid.conf:

http_port 192.168.7.222:80 vport vhost

cache_peer 192.168.77.225 parent 80 0 no-query originserver weight=1 name=b

cache_peer 192.168.77.221 parent 80 0 no-query originserver weight=2 name=a

cache_peer_domain a www.test1.com

cache_peer_domain b www.test2.com

cache_peer_access a allow all

cache_peer_access b allow all

client:

IP:

eth0 192.168.7.223

Apache server1:

192.168.7.221 index.html:This is Apache server1 .My IP is 192.168.7.221

Apache server2:

192.168.7.225 index.html:This is Apache server2 .My IP is 192.168.7.225

實際應用中遇到的問題:

今天在試驗中遇到一個很奇怪的問題,我在client地址欄中輸入:

www.test1.com 顯示:This is Apache server1 .My IP is 192.168.7.221

www.test2.com 顯示:This is Apache server2 .My IP is 192.168.7.225

192.168.7.222 顯示:This is a test!(我以前測試時候寫的內容,但是早都已經刪除了)

很鬱悶,想Google也沒辦法google。沒辦法,只能自己來。

思路:

1. 首先我想着是不是squid.conf文件是否錯誤。

a) 經過仔細檢查後派出配置文檔錯誤

2. 檢查Apache服務是否啓動

因爲我的代理端口端口時80,所以Apache服務早都已經挺了,可以說不用考慮的。但是苦於無法只能又檢查一遍

b)確定不是本機Apache的問題

3. 檢查/var/www/html/index.html

c)分別檢查了squid server和兩臺Apache server index.html文件壓根就沒有This is a test!這句話,很是鬱悶。

4. 出絕招了.

不是辦法的辦法.從根/ 下搜包含This is a test!這句話的文件,只要找到了這句話所在的文件,就知道問題所在了.

d)grep ‘This is a test!’ / =========== 無果而終 ~_~

5. 後來突然發現可能是cache沒有清! 激動

e)# ./squidclient -h 192.168.7.222 -p 80 PURGEA http://192.168.7.222

HTTP/1.0 200 OK

Date: Tue, 06 Jul 2010 21:04:16 GMT

Server: Apache/2.2.3 (CentOS)

Last-Modified: Mon, 05 Jul 2010 17:47:10 GMT

ETag: "10e03ab-10-86a56380"

Accept-Ranges: bytes

Content-Length: 16

Content-Type: text/html; charset=UTF-8

Age: 94967

Warning: 113 song.domain.com (squid/3.1.4) This cache hit is still fresh and more than 1 day old

X-Cache: HIT from song.domain.com

Via: 1.0 song.domain.com (squid/3.1.4)

Connection: close

This is a test!

終於被我逮到了(但是我剛纔從根/開始搜索的時候爲什麼沒有結果呢?),再到client測試

滿懷期待,還是無果而終,還是This is a test!.

鬱悶啊!那個鬱悶,還真的沒折了.

俗話說成功只在一步之遙!哈哈,

6. 成功進行曲最後一步:

f) 最後索性直接跑到cache目錄下/usr/local/squid/var/cache/00/00

#grep 'this is a test' ./*

Binary file ./00000000 matches

Binary file ./00000001 matches

Binary file ./00000002 matches

但是剛纔的命令爲什麼沒有清掉呢!?…………………….探索…………………………..

Caches caches 都是caches惹的禍!!索性一股腦把文件夾下的cache全部刪除了。再到client ok 問題解決。哈哈 =_=

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章