交通大学计算机中心陈昌盛Emailcschen@ccnctuedutw.ppt

上传人:sccc 文档编号:6128036 上传时间:2023-09-26 格式:PPT 页数:73 大小:264.51KB
返回 下载 相关 举报
交通大学计算机中心陈昌盛Emailcschen@ccnctuedutw.ppt_第1页
第1页 / 共73页
交通大学计算机中心陈昌盛Emailcschen@ccnctuedutw.ppt_第2页
第2页 / 共73页
交通大学计算机中心陈昌盛Emailcschen@ccnctuedutw.ppt_第3页
第3页 / 共73页
交通大学计算机中心陈昌盛Emailcschen@ccnctuedutw.ppt_第4页
第4页 / 共73页
交通大学计算机中心陈昌盛Emailcschen@ccnctuedutw.ppt_第5页
第5页 / 共73页
点击查看更多>>
资源描述

《交通大学计算机中心陈昌盛Emailcschen@ccnctuedutw.ppt》由会员分享,可在线阅读,更多相关《交通大学计算机中心陈昌盛Emailcschen@ccnctuedutw.ppt(73页珍藏版)》请在三一办公上搜索。

1、1,交 通 大 學 計 算 機 中 心陳 昌 盛E-mail:cschencc.nctu.edu.tw,WWW Proxy/Cache 系統的建置與管理,TANet Web-proxy Tutorial Course,88.05.14,2,WWW Proxy/Caching 系統簡介(p3-p23)Squid 2.x 的建置與設定(p23-p44)其他相關的系統管理課題(p45-p53)附錄(p54-),課程大綱,3,相關網站http:/www.auth.gr/Squid/(squid home page)http:/cache.is.co.za(squid.conf 設定檔)http:/(F

2、AQ)http:/proxy.nctu.edu.twRFC 1016,2186,2187Mailing Listsquid-users-http:/proxy.nctu.edu.tw/mailing,相關的資訊來源,4,WWW Proxy 系統簡介,Web Proxy/Caching 介紹TANet 骨幹頻寬分割使用(24M bps)163.28.0.0 server 專用 channel(16M bps)關於 Squid,5,Web Caching-基礎篇,什麼是 web caching?什麼是 browser caching什麼是 proxy caching?Transparent Pro

3、xy http accelerator vs proxy/cachingaccelerator:加快 remote 取 local 資料caching:加快 local 取 remote 資料Redirector 改寫 URL,管制連線對象,6,Web caching server 運作基本觀念,Web caching 的基本運作原理hit:文件檔在 cache 中miss:文件檔不在 cache 中refresh_hit,refresh_misspositive caching vs negative caching,7,Web caching 相關protocol 的運作,TCP conn

4、ection 的使用時機browsers/cache 到另一個 web server 或 cache 取回資料UDP connection 的使用時機某一 cache server 用以,查詢其他的 neighbor cache,有無一筆該站想要的資訊ICP query(index 資料),8,Proxy/caching server,HDcache,PC client,Internet,Fig.1 Proxy/caching server 運作示意圖,TANet 區域網路使用者,163.28.xxx.yyy,TANet Gateway,X,1a,2a,1b,2b,3b,4b,9,電子期刊等專

5、用Proxy server,PC client,Internet,Fig.2 電子期刊專用 Proxy server 運作圖,限制使用對象(必須註冊),163.28.xxx.yyy,TANet Gateway,No Cache allowed,10,HDcache,Internet,Fig.3 Transparent Proxy/caching 運作示意圖,TANet Gateway,Proxy,PC client,1,2,3,4,5,6,7b,7a,Router/Layer4 SW,11,httpdaccelerator,HDcache,Local www server,Internet,F

6、ig.4 www accelerator server 運作圖,Redirector on 163.28.xxx.yyy,TANet Gateway,1a,1b,2a,2c,2b,1c,Port 80,Inside firewall,12,Proxy Cache Metric(參考數字),From IRCACHE projectHit ratio(25%-30%)byte hit ratio(20%,通常低於前一項)http:/Proxy networkHit ratio(30%-35%)byte hit ratio(60%-70%)http:/proxy.nctu.edu.tw/http:/

