Oracle 11g RAC 集群中引入了SCAN(Single Client Access Name)的概念,也就是指集群的单客户端访问名称。SCAN 这个特性为客户端提供了单一的主机名,用于访问集群中运行的 Oracle 数据库。如果您在集群中添加或删除节点,使用 SCAN 的客户端无需更改自己的 TNS 配置。无论集群包含哪些节点,SCAN 资源及其关联的 IP 地址提供了一个稳定的名称供客户端进行连接使用。在Oracle 11g grid 安装时即要求为该特性配置DNS解析方式或GNS解析方式。本文描述了安装Oracle 11g grid时的DNS配置。
- 1、安装环境
- #配置DNS,可以使用单独的DNS服务器,也可以直接使用RAC的一个节点来提供DNS解析
- #直接使用某个节点时,容易出现该节点如果宕机将导致SCAN无法解析,客户端无法连接数据库
- #本文仅作演示,使用节点1的public ip用作dns,不考虑上面描述的情形以及DNS安全性等。
- [root@node1 ~]# cat /etc/issue
- Enterprise Linux Enterprise Linux Server release 5.5 (Carthage)
- Kernel \r on an \m
- 2、主机节点host信息
- [root@node1 ~]# more /etc/hosts
- # Do not remove the following line, or various programs
- # that require network functionality will fail.
- #127.0.0.1 localhost.localdomain localhost
- #::1 localhost6.localdomain6 localhost6
- 127.0.0.1 localhost.szdb.com localhost
- # Public eth0
- 192.168.7.71 node1.szdb.com node1 #该地址作为DNS服务器地址
- 192.168.7.72 node2.szdb.com node2
- #Private eth1
- 10.10.7.71 node1-priv.szdb.com node1-priv
- 10.10.7.72 node2-priv.szdb.com node2-priv
- #Virtual
- 192.168.7.81 node1-vip.szdb.com node1-vip
- 192.168.7.82 node2-vip.szdb.com node2-vip
- #scan
- 192.168.7.91 scan-cluster1.szdb.com scan-cluster1
- 3、配置dns需要用到的安装包
- [root@node1 dns_rpm]# ls -hltr
- total 1.1M
- -rw-r--r-- 1 root root 45K Dec 7 18:04 bind-chroot-9.3.6-4.P1.el5_4.2.i386.rpm
- -rw-r--r-- 1 root root 985K Dec 7 18:04 bind-9.3.6-4.P1.el5_4.2.i386.rpm
- -rw-r--r-- 1 root root 61K Dec 7 18:04 caching-nameserver-9.3.6-4.P1.el5_4.2.i386.rpm
- #下面安装rpm包
- [root@node1 dns_rpm]# rpm -Uvh bind-9.3.6-4.P1.el5_4.2.i386.rpm
- warning: bind-9.3.6-4.P1.el5_4.2.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
- Preparing... ########################################### [100%]
- 1:bind ########################################### [100%]
- [root@node1 dns_rpm]# rpm -Uvh bind-chroot-9.3.6-4.P1.el5_4.2.i386.rpm
- warning: bind-chroot-9.3.6-4.P1.el5_4.2.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
- Preparing... ########################################### [100%]
- 1:bind-chroot ########################################### [100%]
- [root@node1 dns_rpm]# rpm -Uvh caching-nameserver-9.3.6-4.P1.el5_4.2.i386.rpm
- warning: caching-nameserver-9.3.6-4.P1.el5_4.2.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
- Preparing... ########################################### [100%]
- 1:caching-nameserver ########################################### [100%]
- 4、配置DNS
- #关于DNS的配置,分为以下几个步骤
- #a.安装所需的rpm包
- #b.配置named.conf文件
- #c.配置zone文件,包括正向和反向zone文件
- #d.配置解析文件resolv.conf
- #e.启动dns服务
- [root@node1 ~]# cd /var/named/chroot/etc/
- #使用下面的方式复制两个新的副本并修改,参数-p表示连同权限及属主,属组一同复制。切记不可忽略参数-p
- [root@node1 etc]# cp -p named.caching-nameserver.conf named.conf
- [root@node1 etc]# cp -p named.rfc1912.zones named.zones
- #修改named.conf文件,将源文件中的所有localhost以及127.0.0.1修改成any,注意any;前后保留空格
- #该文件主要是配置dns监听那些端口以及ip地址并指明相应的名字解析zone文件名named.zones
- #下面是修改后的named.conf文件
- [root@node1 ~]# cat /var/named/chroot/etc/named.conf
- //
- // named.caching-nameserver.conf
- //
- // Provided by Red Hat caching-nameserver 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.
- //
- // DO NOT EDIT THIS FILE - use system-config-bind or an editor
- // to create named.conf - edits to this file will be lost on
- // caching-nameserver package upgrade.
- //
- 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; };
- allow-query-cache { any; };
- };
- logging {
- channel default_debug {
- file "data/named.run";
- severity dynamic;
- };
- };
- view localhost_resolver {
- match-clients { any; };
- match-destinations { any; };
- recursion yes;
- include "/etc/named.zones";
- };
- #修改named.zones文件,该文件用于指定zone的搜索范围,包括正向和反向。文件末尾最后的两个zone为新增加的
- #注意每一个zone的file用于指向真正的zone文件,后面要用到
- # Author : Robinson
- # Blog : http://blog.csdn.net/robinson_0612
- #下面是修改后的named.zones文件
- [root@node1 ~]# cat /var/named/chroot/etc/named.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
- //
- // See /usr/share/doc/bind*/sample/ for example named configuration files.
- //
- zone "." IN {
- type hint;
- file "named.ca";
- };
- zone "localdomain" IN {
- type master;
- file "localdomain.zone";
- allow-update { none; };
- };
- 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; };
- };
- zone "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.ip6.local";
- allow-update { none; };
- };
- zone "255.in-addr.arpa" IN {
- type master;
- file "named.broadcast";
- allow-update { none; };
- };
- zone "0.in-addr.arpa" IN {
- type master;
- file "named.zero";
- allow-update { none; };
- };
- #Add new zone added by Robinson
- #以下两个zone为新增的,包含正向和反向zone
- zone "szdb.com" IN {
- type master;
- file "node1.szdb.zero";
- allow-update { none; };
- };
- zone "7.168.192.in-addr.arpa" IN {
- type master;
- file "7.168.192.local";
- allow-update { none; };
- };
- #配置正向和反向搜索数据库解析文件
- [root@node1 etc]# pwd
- /var/named/chroot/etc
- [root@node1 etc]# cd ../var/named/
- #同样使用cp -p 方式复制文件到新的正向和反向文件
- [root@node1 named]# cp -p named.zero node1.szdb.zero
- [root@node1 named]# cp -p named.local 7.168.192.local
- #下面是修改之后的正向搜索文件,也可以将host文件的其他ip对照编辑到正向搜索文件以实现解析
- #如下面的例子将vip的参照关系也添加到解析文件
- [root@node1 named]# cat node1.szdb.zero
- $TTL 86400
- @ IN SOA node1.szdb.com. root.szdb.com. (
- 42 ; serial (d. adams)
- 3H ; refresh
- 15M ; retry
- 1W ; expiry
- 1D ) ; minimum
- IN NS node1.szdb.com.
- scan-cluster1 IN A 192.168.7.91
- scan-cluster1 IN A 192.168.7.92
- scan-cluster1.szdb.com IN A 192.168.7.91
- scan-cluster1.szdb.com IN A 192.168.7.92
- node1-vip IN A 192.168.7.81
- node2-vip IN A 192.168.7.82
- node1-vip.szdb.com IN A 192.168.7.81
- node2-vip.szdb.com IN A 192.168.7.82
- #下面是修改之后的反向搜索文件
- [root@node1 named]# cat 7.168.192.local
- $TTL 86400
- @ IN SOA node1.szdb.com. root.szdb.com. (
- 1997022700 ; Serial
- 28800 ; Refresh
- 14400 ; Retry
- 3600000 ; Expire
- 86400 ) ; Minimum
- IN NS node1.szdb.com.
- 1 IN PTR node1.szdb.com.
- 91 IN PTR scan-cluster1.szdb.com.
- 92 IN PTR scan-cluster1.szdb.com.
- 91 IN PTR scan-cluster1.
- 92 IN PTR scan-cluster1.
- 81 IN PTR node1-vip.
- 82 IN PTR node2-vip.
- 81 IN PTR node1-vip.szdb.com.
- 82 IN PTR node2-vip.szdb.com.
- #在各个节点配置resolv.conf文件
- #下面是修改之后的内容
- [root@node1 named]# more /etc/resolv.conf
- ; generated by /sbin/dhclient-script
- #the following item removed by Robinson
- #search SSG-140
- #nameserver 192.168.7.10
- #nameserver 192.168.7.11
- #the following item added by Robinson
- search szdb.com
- nameserver 192.168.7.71
- #节点2上的resolv.conf文件
- [root@node2 ~]# more /etc/resolv.conf
- ; generated by /sbin/dhclient-script
- #search SSG-140
- #nameserver 192.168.7.10
- #nameserver 192.168.7.11
- search szdb.com
- nameserver 192.168.7.71
- #启动dns服务
- [root@node1 named]# service named restart
- Stopping named: [ OK ]
- Starting named: [ OK ]
- [root@node1 named]# chkconfig named on
- #测试dns解析
- [root@node1 named]# cd ~
- [root@node1 ~]# nslookup 192.168.7.91
- Server: 192.168.7.71
- Address: 192.168.7.71#53
- 91.7.168.192.in-addr.arpa name = scan-cluster1.
- 91.7.168.192.in-addr.arpa name = scan-cluster1.szdb.com.
- [root@node1 ~]# nslookup 192.168.7.92
- Server: 192.168.7.71
- Address: 192.168.7.71#53
- 92.7.168.192.in-addr.arpa name = scan-cluster1.szdb.com.
- 92.7.168.192.in-addr.arpa name = scan-cluster1.
- [root@node1 ~]# nslookup scan-cluster1
- Server: 192.168.7.71
- Address: 192.168.7.71#53
- Name: scan-cluster1.szdb.com
- Address: 192.168.7.92
- Name: scan-cluster1.szdb.com
- Address: 192.168.7.91
- [root@node1 ~]# nslookup scan-cluster1.szdb.com.
- Server: 192.168.7.71
- Address: 192.168.7.71#53
- Name: scan-cluster1.szdb.com
- Address: 192.168.7.91
- Name: scan-cluster1.szdb.com
- Address: 192.168.7.92
- 转:http://blog.csdn.net/leshami/article/details/8291685#comments