CDN简介
CDN ( Content Delivery Network)
内容分发网络 : 所有客户端可以获得距离自己最近的资源
dns分离解析 功能
根据客户端来源地址的不同,把相同的主机名解析到不同的ip地址
202.16.0.20
dns
http://www.163.com
pc1 192.168.1.1 3.3.3.9
pc2 192.168.1.2 192.168.1.100
dns 202.106.0.20(分离解析)
http://www.tarena.com
www.tarena.com. IN CNAME squid1.lxcdn.net
lxcdn.net DNS
ip地址 dns服务器
网段 dns 家乡上网的dns
联通 202.16.0.20 黑龙江
移动
电信
铁通
项目 : CDN缓存加速
模版机配置:
配置好yum源(安装开发工具软件包组 gcc gcc-c++)
关闭iptables 禁用selinux
网卡模式仅主机 运行级别3 内存300 硬盘10G
-----------------------------------------------------------------
http://www.tarena.com
172.16.0.10 网站服务器10(Nginx)
172.16.0.20 网站服务器20 ( Nginx)
172.16.0.100 北京地区cdn缓存服务器(squid)
172.16.0.200 广州地区cdn缓存服务器(squid)
172.16.0.11 北京地区DNS服务器
172.16.0.22 广州地区DNS服务器
172.16.0.111 模拟权威DNS服务器 (管理所有区域)
172.16.0.222 CDN服务商的DNS服务器
172.16.0.1 北京地区客户端
172.16.0.2 广州地区客户端
-------------------------------------------------------------
1 配置2台nginx网站服务器
yum -y install pcre-devel openssl-devel
useradd -s /sbin/nologin -M nginx
10 ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module
11 make
12 make install
13 echo "172.16.0.10" > /usr/local/nginx/html/test.html
14 /usr/local/nginx/sbin/nginx -t
15 /usr/local/nginx/sbin/nginx
16 elinks --dump http://localhost/test.html
2 配置2台cdn节点服务器(squid)
yum -y install squid
vim /etc/squid/squid.conf
#http_access deny all
http_access allow all
http_port 80 vhost
cache_peer 172.16.0.10 parent 80 0 originserver
cache_peer 172.16.0.20 parent 80 0 originserver
cache_dir ufs /var/spool/squid 100 16 256
:wq
service squid start ; chkconfig squid on
3 配置北京地区的dns服务器(172.16.0.11)
yum -y install bind bind-chroot
mv /etc/named.conf /etc/named.conf.bak
vim /etc/named.conf
options {
forwarders { 172.16.0.111; };
};
service named start ;chkconfig named on
4 配置广州地区的dns服务器(172.16.0.22)
yum -y install bind bind-chroot
mv /etc/named.conf /etc/named.conf.bak
vim /etc/named.conf
options {
forwarders { 172.16.0.111; };
};
service named start ;chkconfig named on
5 配置权威服务器 (172.16.0.111)
yum -y install bind bind-chroot
编辑主配置文件 /etc/named.conf 定义管理区域
mv /etc/named.conf /etc/named.conf.bak
vim /etc/named.conf
options {
directory "/var/named/"; //区域数据文件存放路径
recursion no;
};
zone "tarena.com" {
type master;
file "tarena.com.zone";
};
zone "xinnet.com" {
type master;
file "xinnet.com.zone";
};
zone "net" {
type master;
file "net.zone";
};
:wq
编辑区域文件
vim /var/named/xinnet.com.zone
$TTL 3600
@ IN SOA @ root (
2015120600
28800
14400
17200
86400
)
@ IN NS dns111.xinnet.com.
dns111.xinnet.com. IN A 172.16.0.111;
:wq
vim /var/named/tarena.com.zone
$TTL 3600
@ IN SOA @ root (
2015120600
28800
14400
17200
86400
)
@ IN NS dns111.xinnet.com.
www IN CNAME www.tarena.com.lxcdn.net.
:wq
vim /var/named/net.zone
$TTL 3600
@ IN SOA @ root (
2015120600
28800
14400
17200
86400
)
@ IN NS dns111.xinnet.com.
lxcdn.net. IN NS dns222.lxcdn.net.
dns222.lxcdn.net. IN A 172.16.0.222
:wq
service named start
----------------------------------------------------------------
6 配置CDN服务商的DNS服务器 (172.16.0.222)
yum -y install bind bind-chroot
mv /etc/named.conf /etc/named.conf.bak
vim /etc/named.conf
options {
directory "/var/named";
};
acl "bjclient" { 172.16.0.1; 172.16.0.11; }; //定义ACL指向测试客户端主机pc01 dns指向11
acl "gzclient" { 172.16.0.2; 172.16.0.22; }; //定义ACL指向测试客户端主机pc02 dns指向22
view "bjzone" { ////定义视图zone1
match-clients { bjclient; }; //匹配条件为指定pc01的ACL
zone "tarena.com.lxcdn.net" {
type master;
file "tarena.com.lxcdn.net.bjzone";
};
zone "lxcdn.net" {
type master;
file "lxcdn.net.zone";
};
};
view "gzzone" {
match-clients { gzclient; any; };
zone "tarena.com.lxcdn.net" {
type master;
file "tarena.com.lxcdn.net.gzzone";
};
zone "lxcdn.net" {
type master;
file "lxcdn.net.zone";
};
};
:wq
vim /var/named/tarena.com.lxcdn.net.bjzone
$TTL 3600
@ IN SOA @ root (
2015120600
28800
14400
17200
86400
)
@ IN NS dns222.lxcdn.net.
dns222 IN A 172.16.0.222
www IN A 172.16.0.100
:wq
vim /var/named/tarena.com.lxcdn.net.gzzone
$TTL 3600
@ IN SOA @ root (
2015120600
28800
14400
17200
86400
)
@ IN NS dns222.lxcdn.net.
dns222 IN A 172.16.0.222
www IN A 172.16.0.200
:wq
vim /var/named/lxcdn.net.zone
$TTL 3600
@ IN SOA @ root (
2015120600
28800
14400
17200
86400
)
@ IN NS dns222.lxcdn.net.
IN A 172.16.0.222
dns222 IN A 172.16.0.222
squid100 IN A 172.16.0.100
squid200 IN A 172.16.0.200
:wq
service named start;chkconfig named on
---------------------------------------------------------------
客户端测试 172.16.0.1/2
vim /etc/resolv.conf
nameserver 自己所在地区的DNS服务器的ip地址
:wq
host www.tarena.com
------------------------------------------------------------
172.16.0.111
在 新网 注册的主机名 www.tarena.com
蓝讯公司 提供2台服务器做缓存服务器
172.16.0.100
172.16.0.200
对应主机名 www.tarena.com.lxcdn.net
蓝讯公司dns服务器 172.16.0.222 提供lxcdn.net 区域内主机名解析服务。
互联网的客户端 访问 http://www.tarena.com
原文地址:http://liangzai818.blog.51cto.com/10003446/1767695