7、www.edu.tw/moecc/index.htm(選文宣刊物),13,Fig.5 Proxy.NCTU.edu.tw 的使用情況(1998/11/27),(T),(P),(C),14,全球 Proxy Cache 網路架構,美國 NLANR 的 IRCACHE 網路http:/其他各地,可以從上面網頁連上臺灣地區 proxy cache 網路http:/cache.sinica.edu.tw/cache/index.html,15,Fig.6 IRCACHE 的架構,from http:/,16,Proxy-NCTU,Internet,MOE,Proxy-N,Fig.7 TANet 骨幹的

8、 Proxy Network(163.28.0.0),TANet gateway,17,Squid Cache Hierarchy,Parent/child cacheparent 靠近網路骨幹,child 在較偏遠端parent 替 child 解決 cache misssiblings(同一層-原意,兄弟姐妹)siblings 相互支援(loading 分攤)有一套固定的運作方式(下一頁),18,Squid Cache Resolution Algorithm,Send ICP queries to all appropriate siblings Wait for all replies

9、 to arrive with a configurable timeout(the default is two seconds).Begin fetching the object upon receipt of the first HIT reply,or Fetch the object from the first parent which replied with MISS(subject to weighting values),or Fetch the object from the source,19,Proxy server,HDcache,Internet,Fig.8 P

10、roxy/caching 與 DNS server 搭配 運作圖,163.28.xxx.yyy,TANet Gateway,DNS server,PC client,1,2,3a,3b,4,5,6a,6b,20,What is Squid?(1),Squid 從美國的 Harvest 計劃而來(ARPA 支援).Squid 是一個高效能的 proxy caching server 系統軟體supporting FTP,gopher,and HTTP data objectsSquid handles all requests in a single,non-blocking,I/O-drive

11、n process.,21,What is Squid?(2),Squid supports SSL,extensive access controls,and full request logging.使用 ICP 通信協定(Internet Cache Protocol)squid caches 可以安排成階層式(hierarchy)或 網狀(mesh)的網路.,22,What is Squid?(3),Squid keeps meta data and especially hot objects cached in RAMcaches DNS lookups,supports non-

12、blocking DNS lookups,and implements negative caching of failed requests.,23,Proxy 系統的建置與管理,Proxy server 選定與安裝Cache hierarchy(neighbor sites)Access controlGateway program(Gopher,Ftp,)Cache administration&Expiration Cache 存放空間的管理系統記錄與製做統計報告,24,WWW Proxy server 的規畫,WWW Proxy server 的規畫Memory,Disk,Netwo

13、rk,CPU,UPS system最重要的系統資源是主記憶體(physical memory).硬碟系統(disk),通常是系統主要效能的瓶頸.,25,NCTU Proxy server 的規畫,Hardware(3 套)300 Mhz Pentium II CPU512MB RAM10*4GB UW-SCSI(IBM)共約 120 GB100M Network Interface Card(Intel)SoftwareFreeBSD-2.2.8-stablesquid 2.2,26,取得 Proxy server Squid 軟體,Squid software 的取得ftp:/(原始站)ft

