系统环境: RedHat EL55
Oracle 11g RAC 集群中引入了SCAN(Single Client Access Name)的概念,也就是指集群的单客户端访问名称。SCAN 这个特性为客户端提供了单一的主机名,用于访问集群中运行的 Oracle 数据库。如果您在集群中添加或***节点,使用 SCAN 的客户端无需更改自己的 TNS 配置。无论集群包含哪些节点,SCAN 资源及其关联的 IP 地址提供了一个稳定的名称供客户端进行连接使用。在Oracle 11g grid 安装时即要求为该特性配置DNS解析方式或GNS解析方式。
以下案例是在Linux环境下配置DNS服务器:
步骤:
1、 安装必要软件
[root@Dns_master/]# yum install bind bind-chroot caching-nameserver –y
….
Installed:
bind.i38630:9.3.6-4.P1.el5_4.2
bind-chroot.i386 30:9.3.6-4.P1.el5_4.2 (可以不安装)
caching-nameserver.i386 30:9.3.6-4.P1.el5_4.2
2、 配置
1)修改主配置文件
[root@Dns_master /]# cd/var/named/chroot/
[root@Dns_masterchroot]# pwd
/var/named/chroot
[root@Dns_masterchroot]# ls
dev etc var
[root@Dns_masterchroot]# cd etc/
[root@Dns_masteretc]# ls
localtime named.caching-nameserver.conf named.rfc1912.zones rndc.key
[root@Dns_master etc]# vi named.caching-nameserver.conf
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";
// Those options should be used carefully because they disable port
// randomization
// query-source port 53;
// query-source-v6 port 53;
allow-query { any; }; #查询地址
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view any_resolver {
match-clients { any; }; #客户端
match-destinations { any; }; #查询目的地址
recursion yes;
include "/etc/named.rfc1912.zones";
};
2)声明一个域
[root@Dns_masteretc]# pwd
/var/named/chroot/etc
[root@Dns_masteretc]# ls
localtime named.caching-nameserver.conf named.rfc1912.zones rndc.key
[root@Dns_master etc]# vi named.rfc1912.zones
zone "." IN {
type hint;
file "named.ca";
};
zone "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};
zone "cuug.net" IN {
type master;
file "cuug.zone";
notify no;
};
zone "8.168.192.in-addr.arpa" IN {
type slave;
file "192.zone";
notify no;
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
3)建立对应的正解和反向区域文件
[root@Dns_masteretc]# cd ../var/named/
[root@Dns_masternamed]# pwd
/var/named/chroot/var/named
[root@Dns_masternamed]# ls
data localhost.zone named.ca named.local slaves
localdomain.zone named.broadcast named.ip6.local named.zero
正向解析文件:
[root@Dns_master named]# cat cuug.zone
$TTL 86400
@ IN SOA dns.cuug.net. root.mail.cuug.net. (
1997022700 ; Serial
28800 ; Refresh - 3 hours
14400 ; Retry - 1 hour
3600000 ; Expire - 1 week
86400) ; Minimum - 1 day
IN NS dns.cuug.net.
IN MX 10 mail.cuug.net.
web IN A 192.168.8.31
dns IN A 192.168.8.240
mail IN A 192.168.8.101
ftp IN A 192.168.8.103
www IN CNAME web
反向解析文件:
[root@Dns_master named]# cat 192.zone
$TTL 86400
@ IN SOA dns.cuug.net. root.mail.cuug.net. (
1997022700 ; Serial
28800 ; Refresh - 3 hours
14400 ; Retry - 1 hour
3600000 ; Expire - 1 week
86400) ; Minimum - 1 day
IN NS dns.cuug.net.
IN MX 10 mail.cuug.net.
240 IN PTR dns.cuug.net.
31 IN PTR web.cuug.net.
101 IN PTR mail.cuug.net.
103 IN PTR ftp.cuug.net.
本机反向解析库文件:
net.127
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh - 3 hours
14400 ; Retry - 1 hour
3600000 ; Expire - 1 week
86400) ; Minimum - 1 day
IN NS localhost.
1 IN PTR localhost.
本机正向解析库文件:
net.local
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh - 3 hours
14400 ; Retry - 1 hour
3600000 ; Expire - 1 week
86400) ; Minimum - 1 day
IN NS localhost.
localhost IN A 127.0.0.1
4)修改区域文件的权限
[root@Dns_master named]# chown :named cuug.zone
[root@Dns_master named]# chown :named 192.zone
5)检查配置文件语法
[root@Dns_master named]#named-checkconf ###检测配置文件是否有语法错误
[root@Dns_master named]#named-checkzone cuug.net cuug.zone
zonelinuxidc/IN: loaded serial 42
OK
3、重新启动named服务
[root@Dns_master named]# service named restart
停止 named: [确定]
启动 named: [确定]
4、测试
首先添加DNS服务器记录
编辑nsswitch.conf 添加dns解析
[root@Dns_master named]# vi /etc/nsswitch.conf
在hosts: dns files 增加DNS解析
[root@Dns_masternamed]# cat /etc/resolv.conf
nameserver192.168.8.240
[root@Dns_masternamed]# host www.cuug.net
www.cuug.net has address 192.168.1.100
[root@Dns_masternamed]# ping www.cuug.net
www.cuug.net (192.168.8.240) 56(84) bytes of data.
64bytes from Dns_master (192.168.8.240): icmp_seq=1 ttl=64 time=0.017 ms
64bytes from Dns_master (192.168.8.240): icmp_seq=2 ttl=64 time=0.013 ms
@至此,DNS服务器配置成功!