- 論壇徽章:
- 26
|
本帖最后由 cryboy2001 于 2014-09-29 16:37 編輯
用opentstack做cdn實(shí)驗(yàn)
架構(gòu)
image001.png (39.95 KB, 下載次數(shù): 255)
下載附件
2014-09-29 16:25 上傳
主機(jī)名與ip
image003.jpg (56.84 KB, 下載次數(shù): 253)
下載附件
2014-09-29 16:26 上傳
一、源主機(jī)的安裝
[root@www ~]# #yum -y install httpd
產(chǎn)生一個(gè)測(cè)試頁面
[root@www ~]# cat /var/www/html/index.html
<html>
<body>
This is a test page!
</body>
</html>
[root@www ~]#
打開防火墻
systemctl httpd.service start
systemctl start httpd.service
image008.jpg (29.27 KB, 下載次數(shù): 217)
下載附件
2014-09-29 16:26 上傳
二、dns主機(jī)安裝
安裝bind
#yum -y install make gcc cc gcc+ gcc-c++ openssl openssl-devel perl
# wget ftp://ftp.isc.org/isc/bind9/9.10.1/bind-9.10.1.tar.gz
#tar zxvf bind-9.10.1.tar.gz
# cd bind-9.10.1
# ./configure --prefix=/usr/local/bind
#make && make install
制作配置文件
#/usr/local/bind/sbin/rndc-confgen >rndc.conf
#cat rndc.conf >rndc.key
#tail -n10 rndc.conf |head -n9 |sed -e s/#\ //g >named.conf
[root@dns bind]# cat etc/named.conf
key "rndc-key" {
algorithm hmac-md5;
secret "mHcJqq5mIIkvwZMwr5I5hg==";
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { "rndc-key"; };
};
logging {
channel query_log {
file "query.log" versions 3 size 20m;
severity info;
print-time yes;
print-category yes;
};
category queries {
query_log;
};
};
options {
directory "/usr/local/bind/var";
pid-file "named.pid";
listen-on port 53 {any;};
allow-query {any;};
};
view "squid1" {
match-clients { 10.0.10.0/24; 10.0.1.0/24; };
recursion yes;
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "localhost.arpa";
};
zone "test.com" IN {
type master;
file "test1.com.zone";
allow-update {none;};
};
};
view "squid2" {
match-clients { 10.0.20.0/24;};
recursion yes;
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "localhost.arpa";
};
zone "test.com" IN {
type master;
file "test2.com.zone";
allow-update {none;};
};
};
view "other" {
match-clients { 0.0.0.0/0;};
recursion yes;
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "localhost.arpa";
};
zone "test.com" IN {
type master;
file "test.com.zone";
allow-update {none;};
};
};
相應(yīng)目錄下的zonefile
[root@dns bind]# ls var/test*
var/test1.com.zone var/test2.com.zone var/test.com.zone
[root@dns bind]# cat var/test*
$TTL 86400
@ IN SOA dns.test.com. hostmaster.test.com. (
20140930 ; serial
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
@ IN NS dns.test.com.
dns IN A 10.0.1.18
www IN A 10.0.10.102
$TTL 86400
@ IN SOA dns.test.com. hostmaster.test.com. (
20140930 ; serial
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
@ IN NS dns.test.com.
dns IN A 10.0.1.18
www IN A 10.0.20.101
$TTL 86400
@ IN SOA dns.test.com. hostmaster.test.com. (
20140930 ; serial
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
@ IN NS dns.test.com.
dns IN A 10.0.1.18
www IN A 10.0.1.19
squid1 IN A 10.0.10.102
squid2 IN A 10.0.20.101
設(shè)客戶端dns
image004.jpg (10.14 KB, 下載次數(shù): 229)
下載附件
2014-09-29 16:26 上傳
xp1上的dns查詢
image005.jpg (48.1 KB, 下載次數(shù): 238)
下載附件
2014-09-29 16:26 上傳
xp2上的查詢
image006.jpg (42.81 KB, 下載次數(shù): 234)
下載附件
2014-09-29 16:26 上傳
其它電腦上的查詢
image007.jpg (48.01 KB, 下載次數(shù): 229)
下載附件
2014-09-29 16:26 上傳
通過以上的查詢,確認(rèn)dns view已成功配好了。
三、代理緩存安裝
看前面的squid設(shè)置內(nèi)容
#cat squid.conf
visible_hostname squid2.test.com
pid_filename /var/run/squid.pid
cache_effective_user squid
cache_effective_group squid
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access allow localnet
http_access allow localhost
cache_dir ufs /usr/local/squid/var/cache/squid 100 16 256
coredump_dir /usr/local/squid/var/cache/squid
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
http_port 80 accel vhost vport
cache_peer 10.0.1.19 parent 80 0
http_access allow all
兩臺(tái)一樣,除主機(jī)名外其它都是一樣的
還有要打開80端口防火墻
四、客戶機(jī)上試用
在客戶機(jī)上的動(dòng)作與日志
image008.jpg (29.27 KB, 下載次數(shù): 230)
下載附件
2014-09-29 16:37 上傳
找一個(gè)不存在的網(wǎng)頁
image009.jpg (31.49 KB, 下載次數(shù): 241)
下載附件
2014-09-29 16:26 上傳
squid上的相關(guān)日志非常明顯
image010.jpg (25.54 KB, 下載次數(shù): 2493)
下載附件
2014-09-29 16:26 上傳
加一臺(tái)客戶端,訪問的是另一臺(tái)squid
image011.jpg (28.14 KB, 下載次數(shù): 244)
下載附件
2014-09-29 16:26 上傳
不存在的網(wǎng)頁
image012.jpg (36.08 KB, 下載次數(shù): 236)
下載附件
2014-09-29 16:26 上傳
日志很清楚
image013.jpg (17.54 KB, 下載次數(shù): 242)
下載附件
2014-09-29 16:26 上傳
|
|