交通大学计算机中心陈昌盛.ppt_第1页
交通大学计算机中心陈昌盛.ppt_第2页
交通大学计算机中心陈昌盛.ppt_第3页
交通大学计算机中心陈昌盛.ppt_第4页
交通大学计算机中心陈昌盛.ppt_第5页
已阅读5页,还剩68页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1,交 通 大 學 計 算 機 中 心 陳 昌 盛 E-mail: .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 設定檔) ( FAQ) .tw RFC 1016, 2186, 2187 Mailing List .tw/mailing,相關的資訊來源,4,WWW Proxy 系統簡介,Web Proxy/Caching 介紹 TANet 骨幹頻寬分割使用 ( 24M bps) server 專用 channel ( 16M bps ) 關於 Squid,5,Web Caching - 基礎篇,什麼是 web caching ? 什麼是 browser caching 什麼是 proxy caching ? Transparent Proxy http accelerator vs proxy/caching accelerator : 加快 remote 取 local 資料 caching : 加快 local 取 remote 資料 Redirector 改寫 URL, 管制連線對象,6,Web caching server 運作基本觀念,Web caching 的基本運作原理 hit: 文件檔在 cache 中 miss: 文件檔不在 cache 中 refresh_hit, refresh_miss positive caching vs negative caching,7,Web caching 相關protocol 的運作,TCP connection 的使用時機 browsers/cache 到另一個 web server 或 cache 取回資料 UDP connection 的使用時機 某一 cache server 用以, 查詢其他的 neighbor cache , 有無一筆該站想要的資訊 ICP query ( index 資料),8,Proxy/caching server,HD cache,PC client,Internet,Fig. 1 Proxy/caching server 運作示意圖,TANet 區域網路使用者,163.28.xxx.yyy,TANet Gateway,X,1a,2a,1b,2b,3b,4b,9,電子期刊等專用 Proxy server,PC client,Internet,Fig. 2 電子期刊專用 Proxy server 運作圖,限制使用對象 (必須註冊),163.28.xxx.yyy,TANet Gateway,No Cache allowed,10,HD cache,Internet,Fig. 3 Transparent Proxy/caching 運作示意圖,TANet Gateway,Proxy,PC client,1,2,3,4,5,6,7b,7a,Router/Layer4 SW,11,httpd accelerator,HD cache,Local www server,Internet,Fig. 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 project Hit ratio (25% - 30%) byte hit ratio ( 20%, 通常低於前一項) / NCTU Proxy network Hit ratio ( 30%-35%) byte hit ratio ( 60%-70%) .tw/ .tw/moecc/index.htm ( 選文宣刊物),13,Fig.5 Proxy.NCTU.edu.tw 的使用情況 (1998/11/27),(T),(P),(C),14,全球 Proxy Cache 網路架構,美國 NLANR 的 IRCACHE 網路 其他各地, 可以從上面網頁連上 臺灣地區 proxy cache 網路 .tw/cache/index.html,15,Fig.6 IRCACHE 的架構, from ,16,Proxy-NCTU,Internet,MOE,Proxy-N,Fig. 7 TANet 骨幹的 Proxy Network ( ),TANet gateway,17,Squid Cache Hierarchy,Parent/child cache parent 靠近網路骨幹 , child 在較偏遠端 parent 替 child 解決 cache miss siblings ( 同一層 原意, 兄弟姐妹) siblings 相互支援 ( loading 分攤 ) 有一套固定的運作方式 (下一頁),18,Squid Cache Resolution Algorithm,Send ICP queries to all appropriate siblings Wait for all replies 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,HD cache,Internet,Fig. 8 Proxy/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 objects Squid handles all requests in a single, non-blocking, I/O-driven 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 RAM caches DNS lookups, supports non-blocking DNS lookups, and implements negative caching of failed requests.,23,Proxy 系統的建置與管理,Proxy server 選定與安裝 Cache hierarchy ( neighbor sites ) Access control Gateway program ( Gopher, Ftp, ) Cache administration & Expiration Cache 存放空間的管理 系統記錄與製做統計報告,24,WWW Proxy server 的規畫,WWW Proxy server 的規畫 Memory, Disk, Network, CPU, UPS system 最重要的系統資源是主記憶體 (physical memory). 硬碟系統 (disk), 通常是系統主要效能的瓶頸.,25,NCTU Proxy server 的規畫,Hardware( 3 套) 300 Mhz Pentium II CPU 512MB RAM 10 * 4GB UW-SCSI ( IBM ) 共約 120 GB 100M Network Interface Card ( Intel ) Software FreeBSD-2.2.8-stable squid 2.2,26,取得 Proxy server Squid 軟體,Squid software 的取得 (原始站) .tw/WWW/Proxy/Squid/squid-2/* Squid Server 的安裝 FAQ http:/www.auth.gr/Squid/FAQ/FAQ.html User 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.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 ?,編輯 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 的設定項目分類(2),存取管制 (Access control) Proxy 系統管理 (Administrative parameters) Options for the cache registration service httpd-accelerator options 其它雜項設定 (Miscellaneous) 限制各別站臺的使用頻寬 (Delay Pool parameters ),33,Squid 的功能, 補充說明,Ipcache, FQDNcache Ipcache: Hostname to IP-Number mapping FQDNCache : IP-Number to Hostname mapping Cache Digest ( 2.x ) a summary of the contents of an Internet Object Caching Server an indication of whether or not particular URLs are in the cache X-Forwarded-For X-Forwarded-For: 50, unknown, 0,34,Squid.conf 中, 需要定義的參數 - “.tw” 上的實例,大多數的參數使用內定值 (default ) 底下就列出需要重新定義者 Cache_peer .tw sibling 3128 3130 no-netdb-exchange cache_mem 128M cache_swap_low 93 cache_swap_high 95 cache_mem_low 90 cache_mem_high 95 maximum_object_size 16384 KB,35,Squid.conf (cont.),ipcache_size 20480 ( hostname IP addr. ) ipcache_low 90 ipcache_high 95 fqdnsize 20480 ( IP addr - FQDN ) cache_dir (可以再加) cache_dir /home/squid/cache 100 16 256 cache_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 directory 編輯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 /16 no_cache deny Local 範例 2( domain name) acl Local_D dstdomain edu.tw no_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, icp_access allow/deny And/Or Logics All 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 Manager acl manager proto cache_object acl localhost src /55 acl Proxy src .tw .tw .tw acl purge method purge acl FTP proto FTP acl all src /,42,squid.conf (cont.) - access control 2,acl twdn dstdomain tw acl TANet src /16 .tw acl HCdn srcdomain .tw .tw .tw .tw .tw .tw .tw .tw .tw .tw .tw .tw .tw .tw .tw .tw,43,squid.conf (cont.) - access control (3),Http_access http_access allow manager Proxy http_access deny manager http_access deny all icp_access icp_access allow TANet . icp_access deny all,44,ACL ban list ( 管制),範例 1 ( 找 keyword, 用 regular expression) acl Cooking1 url_regex cooking acl Recipe1 url_regex recipe http_access deny Cooking1 http_access deny Recipe1 http_access allow all 範例 2 ( 用 domain name) acl Cooking2 dstdomain http_access deny Cooking2 http_access allow all,45,Syslog maintenance,/home/squid/etc/squid.conf logfile_rotate 3 Crontab entry for log-rotate 0 0 * * * /bin/kill -USR1 cat /home/squid/logs/squid.pid 每天執行一次, 以避免記錄檔越來越大, 無法處理,46,相關管理的工具程式,wget on proxy server homepage cache manager CGI ( cachemgr.cgi) 使用 Apache 為例 srm.conf, squid.conf, access.conf auto-proxy configuration support,47,設定 Cache Manager ( Apache) - 參考 FAQ 9.1 - 9.9,/home/squid/etc/srm.conf ScriptAlias /Squid/cgi-bin/ /home/squid/cgi-bin /home/squid/etc/access.conf order deny,allow deny form all allow from .tw,.tw ,48,設定 Cache Manager ( Apache) - 參考 FAQ 9.1 - 9.9 (cont.),/home/squid/etc/squid.conf acl manager proto cache_object acl localhost srt /55 acl all src / # http_access deny manager !localhost http_access allow all,49,Sample - access.log(1),912355210.560 10097 super.Dorm9.NCTU.edu.tw TCP_MISS/000 0 GET http:/adforce.i /? - DIRECT/ - 912355210.712 0 .tw UDP_MISS/000 76 ICP_QUERY http:/lygo. com/ly/p/bandn/thumbnails/9780553574753.gif - NONE/- - 912355210.712 0 .tw UDP_DENIED/000 82 ICP_QUERY http:/www. .hk/drama/image/home/top_link/newsong_d.gif - NONE/- - 912355210.712 0 .tw UDP_HIT/000 70 ICP_QUERY http:/www.penth /reading/images/c3.gif - NONE/- - 912355210.718 10171 .tw TCP_REFRESH_HIT/304 265 GET http:/www.be /ads/r03_howlow.gif - DIRECT/ - 912355211.482 358 bill.Dorm-GD1.NCTU.edu.tw TCP_HIT/200 1762 GET http:/www.j /jconsole/index.html - NONE/- text/html 912355211.482 358 hilbert.Dorm-GD1.NCTU.edu.tw TCP_IMS_HIT/304 225 GET http:/ //images/ad_info.gif - NONE/- image/gif,50,Sample -cache.log,1998/11/30 06:10:34| Starting Squid Cache version 2.1.PATCH1 for i386-unknown-freebsd2.2.7. 1998/11/30 06:10:34| Process ID 18654 1998/11/30 06:10:34| With 1024 file descriptors available 1998/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 processes 1998/11/30 06:10:34| Unlinkd pipe opened on FD 29 1998/11/30 06:10:34| Swap maxSize 32768000 KB, estimated 1638400 objects 1998/11/30 06:10:34| Target number of buckets: 40960 1998/11/30 06:10:34| Using 65536 Store buckets, replacement runs every 1 second 1998/11/30 06:10:34| Max Mem size: 131072 KB 1998/11/30 06:10:34| Max Swap size: 32768000 KB 1998/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 3128, 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 .tw/3128/3130 1998/11/30 06:10:35| Configuring Sibling .tw/3128/3130 1998/11/30 06:10:35| Configuring Sibling .tw/3128/3130 1998/11/30 06:10:35| Configuring Sibling .tw/3128/3130 1998/11/30 06:10:35| Configuring Sibling .tw/3128/3130 1998/11/30 06:10:35| Configuring Sibling .tw/3128/3130 1998/11/30 06:10:35| Configuring Sibling .tw/3128/3130 1998/11/30 06:10:36| 65536 Entries read so far.,52,Sample -cache.log (3),1998/11/30 06:45:13| Detected DEAD Sibling: .tw/3128/3130 1998/11/30 06:45:13| Detected REVIVED Sibling: .tw/3128/3130 1998/11/30 06:47:07| clientIfRangeMatch: 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.0 Accept: application/cache-digest Accccept: text/html Via: 0.0 .tw:3128 (Squid/2.1.PATCH1) X-Forwarded-For: unknown Host: .tw:3128 Cache-Control: max-age=1209600 Connection: keep-alive,53,Sample -cache.log (4),1998/11/30 08:13:49| urlParse: URI has whitespace: /spec ial/modx/news.gif?p_uniqid=1cKL7P4NYBCC9vptmA; s_uniqid=2Em4/MoNZkfAd4vndA 1998/11/30 08:14:01| urlParse: URI has whitespace: /spec ial/modx/news.gif?p_uniqid=1cKL7P4NYBCC9vptmA; s_uniqid=2Em4/MoNZkfAd4vndA 1998/11/30 08:14:10| clientSendMoreData: Deferring /Sma rtBanner/nph-graphic/14345.2 1998/11/30 08:14:10| clientKeepaliveNextRequest: FD 107 Sending next 1998/11/30 08:14:14| urlParse: URI has whitespace: /spec ial/modx/news.gif?p_uniqid=1cKL7P4NYBCC9vptmA; s_uniqid=2Em4/MoNZkfAd4vndA 1998/11/30 08:19:52| urlParse: URI has whitespace: /regi on/tw/graphics/tw_wfx_box_sm.jpg WIDTH= 1998/11/30 08:19:53| urlParse: URI has whitespace: /regi on/tw/graphics/tw_pca_box_sm.jpg WIDTH= 1998/11/30 08:23:28| Detected DEAD Sibling: .tw/3128/3130 1998/11/30 08:23:30| Detected REVIVED Sibling: .tw/3128/3130,54,附錄,Transparent Proxy 的設定 HTTP Accelerator 設定範例 .tw 如何使用交通大學 Proxy 服務 P.tw 使用量分佈統計 Cache Manager 的 Sample,55,Transparent Proxy (Squid 設定),讓 transparent proxy 運作的三道程序 將 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 的範例,範例 1 http_port 80 httpd_accel_host localhost httpd_accel_port 81 httpd_accel_with_proxy on 這一行的作用, 同時當 proxy, accelerator 範例 2: http_port 80 httpd_accel_host httpd_accel_port 80,57,如何使用交通大學 Proxy 服務 - .tw,Proxy 相關資訊 使用須知 一般使用者設定方法 ( user 端配合設定 ) 其它區網中心與上游的 Proxy (acl 與 cache 設定) 新竹地區各單位 Proxy (acl 與 cache 設定),58,選擇適合的 Auto Proxy Configuration,由於網路架構的不同,以及為了 reliability 的考量,交通大學校內與校外單位所使用的設定檔並不相同,我們同時提供數份相同的 Auto Proxy 設定檔,請選擇正確的設定檔。 外校單位(清華、中央、工研院等) .tw/proxy.pac .tw/proxy.pac .tw/proxy.pac 交通大學校內 .tw/nctu.pac .tw/nctu.pac .tw/nctu.pac,59,如何設定 Auto Proxy Configuration,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 來分別指定 parent(上一層) or sibling(同一層) 的結點 這裏以 .tw 給新竹區網下其他單位 cache_peer .tw parent 3128 3130 no-query no-netdb-exchange cache_peer .tw parent 3128 3130 no-query no-netdb-exchange cache_peer .tw parent 3128 3130 no-query no-netdb-exchange 這裏以 .tw 給骨幹上的其他 Proxy Servers (163.28.), 設定為例 ( e.g. NCU, NTU, NCKU, etc.) cache_peer .tw sibling 3128 3130 no-netdb-exchange cache_peer .tw sibling 3128 3130 no-netdb-exchange cache_peer .tw sibling 3128 3130 no-netdb-exchange,61,使用交通大學所提供的 Proxy Server 時,您可能會遇到的疑問。,為什麼會遇到 Access Denied 的錯誤訊息? 請確定您是 TANet 新竹區使用者, 包括交通大學, 清華大學, 高速電腦中心, 中華大學, 新竹師院以及其他連接於新竹區網中心的單位 請確定您的 IP 之 DNS 正查與反查設定正確 請設定 Auto Proxy Configuration 請將 URL 中的 IP 部分改為 FQDN,(ex: - .tw) 由於 IP 容易造成 auto proxy config 誤判,所以請避免使用 IP 形式之 URL 為什麼不能存取 NCTUCCCA.edu.tw? 新竹地區使用者,請就近利用 NCTUCCCA.NCTU.edu.tw,62,Proxy Server 統計,NCTU Proxy Servers 使用量排名統計 proxy, proxy2, proxy3 NCTU Proxy Servers 使用量統計分析 proxy, proxy2, proxy3,63,Squid Statistics for .tw:3128 - .tw/logs/19981127.html,1.Summary of Request Method Usage 2.Summary of Protocol Usage 3.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 0.0 - - - 69912 1.7 71.7 0.0 40.3 0.2 0.0 0.8 1.4 65662 1.6 0.0 - 0.0 0.0 - - - 40367 1.0 12.0 80.5 30.5 0.1 87.3 6.5 123.2 34800 0.8 0.0 - 0.0 0.0 - - - 31355 0.7 84.5 48.0 36.4 0.2 41.6 1.4 27.0 30748 0.7 47.5 60.6 1054.8 4.6 67.6 73.9 49.8 24728 0.6 80.9 88.3 115.4 0.5 87.1 5.9 276.8 22275 0.5 0.0 - 0.0 0.0 - - - 20678 0.5 81.8 85.1 40.1 0.2 85.8 2.4 92.9,65,Top 10 sites by MB (1998/11/26) - reqs %all %xfers %hit MB %all %hit kB/xf kB/s, 30748 0.7 47.5 60.6 1054.8 4.6 67.6 73.9 49.8 45 16961 0.4 35.3 56.1 945.1 4.1 52.5 161.5 79.7 447 0.0 26.2 38.5 594.6 2.6 40.5 5204.4 28.0 www.5senses.c

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论