14、p:/ftp.nctu.edu.tw/WWW/Proxy/Squid/squid-2/*Squid Server 的安裝 FAQhttp:/www.auth.gr/Squid/FAQ/FAQ.htmlUser Guide http:/www.auth.gr/SquidUsers/,27,Squid 2.x 的組成,Squid-主要 server 程式dnsserver-外掛的 DNS 查詢程式 附帶的管理與用戶單連線工具程式,28,Squid-2 的建置與設定,Getting and Compiling Squid%tar xzf squid-2.2-src.tar.gz%cd squid-2

15、.2.RELEASE%./configure-prefix=/home/squid%make,29,Squid 中典型的系統目錄,範例(/home/squid/)bin,cgi-bin,etc,logs,scripts主要設定檔安置目錄(/home/squid/etc/*)squid.conf,mime.conf,mib.txt,icons/*,errors/*系統記錄檔存放目錄(/home/squid/logs/*)access.log,cache.log,.Squid port http_port:3128 icp_port:3130,30,How do I start Squid 2.x

16、?,編輯 squid.conf/usr/local/squid/bin/squid-z首先將 cache swap 目錄造出來/usr/local/squid/bin/RunCache&執行 RunCache 這個批次檔,開始啟動 squid 這一組程式,31,Squid.conf 設定的項目分類(1),網路相關的設定選項影響“neighbor 選擇法則”運作的選項影響 cache size 設定的選項記錄檔(log)路徑名稱與 cache directors“外部支援程式“相關的選項調整(tuning)caching 效能的選項 timeouts,32,Squid.conf 的設定項目分類(

17、2),存取管制(Access control)Proxy 系統管理(Administrative parameters)Options for the cache registration servicehttpd-accelerator options其它雜項設定(Miscellaneous)限制各別站臺的使用頻寬(Delay Pool parameters),33,Squid 的功能,補充說明,Ipcache,FQDNcacheIpcache:Hostname to IP-Number mappingFQDNCache:IP-Number to Hostname mappingCache

18、Digest(2.x)a summary of the contents of an Internet Object Caching Serveran indication of whether or not particular URLs are in the cacheX-Forwarded-ForX-Forwarded-For:128.138.243.150,unknown,192.52.106.30,34,Squid.conf 中,需要定義的參數-“proxy.nctu.edu.tw”上的實例,大多數的參數使用內定值(default)底下就列出需要重新定義者Cache_peer pro

19、xy.edu.tw sibling 3128 3130 no-netdb-exchangecache_mem128Mcache_swap_low 93 cache_swap_high 95cache_mem_low 90cache_mem_high 95maximum_object_size 16384 KB,35,Squid.conf(cont.),ipcache_size 20480(hostname-IP addr.)ipcache_low 90ipcache_high 95fqdnsize 20480(IP addr-FQDN)cache_dir(可以再加)cache_dir/home

20、/squid/cache 100 16 256cache_dir/da1s1e 4000 32 32 logfile_rotate 10,36,增建一個 cache directory(Squid.conf),增建某一個 cache directory的程序編輯squid.conf,增加一筆cache_dir 項目行將該directory 初始化,執行#squid-z通知Squid 重新分配cache 的分佈,執行#squid-k reconfigure不必停掉執行中的squid 程式,37,移除某一個cache directory(Squid.conf),移除某一個cache directo

21、ry編輯squid.conf,刪掉該筆cache_dir 項目行將執行中的 squid 重新執行(shutdown and restart)#squid-k shutdown#重新執行 squid(使用RunCache 會自動重跑)刪除原系統中,已不用的 cache directory必須中斷執行中的squid 程式,38,不想 cache 臨近地區的data(squid.conf),使用 no_cache 這個選項功能編輯 squid.conf(squid-2)範例 1(IP address)acl Local dst 140.113.0.0/16no_cache deny Local範例

22、2(domain name)acl Local_D dstdomain edu.twno_cache deny Local_D,39,Squid cache replacement algorithm,LRU(Least Recent Used)是最基本原則Low water mark(90%),High water mark(95%)優先移除者negative cached,private key最後一次存取時間超過 LRU 的期限(threshold)不可移除者有其他用戶正需求這一個檔正從上游站,取過來的檔,40,關於 Access Control 的設定,acl,http_access,

23、icp_accessallow/denyAnd/Or LogicsAll elements of an acl entry are ORed together.All elements of an access entry are ANDed together.e.g.http_access and icp_access.src/srcdomain,dst/dstdomain,41,squid.conf(cont.)-access control 1,設立 Cache Manageracl manager proto cache_objectacl localhost src 127.0.0.

24、1/255.255.255.255acl Proxy src proxy.nctu.edu.tw proxy2.nctu.edu.tw proxy3.nctu.edu.twacl purge method purgeacl FTP proto FTPacl all src 0.0.0.0/0.0.0.0,42,squid.conf(cont.)-access control 2,acl twdn dstdomain tw acl TANet src 163.28.0.0/16 proxy.thu.edu.tw acl HCdn srcdomain nthu.edu.tw nchc.gov.tw

25、 srrc.gov.tw chu.edu.tw nhctc.edu.tw hceb.edu.tw hc.edu.tw hcc.edu.tw cic.edu.tw mhit.edu.tw firdi.org.tw hchcc.gov.tw lctc.edu.tw ymit.edu.tw chinmin.edu.tw thctc.edu.tw,43,squid.conf(cont.)-access control(3),Http_accesshttp_access allow manager Proxyhttp_access deny managerhttp_access deny allicp_

26、accessicp_access allow TANet.icp_access deny all,44,ACL ban list(管制),範例 1(找 keyword,用 regular expression)acl Cooking1 url_regex cookingacl Recipe1 url_regex recipehttp_access deny Cooking1http_access deny Recipe1http_access allow all範例 2(用 domain name)acl Cooking2 dstdomain gourmet-http_access deny

27、Cooking2http_access allow all,45,Syslog maintenance,/home/squid/etc/squid.conflogfile_rotate 3 Crontab entry for log-rotate 0 0*/bin/kill-USR1 cat/home/squid/logs/squid.pid每天執行一次,以避免記錄檔越來越大,無法處理,46,相關管理的工具程式,wget on proxy server homepagecache manager CGI(cachemgr.cgi)使用 Apache 為例srm.conf,squid.conf,

