欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

搭建一個(gè)大型網(wǎng)站架構(gòu)的實(shí)驗(yàn)環(huán)境(Squid緩存服務(wù)器篇)

 更新時(shí)間:2009年07月02日 14:48:00   投稿:mdxy-dxy  
Squid是一個(gè)高性能的代理緩沖服務(wù)器,也許你已經(jīng)用過(guò)Windows平臺(tái)下的WinGate,MS Proxy Server等功能類(lèi)似的產(chǎn)品。

六、squid緩存服務(wù)器的配置
squid緩存服務(wù)器在這個(gè)實(shí)驗(yàn)環(huán)境中有兩臺(tái)(192.168.10.30,192.168.10.31)做成squid集群,我們首先安裝一臺(tái),然后復(fù)制一臺(tái),再做配置,這樣省事,哈!
squid01服務(wù)器網(wǎng)絡(luò)配置
# ee /etc/rc.conf
ifconfig_lnc0="inet 192.168.10.30 netmask 255.255.255.0"
defaultrouter="192.168.10.10"           


192.168.10.30    squid01.rd.bj # ee /etc/resolv.conf
nameserver 192.168.10.40

網(wǎng)絡(luò)配置好后,我們開(kāi)始安裝squid,先把的藏身處找到:
# whereis squid30
squid30: /usr/ports/www/squid30
# cd /usr/ports/www/squid30

sq_1

===> The following configuration options are available for squid-3.0.1:
     SQUID_LDAP_AUTH=off "Install LDAP authentication helpers"
     SQUID_SASL_AUTH=off "Install SASL authentication helpers"
     SQUID_DELAY_POOLS=off "Enable delay pools"
     SQUID_SNMP=on "Enable SNMP support"
     SQUID_CARP=on "Enable CARP support"
     SQUID_SSL=off "Enable SSL support for reverse proxies"
     SQUID_PINGER=off "Install the icmp helper"

     SQUID_HTCP=on "Enable HTCP support"
     SQUID_VIA_DB=off "Enable forward/via database"
     SQUID_CACHE_DIGESTS=on "Enable cache digests"
     SQUID_WCCP=on "Enable Web Cache Coordination Prot. v1"

     SQUID_STRICT_HTTP=on "Be strictly HTTP compliant"
     SQUID_IDENT=on "Enable ident (RFC 931) lookups"
     SQUID_REFERER_LOG=on "Enable Referer-header logging"
     SQUID_USERAGENT_LOG=on "Enable User-Agent-header logging"

     SQUID_IPFW=off "Enable transparent proxying with IPFW"
     SQUID_PF=off "Enable transparent proxying with PF"
     SQUID_IPFILTER=off "Enable transp. proxying with IPFilter"
     SQUID_ICAP=off "Enable ICAP client functionality"
     SQUID_ESI=off "Enable ESI support (experimental)"

     SQUID_COSS=off "Enable the COSS storage scheme"

     SQUID_LARGEFILE=on "Support log and cache files >2GB"

     SQUID_DEBUG=off "Enable debugging options"
===> Use 'make config' to modify these settings
# make install clean
漫長(zhǎng)的安裝過(guò)程又來(lái)了, 我該干點(diǎn)什么呢?看看新浪互聯(lián)星空播客吧!速度挺快的,支持?。?!

Squid 安裝好了,現(xiàn)在開(kāi)始配置她了。安裝完后,在/usr/local/etc/squid下有squid的配置文件squid.conf和 squid.conf.default,這兩個(gè)都是一樣的,我們先刪除掉squid.conf,在建個(gè)新的squid.conf,然后把我們的配置信息寫(xiě) 在里面,這樣的話更加清晰一點(diǎn),省得在原來(lái)的配置文件中改,里面內(nèi)容那么多,改到后來(lái),自己都不知道改了那些東西,糊涂了,如果對(duì)配置有什么不清楚的還是 可以參考squid.conf.default文件的。

# rm -rf squid.conf
# touch squid.conf
# ee squid.conf

http_port 192.168.10.30:3128 vhost vport defaultsite=www.rd.bj

cache_mem 64 MB
cache_swap_low 90

maximum_object_size 20 MB
minimum_object_size 0 KB
maximum_object_size_in_memory 5 MB
ipcache_size 1024
ipcache_low 90

fqdncache_size 1024

