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
#下面是修改後的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
oracle視頻教程請關注:http://u.youku.com/user_video/id_UMzAzMjkxMjE2.html