28、access.confauto-proxy configuration support,47,設定 Cache Manager(Apache)-參考 FAQ 9.1-9.9,/home/squid/etc/srm.confScriptAlias/Squid/cgi-bin/home/squid/cgi-bin/home/squid/etc/access.conforder deny,allowdeny form allallow from proxy.nctu.edu.tw,proxy2.nctu.edu.tw,48,設定 Cache Manager(Apache)-參考 FAQ 9.1-9.

29、9(cont.),/home/squid/etc/squid.confacl manager proto cache_objectacl localhost srt 127.0.0.1/255.255.255.255acl all src 0.0.0.0/0.0.0.0#http_access deny manager!localhosthttp_access allow all,49,Sample-access.log(1),912355210.560 10097 super.Dorm9.NCTU.edu.tw TCP_MISS/000 0 GET http:/-DIRECT/-912355

30、210.712 0 ccproxy.nsysu.edu.tw UDP_MISS/000 76 ICP_QUERY http:/-NONE/-912355210.712 0 w3-gate2.ntu.edu.tw UDP_DENIED/000 82 ICP_QUERY http:/.hk/drama/image/home/top_link/newsong_d.gif-NONE/-912355210.712 0 proxy.ncku.edu.tw UDP_HIT/000 70 ICP_QUERY http:/-NONE/-912355210.718 10171 proxy.nthu.edu.tw

31、TCP_REFRESH_HIT/304 265 GET http:/-DIRECT/-912355211.482 358 bill.Dorm-GD1.NCTU.edu.tw TCP_HIT/200 1762 GET http:/-NONE/-text/html912355211.482 358 hilbert.Dorm-GD1.NCTU.edu.tw TCP_IMS_HIT/304 225 GET http:/-NONE/-image/gif,50,Sample-cache.log,1998/11/30 06:10:34|Starting Squid Cache version 2.1.PAT

32、CH1 for i386-unknown-freebsd2.2.7.1998/11/30 06:10:34|Process ID 186541998/11/30 06:10:34|With 1024 file descriptors available1998/11/30 06:10:34|Performing DNS Tests.1998/11/30 06:10:34|Successful DNS name lookup tests.1998/11/30 06:10:34|helperOpenServers:Starting 20 dnsserver processes1998/11/30

33、06:10:34|Unlinkd pipe opened on FD 291998/11/30 06:10:34|Swap maxSize 32768000 KB,estimated 1638400 objects1998/11/30 06:10:34|Target number of buckets:409601998/11/30 06:10:34|Using 65536 Store buckets,replacement runs every 1 second 1998/11/30 06:10:34|Max Mem size:131072 KB1998/11/30 06:10:34|Max