#acl all src 0.0.0.0/0.0.0.0 #好像squid30已經(jīng)內(nèi)置了
acl gsrc src 192.168.10.20 192.168.10.30 192.168.10.31 192.168.10.40
http_access allow gsrc

acl Manager proto cache_object
acl Localhost src 127.0.0.1
http_access allow Manager Localhost

acl Safe_ports port 3128 80 3130 3131

http_access allow all


cache_mgr admin@rd.bj

cache_effective_user squid
cache_effective_group squid
tcp_recv_bufsize 65536 bytes


cache_peer_access 192.168.10.31 allow all
cache_peer 192.168.10.40 parent 80 0 no-query originserver no-digest

access_log /usr/local/squid/logs/access.log
cache_dir diskd /usr/local/squid/cache 256 16 256 Q1=60 Q2=50

error_directory /usr/local/etc/squid/errors/Simplify_Chinese

icp_port 3130
htcp_port 0
icp_query_timeout 2000
icp_access allow all
digest_generation on

icp_hit_stale on
保存退出后,我們驗(yàn)證一下配置文件是否正確:
# rehash
# squid parse

OK,現(xiàn)在我們先根據(jù)配置文件創(chuàng)建緩存目錄。
# squid -z
2007/12/27 12:43:55| Creating Swap Directories

2007/12/27 12:43:55| Making directories in /usr/local/squid/cache/00
2007/12/27 12:43:55| Making directories in /usr/local/squid/cache/01
2007/12/27 12:43:55| Making directories in /usr/local/squid/cache/02
2007/12/27 12:43:55| Making directories in /usr/local/squid/cache/03

2007/12/27 12:43:56| Making directories in /usr/local/squid/cache/05
2007/12/27 12:43:57| Making directories in /usr/local/squid/cache/06
2007/12/27 12:43:58| Making directories in /usr/local/squid/cache/07
2007/12/27 12:43:58| Making directories in /usr/local/squid/cache/08

2007/12/27 12:43:59| Making directories in /usr/local/squid/cache/0A

2007/12/27 12:43:59| Making directories in /usr/local/squid/cache/0C
2007/12/27 12:44:00| Making directories in /usr/local/squid/cache/0D

2007/12/27 12:44:01| Making directories in /usr/local/squid/cache/0F

這樣就創(chuàng)建完成了。
在這里我補(bǔ)充一點(diǎn),如果創(chuàng)建緩存目錄失敗的,多半是目錄讀寫(xiě)權(quán)限的問(wèn)題。因?yàn)槲覀兪?a href=" :;" target="_self">ports安裝的,所以系統(tǒng)會(huì)跟我們預(yù)先創(chuàng)建好squid用戶(hù)和用戶(hù)組。并把家目錄指向/usr/local/squid。所以我們這里一般不會(huì)有問(wèn)題。但是,如果大家是用下載的源碼自行編譯又想把緩存目錄換到別的位置或是用個(gè)新硬盤(pán)存放,那改怎么辦呢?我慢慢跟你道來(lái)。

首先我們格式化新硬盤(pán)
可以利用sysinstal來(lái)完成,具體操作可以參考FressBSD安裝的那個(gè)章節(jié)有介紹,這里不說(shuō)了。格式化好硬盤(pán)后,因?yàn)槲覀兪怯脕?lái)存放緩存文件的,所以我們對(duì)該塊硬盤(pán)做點(diǎn)小優(yōu)化。
# newfs -b 8192 -f 1024 /dev/ad1s1d
# tunefs -n enable /dev/ad1s1d   # 啟用Soft Updates,必需在硬盤(pán)沒(méi)有被掛載的時(shí)候或在單用戶(hù)模式下才可以應(yīng)用
# mount /dev/ad1s1d /cache
# ee /etc/fstab     # 加載硬盤(pán)

補(bǔ)充小知識(shí):

當(dāng) 我們的分區(qū)主要存放大量小型文件時(shí),我們會(huì)將block size 調(diào)小一點(diǎn),如 8K 或是 4K。而在 newfs 時(shí),我們也會(huì)指定fragment size,它的值最好是 block size 的八分之一,例如當(dāng)block size 為8K 時(shí),我們會(huì)使用newfs -b 8192 -f 1024 來(lái)格式化硬盤(pán)。如果您使用的是/stand/sysinstall 來(lái)格式化硬盤(pán),您可以在格式化硬盤(pán)時(shí)按N來(lái)設(shè)置newfs option。

