从oracle 11gR2开始,引入SCAN IP。在客户端的tnsnames.ora配置文件中,只需要配置SCANIP的配置信息即可,客户端通过SCAN IP、SCAN IP Listener来访问数据库。使用scan IP的好处是,当后台RAC数据库添加、删除节点时,客户端配置信息无需修改。可以通过配置DNS服务器或GNS来配置SCAN。
[root@dg named]# service iptables stop
[root@dg named]# chkconfig iptables off
[root@dg named]# vi /etc/selinux/config
SELINUX=enforcing
[root@dg ~]# hostname
dg.localdomain
[root@dg ~]# uname -r
2.6.32-279.el6.x86_64
[root@dg ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release6.3 (Santiago)
[root@dg ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=dg.localdomain
GATEWAY=192.168.100.254
[root@dg ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search localdomain
# No nameservers found; try putting DNSservers into your
# ifcfg files in /etc/sysconfig/network-scriptslike so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com
[root@dg named]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.100.70 dg.localdomain dg
[root@dg ~]# ifconfig
eth0 Link encap:Ethernet HWaddr00:0C:29:90:C0:C8
inet addr:192.168.100.70 Bcast:192.168.100.255 Mask:255.255.255.0
[root@node1~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.100.66 node1.localdomain node1
192.168.100.68 node1-vip.localdomain node1-vip
10.10.10.2 node1-priv.localdomain node1-priv
192.168.100.67 node2.localdomain node2
192.168.100.69 node2-vip.localdomain node2-vip
10.10.10.3 node2-priv.localdomain node2-priv
192.168.100.71 scan-cluster.localdomain scan-cluster
[root@dg ~]# yum install bind-chroot
[root@dg ~]#yum install bind-utils
[root@dg ~]# vi/etc/named.conf
//
// named.conf
//
// Provided by Red Hat bind package toconfigure the ISC BIND named(8) DNS
// server as a caching only nameserver (asa localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ forexample 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; };
allow-query-cache { any; };
recursion no;
// dnssec-enable yes;
// dnssec-validation yes;
// dnssec-lookasideauto;
// /* Path to ISC DLVkey */
// 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";
named.rfc1912.zones,是named.conf的辅助区域配置文件。意思是除了根域外,其他所有的区域配置建议在named.rfc1912.zones文件中配置,主要是为了方便管理,不轻易破坏主配置文件named.conf。
在辅助区域配置文件named.rfc1912.zones中创建正向反向区域。
[root@dg ~]# vi /etc/named.rfc1912.zones
添加:
zone "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};
zone "100.168.192.in-addr.arpa"IN {
type master;
file "100.168.192.in-addr.arpa";
allow-update { none; };
};
正向区域:
zone 后面跟域名localdomain
type 为区域的类型,master为主DNS区域,如果是salve 则为辅助DNS区域。
file 后面跟对应区域数据库的配置文件,一般格式为 域名.zone,可以有其他写法。
allow-update参数为none 不允许客户端动态更新
反向区域:
zone 后面跟IP地址反写,除去最后一位。
file后面跟对应的反向区域数据库配置文件,一般格式为“ip.arpa”ip不包含最后一位。
通过模版创建对应的正向反向区域数据库文件。
数据库配置文件在/var/named/下。注意这里的配置文件名称和以上区域配置文件中设置的名称一样。请使用cp -p命令将named.localhost文件和权限一起复制.
[root@dg etc]# cd /var/named/
[root@dg named]# ll
total 32
drwxr-x---. 6 root named 4096Apr 2 15:50 chroot
drwxrwx---. 2 named named 4096 Jun 5 2012 data
drwxrwx---. 2 named named 4096 Jun 5 2012 dynamic
-rw-r-----. 1 root named 1892Feb 18 2008 named.ca
-rw-r-----. 1 root named 152 Dec 15 2009 named.empty
-rw-r-----. 1 root named 152 Jun 21 2007named.localhost
-rw-r-----. 1 root named 168 Dec 15 2009 named.loopback
drwxrwx---. 2 namednamed 4096 Jun 5 2012slaves
[root@dg named]# cp-p named.localhost localdomain.zone
[root@dg named]# cp-p named.localhost 100.168.192.in-addr.arpa
[root@dg named]# ll
total 40
-rw-r-----. 1 root named 208 Apr 3 10:30 100.168.192.in-addr.arpa
drwxr-x---. 6 root named 4096 Apr 2 15:50 chroot
drwxrwx---. 2 named named 4096 Apr 7 10:06 data
drwxrwx---. 2 named named 4096 Apr 9 09:00 dynamic
-rw-r-----. 1 root named 183 Apr 3 10:16 localdomain.zone
-rw-r-----. 1 root named 1892 Feb 18 2008 named.ca
-rw-r-----. 1 root named 152 Dec 15 2009 named.empty
-rw-r-----. 1 root named 152 Jun 21 2007named.localhost
-rw-r-----. 1 root named 168 Dec 15 2009 named.loopback
drwxrwx---. 2 named named 4096 Jun 5 2012slaves
修改正向区域数据库配置文件localdomain.zone,添加以下内容
scan-cluster A 192.168.100.71
修改反向区域数据库配置文件100.168.192.in-addr.arpa,添加以下内容
71 PTR scan-cluster.localdomain.
设置完成之后,通过自带的脚本启动named服务,第一次启动,会生成一个远程管理的key文件,会比较慢。
[root@dg named]# /etc/init.d/namedstart
Generating /etc/rndc.key:[ OK ]
Starting named: [ OK ]
可以通过 netstat -anpl | grep :53查看named服务的端口监听状态
[root@dg named]# netstat -anpl |grep :53
tcp 0 0 192.168.100.70:53 0.0.0.0:* LISTEN 1520/named
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1520/named
tcp 0 0 ::1:53 :::* LISTEN 1520/named
udp 0 0 0.0.0.0:5353 0.0.0.0:* 1645/avahi-daemon
udp 0 0192.168.100.70:53 0.0.0.0:* 1520/named
udp 0 0 127.0.0.1:53 0.0.0.0:* 1520/named
udp 0 0 ::1:53 :::* 1520/named
分别在RAC节点的/etc/resolv.conf配置文件中添加以下配置信息:
[root@node1 ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search localdomain
nameserver 192.168.100.70
# No nameservers found; try putting DNSservers into your
# ifcfg files in/etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com
最后,测试SCAN IP解析是否成功
[root@node1 ~]# nslookup 192.168.100.71
Server: 192.168.100.70
Address: 192.168.100.70#53
71.100.168.192.in-addr.arpa name = scan-cluster.localdomain.
最后在DNS服务器上设置named开机自启动
[root@dg named]# chkconfig named on
[root@dg named]# chkconfig --list named
named 0:off 1:off 2:on 3:on 4:on 5:on 6:off