34、 Swap size:32768000 KB1998/11/30 06:10:34|Store logging disabled 1998/11/30 06:10:34|Rebuilding storage in Cache Dir#0(CLEAN),51,Sample-cache.log(2),1998/11/30 06:10:34|Rebuilding storage in Cache Dir#7(CLEAN)1998/11/30 06:10:34|Loaded Icons.1998/11/30 06:10:35|Accepting HTTP connections on port 312

35、8,FD 65.1998/11/30 06:10:35|Accepting ICP messages on port 3130,FD 66.1998/11/30 06:10:35|Accepting SNMP messages on port 3401,FD 67.1998/11/30 06:10:35|Ready to serve requests.1998/11/30 06:10:35|Configuring Sibling proxy.edu.tw/3128/31301998/11/30 06:10:35|Configuring Sibling w3-gate2.ntu.edu.tw/3

36、128/31301998/11/30 06:10:35|Configuring Sibling proxytest.ncu.edu.tw/3128/31301998/11/30 06:10:35|Configuring Sibling cache.nchu.edu.tw/3128/31301998/11/30 06:10:35|Configuring Sibling proxy.ccu.edu.tw/3128/31301998/11/30 06:10:35|Configuring Sibling gate.ncku.edu.tw/3128/31301998/11/30 06:10:35|Con

37、figuring Sibling ccproxy.nsysu.edu.tw/3128/31301998/11/30 06:10:36|65536 Entries read so far.,52,Sample-cache.log(3),1998/11/30 06:45:13|Detected DEAD Sibling:proxytest.ncu.edu.tw/3128/31301998/11/30 06:45:13|Detected REVIVED Sibling:proxytest.ncu.edu.tw/3128/31301998/11/30 06:47:07|clientIfRangeMat

38、ch:Weak ETags are not allowed in If-Range:b406e-5b6-36279831?b406e-5b6-36279831”1998/11/30 06:50:48|internalStart:unknown request:GET/squid-internal-periodic/store_digest HTTP/1.0Accept:application/cache-digestAccccept:text/htmlVia:0.0 ccproxy.nsysu.edu.tw:3128(Squid/2.1.PATCH1)X-Forwarded-For:unkno

39、wnHost:w3-gate.nctu.edu.tw:3128Cache-Control:max-age=1209600Connection:keep-alive,53,Sample-cache.log(4),1998/11/30 08:13:49|urlParse:URI has whitespace:http:/s_uniqid=2Em4/MoNZkfAd4vndA1998/11/30 08:14:01|urlParse:URI has whitespace:http:/s_uniqid=2Em4/MoNZkfAd4vndA1998/11/30 08:14:10|clientSendMor

40、eData:Deferring http:/08:14:10|clientKeepaliveNextRequest:FD 107 Sending next1998/11/30 08:14:14|urlParse:URI has whitespace:http:/s_uniqid=2Em4/MoNZkfAd4vndA1998/11/30 08:19:52|urlParse:URI has whitespace:http:/WIDTH=1998/11/30 08:19:53|urlParse:URI has whitespace:http:/WIDTH=1998/11/30 08:23:28|De

41、tected DEAD Sibling:proxy.edu.tw/3128/31301998/11/30 08:23:30|Detected REVIVED Sibling:proxy.edu.tw/3128/3130,54,附錄,Transparent Proxy 的設定HTTP Accelerator 設定範例http:/proxy.nctu.edu.tw如何使用交通大學 Proxy 服務Proxy.nctu.edu.tw 使用量分佈統計Cache Manager 的 Sample,55,Transparent Proxy(Squid 設定),讓 transparent proxy 運作的

42、三道程序將 packets 導到 proxy/cache host透過 router,layer4 switch讓你的 cache host 接受這些經過重導的packet,並轉送到機器上的 proxy/cache 程式ipfwdadm(Linux),ipnat/ip-filter(FreeBSD&Others)設定 squid 認下這一些 packet,並找出目的地 address,56,Squid 當 HTTP Accelerator 的範例,範例 1http_port 80httpd_accel_host localhosthttpd_accel_port 81httpd_accel_w