新硬盤(pán)安裝好了以后,我們現(xiàn)在來(lái)做配置:
# pw groupadd squid
# pw useradd squid -s /usr/sbin/nologin -d /nonexistent -g squid
# mkdir /cache/www.rd.bj #建立緩存目錄
# chown -R squid:squid /cache/www.rd.bj
好了,現(xiàn)在只需要把squid.conf里的

改成
cache_dir diskd /cache/www.rd.bj 256 16 256 Q1=60 Q2=50

# squid -z
好了就補(bǔ)充到這里吧,我們繼續(xù)我們的探索之旅。

現(xiàn)在squid的配置文件已經(jīng)測(cè)試無(wú)誤了,那我們還等什么,趕緊測(cè)試一下服務(wù)叻!
# squid -CDNd1
2007/12/27 14:01:56| Starting Squid Cache version 3.0.STABLE1 for i386-portbld-freebsd6.3...
2007/12/27 14:01:56| Process ID 810

2007/12/27 14:01:56| DNS Socket created at 0.0.0.0, port 49839, FD 5
2007/12/27 14:01:56| Adding nameserver 192.168.10.40 from /etc/resolv.conf
2007/12/27 14:01:56| User-Agent logging is disabled.
2007/12/27 14:01:56| Referer logging is disabled.
2007/12/27 14:01:56| Unlinkd pipe opened on FD 9
2007/12/27 14:01:56| Local cache digest enabled; rebuild/rewrite every 3600/3600 sec
2007/12/27 14:01:56| Swap maxSize 262144 KB, estimated 20164 objects
2007/12/27 14:01:56| Target number of buckets: 1008

2007/12/27 14:01:56| Max Mem size: 8192 KB

2007/12/27 14:01:57| Rebuilding storage in /usr/local/squid/cache (DIRTY)

2007/12/27 14:01:57| Current Directory is /root

2007/12/27 14:01:57| Accepting accelerated HTTP connections at 192.168.10.30, port 3128, FD 11.
2007/12/27 14:01:57| Accepting ICP messages at 0.0.0.0, port 3130, FD 12.

2007/12/27 14:01:57| Configuring Sibling 192.168.10.31/3128/3131
2007/12/27 14:01:57| Configuring Parent 192.168.10.40/80/0

2007/12/27 14:02:04| Done scanning /usr/local/squid/cache swaplog (0 entries)
2007/12/27 14:02:04| Finished rebuilding storage from disk.

2007/12/27 14:02:04|         0 Invalid entries.

2007/12/27 14:02:04|         0 Objects loaded.
2007/12/27 14:02:04|         0 Objects expired.
2007/12/27 14:02:04|         0 Objects cancelled.
2007/12/27 14:02:04|         0 Duplicate URLs purged.
2007/12/27 14:02:04|         0 Swapfile clashes avoided.
2007/12/27 14:02:04|   Took 6.97 seconds ( 0.00 objects/sec).

2007/12/27 14:02:04|   Completed Validation Procedure
2007/12/27 14:02:04|   Validated 25 Entries
2007/12/27 14:02:04|   store_swap_size = 0
2007/12/27 14:02:04| storeLateRelease: released 0 objects

啟動(dòng)沒(méi)有什么問(wèn)題,來(lái)我們用瀏覽器訪問(wèn)一下吧!
sq_2

正式啟動(dòng)可以使用:

OK,我們的Squid01的配置就到這里, 現(xiàn)在我們關(guān)閉虛擬機(jī),然后拷貝一份squid01為squid02,用來(lái)配置另一臺(tái)Squid服務(wù)器。

復(fù)制好squid02后,我們現(xiàn)在開(kāi)始配置了, 應(yīng)為squid01的大部分工作都已經(jīng)做好了, 所以squid02的配置就比較方便了,只要是配置文件中IP地址和機(jī)器名的修改。

# ee /etc/rc.conf

defaultrouter="192.168.10.10"           
hostname="squid02.rd.bj"

# ee /etc/hosts
192.168.10.31    squid02.rd.bj

# ee /usr/local/etc/squid/squid.conf
最后修改好的配置文件為:
http_port 192.168.10.31:3128 vhost vport defaultsite=www.rd.bj


cache_swap_low 90
cache_swap_high 95

minimum_object_size 0 KB
maximum_object_size_in_memory 5 MB
ipcache_size 1024
ipcache_low 90
ipcache_high 95
fqdncache_size 1024

