CDN
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CDN相关的知识,希望对你有一定的参考价值。
这里写了基本的CDN工作原理
还有这里
*(这里貌似是一本书的部分章节,有兴趣的可以了解下)
[[email protected] ~]# vim /etc/nsswitch.conf (这里面定义了解析先找那个文件)
[[email protected] ~]# vim /etc/resolv.conf (这里自定义DNS服务器,最多指定三台)
试验环境
192.168.10.14 dns-view
192.168.10.15 dxview
192.168.10.13 ltview
开始试验
dns-view 这里更改
[[email protected] named]# vim /etc/named.conf
view "dxview" {
match-clients { 192.168.10.15; };
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones"; (这个引导文件路劲别忘记加上)
zone "abc.com" IN {
type master;
file "dx.abc.com.zone";
};
};
view "ltview" {
match-clients { 192.168.10.13; }; (多个ip用分号隔开)
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
zone "abc.com" IN {
type master;
file "lt.abc.com.zone";
};
};
view "qitaview" {
match-clients { any; };
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
zone "abc.com" IN {
type master;
file "lt.abc.com.zone";
};
};
[[email protected] named]# cd /var/named/ (创建对应的数据文件)
[[email protected] named]# ls
chroot dx.abc.com.zone lt.abc.com.zone named.empty named.loopback
data dynamic named.ca named.localhost slaves
[[email protected] named]# diff dx.abc.com.zone lt.abc.com.zone
10c10
< www A 1.1.1.1
---
> www A 2.2.2.2
[[email protected] named]# cat dx.abc.com.zone(内容)
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 192.168.10.14
www A 1.1.1.1
客户端别忘记指定DNS----192.168.10.14(当然也可以使用server指定)
但是呢有个问题,那么多ip不可能都写进配置字段吧?解决方法
ACL参数控制
acl "qita" { any; }; acl+名字+ip或网段
view "qitaview" {
match-clients { qita; }; (这里直接写acl的名字即可)
好像轻松了一些,但感觉还是很乱?解决方法
#acl "qita" { any; };
include "/etc/qitaip"; (添加一个引导文件,在文件里面写acl)
view "qitaview" {
match-clients { qita; };
*(注意include的/etc/qitaip,是放在真实路径下的,ps -ef可以看出来,这里就是/var/named/chroot/etc/)
dns-view主从
类似于dns的主从
view的数量决定你从机网卡的数量
现在我选择15作为从机,就只做一个view的同步,我选取qitaip做实验
小插曲(灰常有意思,同样的配置,同样的系统,同样版本的软件。有一台机器怎么调试都不好使。。。捣鼓了一大顿,先把实验贴出来吧)
如果大家做的途中出现什么问题请参考下这里是个思路,大部分思路都是如此。耐心
*(哪位大神知道此问题的解决方法,欢迎评论给下连接---slave文件死活同步不过来)
关闭防火墙和selinux
******************主机**********************
[[email protected] named]# vim /etc/named.conf
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options { //服务器的全局配置选项及一些默认设置
listen-on port 53 { any; }; //监听端口,也可写为 { 127.0.0.1; 192.168.10.20; }
# listen-on-v6 port 53 { ::1; }; //对ip6支持
directory "/var/named"; //区域文件存储目录
dump-file "/var/named/data/cache_dump.db"; //dump cach的目录directory
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { any; }; //指定允许进行查询的主机,当然是要所有的电脑都可以查啦
recursion yes; //设置进行递归查询
allow-transfer { 192.168.10.21; }; //指定允许接受区域传送请求的主机,说明白一点就是辅dns的ip
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
};
logging { //指定服务器日志记录的内容和日志信息来源
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
include "/etc/qitaip";
view "qitaview" {
match-clients { "qita"; 192.168.10.21; };
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones"; //包含文件,这里也就是载入/etc/named.rfc1912.zones
zone "abc.com" IN {
type master;
file "lt.abc.com.zone";
notify yes;
also-notify { 192.168.10.21; };
allow-update { none; };
allow-transfer { 192.168.10.21; };
};
};
#include "/etc/named.root.key";
***********************从机************************
[[email protected] tmp]# vim /etc/named.conf
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {
listen-on port 53 { any; };
# listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { any; };
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
include "/etc/named.rfc1912.zones";
#include "/etc/named.root.key";
[[email protected] tmp]# vim /etc/named.rfc1912.zones
// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
// and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt
// (c)2007 R W Franks
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
#zone "localhost.localdomain" IN {
# type master;
# file "named.localhost";
# allow-update { none; };
#};
include "/etc/qitaip"
view "qitaview" {
matchclients { "qita"; 192.168.10.21; };
transfer-source 192.168.10.21;
recursion yes;
zone "abc.com" IN {
type slave;
masters { 192.168.10.20; };
file "slaves/lt.abc.com.zone";
#allow-update { none;};
masters { 192.168.10.20; };
allow-update { none;};
};
#zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
# type master;
# file "named.loopback";
# allow-update { none; };
#};
# allow-update { none; };
#zone "0.in-addr.arpa" IN {
# type master;
# file "named.empty";
# allow-update { none; };
#};
修改完配置文件先重启主机再重启从机!!!!!!!
遇到的问题:
之前升级过yum源码,前后软件的依赖关系,版本注意下
http://ju.outofmemory.cn/entry/245070
以上是关于CDN的主要内容,如果未能解决你的问题,请参考以下文章