43、ith_proxy on 這一行的作用,同時當 proxy,accelerator範例 2:http_port 80httpd_accel_host httpd_accel_port 80,57,如何使用交通大學 Proxy 服務-http:/proxy.nctu.edu.tw,Proxy 相關資訊使用須知 一般使用者設定方法(user 端配合設定)其它區網中心與上游的 Proxy(acl 與 cache 設定)新竹地區各單位 Proxy(acl 與 cache 設定),58,選擇適合的 Auto Proxy Configuration,由於網路架構的不同,以及為了 reliability 的

44、考量,交通大學校內與校外單位所使用的設定檔並不相同,我們同時提供數份相同的 Auto Proxy 設定檔,請選擇正確的設定檔。外校單位(清華、中央、工研院等)http:/nctu.edu.tw/proxy.pachttp:/proxy.nctu.edu.tw/proxy.pachttp:/proxy2.nctu.edu.tw/proxy.pac交通大學校內http:/nctu.edu.tw/nctu.pachttp:/proxy.nctu.edu.tw/nctu.pac http:/proxy2.nctu.edu.tw/nctu.pac,59,如何設定 Auto Proxy Configura

45、tion,MSIE 4.x 檢視-Internet 選項-連線-自動組態-組態然後在 URL 的地方填入 Auto Proxy URL,並按 Reload 後,即可使用Netscape 4.06+Edit-Preferences-Advanced-Proxies-Automatic Proxy Configuration然後在 URL 的地方填入 Auto Proxy URL,並按 Reload 後,即可使用,60,如何加入一個 cache hierarchy/mesh?-squid 2.x,在 2.x 的 squid.conf 中,使用 cache_peer 這個 directive 來分別

46、指定 parent(上一層)or sibling(同一層)的結點 這裏以 proxy.nctu.edu.tw 給新竹區網下其他單位cache_peer w3-gate.nctu.edu.tw parent 3128 3130 no-query no-netdb-exchangecache_peer w3-gate2.nctu.edu.tw parent 3128 3130 no-query no-netdb-exchangecache_peer w3-gate2.nctu.edu.tw parent 3128 3130 no-query no-netdb-exchange這裏以 proxy.n

47、ctu.edu.tw 給骨幹上的其他 Proxy Servers(163.28.),設定為例(e.g.NCU,NTU,NCKU,etc.)cache_peer w3-gate.nctu.edu.tw sibling 3128 3130 no-netdb-exchange cache_peer w3-gate2.nctu.edu.tw sibling 3128 3130 no-netdb-exchange cache_peer w3-gate3.nctu.edu.tw sibling 3128 3130 no-netdb-exchange,61,使用交通大學所提供的 Proxy Server 時

48、,您可能會遇到的疑問。,為什麼會遇到 Access Denied 的錯誤訊息?請確定您是 TANet 新竹區使用者,包括交通大學,清華大學,高速電腦中心,中華大學,新竹師院以及其他連接於新竹區網中心的單位 請確定您的 IP 之 DNS 正查與反查設定正確 請設定 Auto Proxy Configuration 請將 URL 中的 IP 部分改為 FQDN,(ex:http:/140.113.250.5-http:/www.nctu.edu.tw)由於 IP 容易造成 auto proxy config 誤判,所以請避免使用 IP 形式之 URL 為什麼不能存取 NCTUCCCA.edu.tw

49、?新竹地區使用者,請就近利用 NCTUCCCA.NCTU.edu.tw,62,Proxy Server 統計,NCTU Proxy Servers 使用量排名統計proxy,proxy2,proxy3NCTU Proxy Servers 使用量統計分析proxy,proxy2,proxy3,63,Squid Statistics for proxy.nctu.edu.tw:3128-http:/proxy.nctu.edu.tw/logs/19981127.html,1.Summary of Request Method Usage 2.Summary of Protocol Usage 3.

50、Summary of Client Usage 4.Summary of Server Usage 5.Summary of URL Types 6.Summary of URL Top-Level Domains 7.Client Utilization 8.Top 200 HTTP Requests 9.Top 200 ICP Requests 10.Top 200 CONNECT Requests,64,Top 10 sites by xfers(1998/11/26)-reqs%all%xfers%hit MB%all%hit kB/xf kB/s,185571 4.4 0.0-0.0

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 建筑/施工/环境 > 农业报告


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号