#acl all src 0.0.0.0/0.0.0.0

http_access allow gsrc

acl Manager proto cache_object
acl Localhost src 127.0.0.1
http_access allow Manager Localhost

acl Safe_ports port 3128 80 3130 3131

http_access allow all

visible_hostname squid01.rd.bj
cache_mgr admin@rd.bj

cache_effective_group squid                          
tcp_recv_bufsize 65536 bytes                         
cache_peer 192.168.10.30 sibling 3128 3130           

cache_peer 192.168.10.40 parent 80 0 no-query originserver no-digest
access_log /usr/local/squid/logs/access.log
cache_dir diskd /usr/local/squid/cache 256 16 256 Q1=60 Q2=50

icp_port 3131

icp_query_timeout 2000
icp_access allow all
digest_generation on
log_icp_queries on

最后,關(guān)于Squid,給大家推薦一本好書(shū)《Squid中文權(quán)威指南》雖然講的是squid2.5版本的,但是有很好的指導(dǎo)意義,我相信大多數(shù)人都已經(jīng)看過(guò)了,在此推薦是對(duì)作者辛勤勞動(dòng)的無(wú)比崇敬。好,我們即將要踏上proxy服務(wù)器之旅。

相關(guān)文章

  • Ubuntu20.04防火墻設(shè)置簡(jiǎn)易教程(小白)

    Ubuntu20.04防火墻設(shè)置簡(jiǎn)易教程(小白)

    這篇文章主要介紹了Ubuntu20.04防火墻設(shè)置簡(jiǎn)易教程(小白),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • 一道題理解Linux中sort命令的多個(gè)參數(shù)

    一道題理解Linux中sort命令的多個(gè)參數(shù)

    今天小編就為大家分享一篇關(guān)于一道題理解Linux中sort命令的多個(gè)參數(shù),小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2019-03-03
  • 如何使用Linux文本操作命令ed進(jìn)行提權(quán)nov5詳解

    如何使用Linux文本操作命令ed進(jìn)行提權(quán)nov5詳解

    這篇文章主要給大家介紹了關(guān)于如何使用Linux文本操作命令ed進(jìn)行提權(quán)nov5的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Linux系統(tǒng)具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-08-08
  • linux下安裝ffmpeg的詳細(xì)教程

    linux下安裝ffmpeg的詳細(xì)教程

    這篇文章主要介紹了linux下安裝ffmpeg的詳細(xì)教程,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-07-07
  • Linux環(huán)境下GRE的部署方式

    Linux環(huán)境下GRE的部署方式

    這篇文章主要介紹了Linux環(huán)境下GRE的部署方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-12-12
  • centos7云主機(jī)系統(tǒng)下掛載磁盤(pán)的方法

    centos7云主機(jī)系統(tǒng)下掛載磁盤(pán)的方法

    本篇文章主要介紹了centos7云主機(jī)系統(tǒng)下掛載磁盤(pán)的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-02-02
  • Centos7修改主機(jī)名hostname的三種方法

    Centos7修改主機(jī)名hostname的三種方法

    今天小編就為大家分享一篇關(guān)于Centos7修改主機(jī)名hostname的三種方法,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2019-01-01
  • Linux初學(xué)(CnetOS7 Linux)之切換命令模式和圖形模式的方法

    Linux初學(xué)(CnetOS7 Linux)之切換命令模式和圖形模式的方法

    本篇文章主要介紹了Linux初學(xué)(CnetOS Linux7)之切換命令模式和圖形模式的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-03-03
  • Linux之進(jìn)程的虛擬地址空間,邏輯地址和物理地址,進(jìn)程管理命令

    Linux之進(jìn)程的虛擬地址空間,邏輯地址和物理地址,進(jìn)程管理命令

    這篇文章主要介紹了Linux之進(jìn)程的虛擬地址空間,邏輯地址和物理地址,進(jìn)程管理命令,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-03-03
  • CentOS環(huán)境下安裝PHPUnit的方法分析

    CentOS環(huán)境下安裝PHPUnit的方法分析

    這篇文章主要介紹了CentOS環(huán)境下安裝PHPUnit的方法,結(jié)合實(shí)例形式分析了CentOS環(huán)境下安裝PHPUnit的步驟、相關(guān)問(wèn)題與解決方法,需要的朋友可以參考下
    2018-05-05

最新評(píng)論