2.2 配置 /etc/hosts文件
参照Figure 2.1网络配置信息表,修改节点1的/etc/hosts配置文件。
[root@node1 ~]# cp /etc/hosts /etc/hosts.bak
[root@node1 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost
::1 localhost6.localdomain6 localhost6
# node1
172.16.0.191 node1.localdomain node1
172.16.0.193 node1-vip.localdomain node1-vip
192.168.94.11 node1-priv.localdomain node1-priv
# node2
172.16.0.192 node2.localdomain node2
172.16.0.194 node2-vip.localdomain node2-vip
192.168.94.12 node2-priv.localdomain node2-priv
# scan-ip
172.16.0.203 scan-cluster.localdomain scan-cluster
[root@node1 ~]#
2.3 配置DNS服务器,确认SCAN IP可以被解析
从Oracle 11gR2开始,引入SCAN(Single Client Access Name) IP的概念,相当于在客户端和数据库之间增加一层虚拟的网络服务层,即是SCAN IP和SCAP IP Listener。在客户端的tnsnames.ora配置文件中,只需要配置SCAN IP的配置信息即可,客户端通过SCAN IP、SCAN IP Listener来访问数据库。同之前各版本的RAC相比,使用SCAN IP的好处就是,当后台RAC数据库添加、删除节点时,客户端配置信息无需修改。可以通过配置DNS服务器或GNS来配置SCAN,我们这里以DNS为例来进行配置。
2.3.1 配置DNS服务器
这里,选择IP地址为172.16.0.176的服务器来配置DNS服务器。
①安装DNS软件包:
[root@rdd dns_rpm]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:99:DA:22
inet addr:172.16.0.176 Bcast:172.16.15.255 Mask:255.255.240.0
inet6 addr: fe80::20c:29ff:fe99:da22/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10237921 errors:0 dropped:0 overruns:0 frame:0
TX packets:1394986 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3375785216 (3.1 GiB) TX bytes:596171214 (568.5 MiB)
[root@rdd dns_rpm]# pwd
/root/dns_rpm
[root@rdd dns_rpm]# ll
total 1112
-rw-r–r– 1 root root 1015531 Apr 23 14:53 bind-9.3.6-4.P1.el5_4.2.x86_64.rpm
-rw-r–r– 1 root root 45360 Apr 23 14:53 bind-chroot-9.3.6-4.P1.el5_4.2.x86_64.rpm
-rw-r–r– 1 root root 62251 Apr 23 14:53 caching-nameserver-9.3.6-4.P1.el5_4.2.x86_64.rpm
[root@rdd dns_rpm]# rpm -ivh bind-9.3.6-4.P1.el5_4.2.x86_64.rpm
warning: bind-9.3.6-4.P1.el5_4.2.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing… ########################################### [100%]
1:bind ########################################### [100%]
[root@rdd dns_rpm]# rpm -ivh bind-chroot-9.3.6-4.P1.el5_4.2.x86_64.rpm
warning: bind-chroot-9.3.6-4.P1.el5_4.2.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing… ########################################### [100%]
1:bind-chroot ########################################### [100%]
[root@rdd dns_rpm]# rpm -ivh caching-nameserver-9.3.6-4.P1.el5_4.2.x86_64.rpm
warning: caching-nameserver-9.3.6-4.P1.el5_4.2.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing… ########################################### [100%]
1:caching-nameserver ########################################### [100%]
[root@rdd dns_rpm]#
② 配置/var/named/chroot/etc/named.conf文件
先拷贝生成该文件:
[root@rdd dns_rpm]# cd /var/named/chroot/etc/
[root@rdd etc]# ll
total 16
-rw-r–r– 1 root root 405 Apr 18 07:50 localtime
-rw-r—– 1 root named 1230 Jan 21 2010 named.caching-nameserver.conf
-rw-r—– 1 root named 955 Jan 21 2010 named.rfc1912.zones
-rw-r—– 1 root named 113 Apr 23 14:55 rndc.key
[root@rdd etc]# cp -p named.caching-nameserver.conf named.conf
[root@rdd etc]#
修改后的该文件内容如下:
[root@rdd etc]# pwd
/var/named/chroot/etc
[root@rdd etc]# cat 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.rfc1912.zones";
};
[root@rdd etc]#
说明:为简单起见,将该文件中的127.0.0.1、localhost全部修改成any,且修改时,需要注意左右两边留空格。修改部分在上述配置文件中以红色加粗标示。
通过拷贝来生成/var/named/chroot/etc/named.conf文件时,注意加上-p选项,来保证文件的权限问题,否则会导致DNS服务启不来!
③ 配置Zone文件,修改/var/named/chroot/etc/named.rfc1912.zones文件
配置Zone的目的是为了解析SCAN IP,在该文件末尾添加以下反向Zone:
zone "0.16.172.in-addr.arpa." IN {
type master;
file "0.16.172.in-addr.arpa";
allow-update { none; };
};
配置反向Zone之后的该文件内容如下:
[root@rdd etc]# pwd
/var/named/chroot/etc
[root@rdd etc]# ll
total 20
-rw-r–r– 1 root root 405 Apr 18 07:50 localtime
-rw-r—– 1 root named 1230 Jan 21 2010 named.caching-nameserver.conf
-rw-r—– 1 root root 1200 Apr 23 15:03 named.conf
-rw-r—– 1 root named 1085 Apr 23 15:19 named.rfc1912.zones
-rw-r—– 1 root named 113 Apr 23 14:55 rndc.key
[root@rdd etc]# cat 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
//
// 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; };
};
zone "0.16.172.in-addr.arpa." IN {
type master;
file "0.16.172.in-addr.arpa";
allow-update { none; };
};
[root@rdd etc]#
说明:正常情况下还应该配置正向Zone文件。这里,我们的RAC双节点node1、node2的域名domain都设置为localdomain,而默认情况下,该配置文件(/var/named/chroot/etc/named.rfc1912.zones)的第15行到第20行中已经自带下述正向Zone文件配置信息,所以无需再添加。
zone "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};
④ 配置正、反向解析数据库文件。在/var/named/chroot/var/named路径下进行配置
首先,生成正、反向解析数据库文件。利用/var/named/chroot/var/named/localhost.zone复制生成正向解析的数据库文件,利用/var/named/chroot/var/named/localhost.zone复制生成名为0.16.172.in-addr.arpa的反向解析的数据库文件。
[root@rdd etc]# pwd
/var/named/chroot/etc
[root@rdd etc]# cd /var/named/chroot/var/named/
[root@rdd named]# ll
total 36
drwxrwx— 2 named named 4096 Aug 26 2004 data
-rw-r—– 1 root named 198 Jan 21 2010 localdomain.zone
-rw-r—– 1 root named 195 Jan 21 2010 localhost.zone
-rw-r—– 1 root named 427 Jan 21 2010 named.broadcast
-rw-r—– 1 root named 1892 Jan 21 2010 named.ca
-rw-r—– 1 root named 424 Jan 21 2010 named.ip6.local
-rw-r—– 1 root named 426 Jan 21 2010 named.local
-rw-r—– 1 root named 427 Jan 21 2010 named.zero
drwxrwx— 2 named named 4096 Jul 27 2004 slaves
[root@rdd named]# cp -p named.local 0.16.172.in-addr.arpa
[root@rdd named]# ll
total 40
-rw-r—– 1 root named 426 Apr 23 16:10 0.16.172.in-addr.arpa
drwxrwx— 2 named named 4096 Aug 26 2004 data
-rw-r—– 1 root named 198 Jan 21 2010 localdomain.zone
-rw-r—– 1 root named 195 Jan 21 2010 localhost.zone
-rw-r—– 1 root named 427 Jan 21 2010 named.broadcast
-rw-r—– 1 root named 1892 Jan 21 2010 named.ca
-rw-r—– 1 root named 424 Jan 21 2010 named.ip6.local
-rw-r—– 1 root named 426 Jan 21 2010 named.local
-rw-r—– 1 root named 427 Jan 21 2010 named.zero
drwxrwx— 2 named named 4096 Jul 27 2004 slaves
[root@rdd named]#
说明:在上述步骤③中我们没有配置正向Zone文件,故只需生成反向解析数据库文件,正向解析数据库文件利用默认的localdomain.zone文件。
生成的正、反向解析数据库文件名一定要同上述步骤③中定义的正、反向Zone文件一致,否则DNS出错!
然后,定义正、反向解析数据库文件。
在正向解析数据库文件localdomain.zone末尾添加下述内容:
scan-cluster IN A 172.16.0.203
添加后内容如下:
[root@rdd named]# pwd
/var/named/chroot/var/named
[root@rdd named]# cat localdomain.zone
$TTL 86400
@ IN SOA localhost root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS localhost
localhost IN A 127.0.0.1
scan-cluster IN A 172.16.0.203
[root@rdd named]#
在反向解析数据库文件0.16.172.in-addr.arpa末尾添加下述内容:
203 IN PTR scan-cluster.localdomain.
添加后内容如下:
[root@rdd named]# pwd
/var/named/chroot/var/named
[root@rdd named]# cat 0.16.172.in-addr.arpa
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
1 IN PTR localhost.
203 IN PTR scan-cluster.localdomain.
[root@rdd named]#
2.3.2 测试DNS服务器解析SCAN IP正常
首先,在DNS服务器172.16.0.176上启动DNS服务:
[root@rdd named]# /etc/init.d/named status
rndc: connect failed: 127.0.0.1#953: connection refused
named is stopped
[root@rdd named]# /etc/init.d/named start
Starting named: [ OK ]
[root@rdd named]# /etc/init.d/named status
number of zones: 7
debug level: 0
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is OFF
recursive clients: 0/1000
tcp clients: 0/100
server is up and running
named (pid 23307) is running…
[root@rdd named]# chkconfig named on
[root@rdd named]#
然后,分别在RAC节点node1、node2的/etc/resolv.conf配置文件中添加下述配置信息:
search localdomain
nameserver 172.16.0.176
添加之后:
[root@node1 ~]# cat /etc/resolv.conf
search localdomain
nameserver 172.16.0.176
[root@node1 ~]#
最后,测试SCAN IP解析是否成功?
node1测试:
[root@node1 ~]# nslookup 172.16.0.203
Server: 172.16.0.176
Address: 172.16.0.176#53
203.0.16.172.in-addr.arpa name = scan-cluster.localdomain.
[root@node1 ~]# nslookup scan-cluster.localdomain
Server: 172.16.0.176
Address: 172.16.0.176#53
Name: scan-cluster.localdomain
Address: 172.16.0.203
[root@node1 ~]# nslookup scan-cluster
Server: 172.16.0.176
Address: 172.16.0.176#53
Name: scan-cluster.localdomain
Address: 172.16.0.203
[root@node1 ~]#
node2测试:
[root@node2 ~]# nslookup 172.16.0.203
Server: 172.16.0.176
Address: 172.16.0.176#53
203.0.16.172.in-addr.arpa name = scan-cluster.localdomain.
[root@node2 ~]# nslookup scan-cluster.localdomain
Server: 172.16.0.176
Address: 172.16.0.176#53
Name: scan-cluster.localdomain
Address: 172.16.0.203
[root@node2 ~]# nslookup scan-cluster
Server: 172.16.0.176
Address: 172.16.0.176#53
Name: scan-cluster.localdomain
Address: 172.16.0.203
[root@node2 ~]#
至此,准备工作中的配置SCAN IP通过配置DNS服务器来解析已经成功!