当前位置:   article > 正文

RAC的dns server配置_如何修改rac数据库为dns方式

如何修改rac数据库为dns方式

在oracle 11gR2 RAC中,oracle使用了SCAN(single client access name),在VIP的上面又加了一层网络管理,虽说方便了客户端,在RAC增加节点数量的时候,在客户端的tnsnames不进行改动,对于一个数据库服务多个应用服务器的场景提供了方便,但是,由于oracle把手伸到了网络层面,多一层SCAN IP也多一层故障的可能性。

在安装11gR2 RAC的时候,由于oracle强制使用SCAN,在安装时如果没有启用DNS,安装就会进行不下去。报错INS-40922和INS-40718。虽然我们可以使用单个IP做SCAN,但是oracle还是比较推荐使用DNS服务,或者采用GNS服务。

在这里我们来为RAC配置一个DNS server。
相关的IP是如下设置的:

127.0.0.1       localhost.localdomain   localhost
#DNS server
192.168.190.220 dnsserver.oracleblog.org dnsserver
# Public
192.168.190.101 rac1.oracleblog.org     rac1
192.168.190.102 rac2.oracleblog.org     rac2
# Private
192.168.0.101   rac1-priv.oracleblog.org        rac1-priv
192.168.0.102   rac2-priv.oracleblog.org        rac2-priv
# Virtual
192.168.190.111 rac1-vip.oracleblog.org rac1-vip
192.168.190.112 rac2-vip.oracleblog.org rac2-vip
# SCAN
192.168.190.201 rac-scan.oracleblog.org rac-scan
192.168.190.202 rac-scan.oracleblog.org rac-scan
192.168.190.203 rac-scan.oracleblog.org rac-scan

首先,我们到DNS服务器上配置DNS服务,
我们进入/var/named/chroot/etc,看看是否存在相关的配置文件:

[root@dnsserver etc]#cd /var/named/chroot
[root@dnsserver etc]# ll
total 16
-rw-r--r-- 1 root root  3519 Feb 27  2006 localtime
-rw-r----- 1 root named  113 May 23 00:45 rndc.key

此时相关的配置文件都还不存在,如果我们启动DNS服务,就会报错fail:

[root@dnsserver etc]# service named start
Locating /var/named/chroot//etc/named.conf failed:
[FAILED]
[root@dnsserver etc]#

好,下面我们开始配置,我们touch一个named.conf,然后在里面输入:

[root@dnsserver etc]# cat named.conf
//
 
// named.conf for Red Hat caching-nameserver
 
//
 
 
 
options {
 
       directory "/var/named";
 
       dump-file "/var/named/data/cache_dump.db";
 
       statistics-file "/var/named/data/named_stats.txt";
 
       /*
 
        * If there is a firewall between you and nameservers you want
 
        * to talk to, you might need to uncomment the query-source
 
        * directive below. Previous versions of BIND always asked
 
        * questions using port 53, but BIND 8.1 uses an unprivileged
 
        * port by default.
 
        */
 
        // query-source address * port 53;
 
};
 
 
 
//
 
// a caching only nameserver config
 
//
 
controls {
 
       inet 127.0.0.1 allow { localhost; } keys { rndckey; };
 
};
 
 
 
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; };
 
};
 
######################################
# ADD for oracle RAC SCAN,
# START FROM HERE
######################################
zone "190.168.192.in-addr.arpa" IN {
 
       type master;
 
       file "190.168.192.in-addr.local";
 
       allow-update { none; };
 
};
 
 
 
zone "oracleblog.org" IN {
 
       type master;
 
       file "oracleblog.org.zone";
 
       allow-update { none; };
 
};
######################################
# ADD for oracle RAC SCAN,
# END FROM HERE
######################################

我们看到,上面有6个zone,其中前面4个zone是系统的,后面的2个zone是我们给RAC的SCAN配置的。对应的每个zone,我们都有一个对应的file放在/var/named/chroot/var/named下。

zone .=>named.ca
zone localdomain=>localdomain.zone
zone localhost=>localhost.zone
zone 0.0.127.in-addr.arpa=>named.local
zone 190.168.192.in-addr.arpa=>190.168.192.in-addr.local
zone oracleblog.org=>oracleblog.org.zone

如果在/var/named/chroot/var/named下你找不到相关的zone文件,也没关系,在/usr/share/doc/bind-9.3.6/sample/var/named下就有相关的sample文件(Oracle Linux Enterprise 5 update 8),我们拷贝过来就可以用。

拷贝过来后,在/var/named/chroot/var/named有:

[root@dnsserver named]# ls -l
total 60
drwxrwx--- 2 named named 4096 Aug 26  2004 data
-rw-r--r-- 1 root  root   198 Dec 20 17:01 localdomain.zone
-rw-r--r-- 1 root  root   195 Dec 20 17:01 localhost.zone
-rw-r--r-- 1 root  root    56 Dec 20 17:18 my.external.zone.db
-rw-r--r-- 1 root  root    56 Dec 20 17:18 my.internal.zone.db
-rw-r--r-- 1 root  root   427 Dec 20 17:01 named.broadcast
-rw-r--r-- 1 root  root   424 Dec 20 17:01 named.ip6.local
-rw-r--r-- 1 root  root   426 Dec 20 17:01 named.local
-rw-r--r-- 1 root  root  1892 Dec 20 17:01 named.root
-rw-r--r-- 1 root  root   427 Dec 20 17:01 named.zero
drwxrwx--- 2 named named 4096 Jul 27  2004 slaves
[root@dnsserver named]#

此时,你会发现,190.168.192.in-addr.local和oracleblog.org.zone还有named.ca还没有呢?别急,前2个文件我们可以从named.local和localdomain.zone借鉴,而named.ca是个固定的文件,记录着根服务器的地址,一般情况下不会改变,我们可以在网上抄一个。

[root@dnsserver named]# cp -p named.local 190.168.192.in-addr.local
[root@dnsserver named]# cp -p  localdomain.zone oracleblog.org.zone
[root@dnsserver named]# ls -lrt
total 68
drwxrwx--- 2 named named 4096 Jul 27  2004 slaves
drwxrwx--- 2 named named 4096 Aug 26  2004 data
-rw-r--r-- 1 root  root   427 Dec 20 17:01 named.zero
-rw-r--r-- 1 root  root  1892 Dec 20 17:01 named.root
-rw-r--r-- 1 root  root   426 Dec 20 17:01 named.local
-rw-r--r-- 1 root  root   424 Dec 20 17:01 named.ip6.local
-rw-r--r-- 1 root  root   427 Dec 20 17:01 named.broadcast
-rw-r--r-- 1 root  root   195 Dec 20 17:01 localhost.zone
-rw-r--r-- 1 root  root   198 Dec 20 17:01 localdomain.zone
-rw-r--r-- 1 root  root    56 Dec 20 17:18 my.internal.zone.db
-rw-r--r-- 1 root  root    56 Dec 20 17:18 my.external.zone.db
-rw-r--r-- 1 root  root   761 May 23 18:19 oracleblog.org.zone
-rw-r--r-- 1 root  root   559 May 23 18:20 190.168.192.in-addr.local
[root@dnsserver named]#

ok,借鉴归借鉴,里面文件中的内容我们还是要修改的,修改完成后,内容如下:

[root@dnsserver named]# cat 190.168.192.in-addr.local
$TTL   86400
@      IN     SOA    localhost. root.localhost. (
                                     1997022700 ; Serial
                                     28800     ; Refresh
                                     14400     ; Retry
                                     3600000   ; Expire
                                     86400 )   ; Minimum
             IN     NS    oracleblog.org.
101 IN PTR rac1.oracleblog.org.
102 IN PTR rac2.oracleblog.org.
201 IN PTR rac-scan.oracleblog.org.
202 IN PTR rac-scan.oracleblog.org.
203 IN PTR rac-scan.oracleblog.org.
[root@dnsserver named]# cat oracleblog.org.zone
$TTL   86400
@              IN SOA  localhost root(
                                       42             ; serial (d. adams)
                                       3H             ; refresh
                                       15M            ; retry
                                       1W             ; expiry
                                       1D )           ; minimum
               IN NS          oracleblog.org.
rac1   IN     A      192.168.190.101
rac2   IN     A      192.168.190.102
rac-scan      IN     A      192.168.190.201
rac-scan      IN     A      192.168.190.202
rac-scan      IN     A      192.168.190.203
rac1-vip IN     A       192.168.190.111
rac2-vip IN     A       192.168.190.112

named.ca文件的内容:

;       This file holds the information on root name servers needed to
;       initialize cache of Internet domain name servers
;       (e.g. reference this file in the "cache  . 
< file > ;"
;       configuration file of BIND domain name servers).
;
;       This file is made available by InterNIC registration services
;       under anonymous FTP as
;           file                /domain/named.root
;           on server           FTP.RS.INTERNIC.NET
;       -OR- under Gopher at    RS.INTERNIC.NET
;           under menu          InterNIC Registration Services (NSI)
;              submenu          InterNIC Registration Archives
;           file                named.root
;
;       last update:    Aug 22, 1997
;       related version of root zone:   1997082200
; $FreeBSD: src/etc/namedb/named.root,v 1.9 1999/09/13 17:09:08 peter Exp $
;
; formerly NS.INTERNIC.NET
;
.                        3600000  IN  NS    A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET.      3600000      A     198.41.0.4
;
; formerly NS1.ISI.EDU
;
.                        3600000      NS    B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET.      3600000      A     128.9.0.107
;
; formerly C.PSI.NET
;
.                        3600000      NS    C.ROOT-SERVERS.NET.
C.ROOT-SERVERS.NET.      3600000      A     192.33.4.12
;
; formerly TERP.UMD.EDU
;
.                        3600000      NS    D.ROOT-SERVERS.NET.
D.ROOT-SERVERS.NET.      3600000      A     128.8.10.90
;
; formerly NS.NASA.GOV
;
.                        3600000      NS    E.ROOT-SERVERS.NET.
E.ROOT-SERVERS.NET.      3600000      A     192.203.230.10
;
; formerly NS.ISC.ORG
;
.                        3600000      NS    F.ROOT-SERVERS.NET.
F.ROOT-SERVERS.NET.      3600000      A     192.5.5.241
;
; formerly NS.NIC.DDN.MIL
;
.                        3600000      NS    G.ROOT-SERVERS.NET.
G.ROOT-SERVERS.NET.      3600000      A     192.112.36.4
;
; formerly AOS.ARL.ARMY.MIL
;
.                        3600000      NS    H.ROOT-SERVERS.NET.
H.ROOT-SERVERS.NET.      3600000      A     128.63.2.53
;
; formerly NIC.NORDU.NET
;
.                        3600000      NS    I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET.      3600000      A     192.36.148.17
;
; temporarily housed at NSI (InterNIC)
;
.                        3600000      NS    J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET.      3600000      A     198.41.0.10
;
; housed in LINX, operated by RIPE NCC
;
.                        3600000      NS    K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET.      3600000      A     193.0.14.129
;
; temporarily housed at ISI (IANA)
;
.                        3600000      NS    L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET.      3600000      A     198.32.64.12
;
; housed in Japan, operated by WIDE
;
.                        3600000      NS    M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET.      3600000      A     202.12.27.33
; End of File

此时,大部分的DNS服务器基本已经配置完成,不过你还需要建一个soft link和授权777。在这里提前说一句,如果你的DNS服务起不来,启动时候就一个报错fail,你可以用named -d 3 -f -g这个命令来诊断。
(1)创建soft link:

[root@dnsserver etc]# ln -s /var/named/chroot/etc/named.conf /etc/named.conf

如果不建立该soft link,会报错以下错误。

[root@dnsserver named]# named -d 3 -f -g
23-May-2012 17:56:36.860 starting BIND 9.3.6-P1-RedHat-9.3.6-20.P1.el5 -d 3 -f -g
23-May-2012 17:56:36.860 adjusted limit on open files from 1024 to 1048576
23-May-2012 17:56:36.860 found 1 CPU, using 1 worker thread
23-May-2012 17:56:36.861 using up to 4096 sockets
23-May-2012 17:56:36.866 loading configuration from '/etc/named.conf'
23-May-2012 17:56:36.866 none:0: open: /etc/named.conf: file not found
23-May-2012 17:56:36.874 load_configuration: file not found
23-May-2012 17:56:36.874 loading configuration: file not found
23-May-2012 17:56:36.874 exiting (due to fatal error)
[root@dnsserver named]#

(2)赋权777:

[root@dnsserver run]# cd /var/run
[root@dnsserver run]# chmod 777 named

如果不赋权,会报错以下错误。

[root@dnsserver named]# named -d 3 -f -g
23-May-2012 18:08:32.901 starting BIND 9.3.6-P1-RedHat-9.3.6-20.P1.el5 -d 3 -f -g
23-May-2012 18:08:32.901 adjusted limit on open files from 1024 to 1048576
23-May-2012 18:08:32.901 found 1 CPU, using 1 worker thread
23-May-2012 18:08:32.902 using up to 4096 sockets
23-May-2012 18:08:32.908 loading configuration from '/etc/named.conf'
23-May-2012 18:08:32.909 set maximum stack size to 4294967295: success
23-May-2012 18:08:32.909 set maximum data size to 4294967295: success
23-May-2012 18:08:32.910 set maximum core size to 4294967295: success
23-May-2012 18:08:32.910 set maximum open files to -1: success
23-May-2012 18:08:32.910 using default UDP/IPv4 port range: [1024, 65535]
23-May-2012 18:08:32.911 using default UDP/IPv6 port range: [1024, 65535]
23-May-2012 18:08:32.938 no IPv6 interfaces found
23-May-2012 18:08:32.938 listening on IPv4 interface lo, 127.0.0.1#53
23-May-2012 18:08:32.938 clientmgr @0xb8b46f90: create
23-May-2012 18:08:32.939 clientmgr @0xb8b46f90: createclients
23-May-2012 18:08:32.939 clientmgr @0xb8b46f90: create new
23-May-2012 18:08:32.939 client @0xb8b67800: create
23-May-2012 18:08:32.939 clientmgr @0xb8b46f90: createclients
23-May-2012 18:08:32.939 clientmgr @0xb8b46f90: create new
23-May-2012 18:08:32.939 client @0xb8b69638: create
23-May-2012 18:08:32.939 listening on IPv4 interface eth0, 192.168.190.201#53
23-May-2012 18:08:32.939 clientmgr @0xb8b6b410: create
23-May-2012 18:08:32.939 clientmgr @0xb8b6b410: createclients
23-May-2012 18:08:32.940 clientmgr @0xb8b6b410: create new
23-May-2012 18:08:32.940 client @0xb8b6ba60: create
23-May-2012 18:08:32.940 clientmgr @0xb8b6b410: createclients
23-May-2012 18:08:32.940 clientmgr @0xb8b6b410: create new
23-May-2012 18:08:32.940 client @0xb8b6d908: create
23-May-2012 18:08:32.941 res 0xb8b77310: create
23-May-2012 18:08:32.941 dns_requestmgr_create
23-May-2012 18:08:32.941 dns_requestmgr_create: 0xb8b7ac50
23-May-2012 18:08:32.941 dns_requestmgr_whenshutdown
23-May-2012 18:08:32.942 res 0xb8b82808: create
23-May-2012 18:08:32.942 dns_requestmgr_create
23-May-2012 18:08:32.942 dns_requestmgr_create: 0xb8b83ed8
23-May-2012 18:08:32.942 dns_requestmgr_whenshutdown
23-May-2012 18:08:32.943 command channel listening on 127.0.0.1#953
23-May-2012 18:08:32.943 ignoring config file logging statement due to -g option
23-May-2012 18:08:32.943 couldn't open pid file '/var/run/named/named.pid': Permission denied
23-May-2012 18:08:32.943 exiting (due to early fatal error)
[root@dnsserver named]#

好了,在DNS服务器端,我们就配置完成了,启动DNS服务器,即可正常工作了。

[root@dnsserver var]# service named stop
Stopping named: [  OK  ]
[root@dnsserver var]# service named start
Starting named: [  OK  ]
[root@dnsserver var]#

设置完成DNS服务器,我们还需要在所有的数据库服务器端做一些设置:
在数据库服务器端,修改/etc/resolv.conf文件,设置DNS服务器,加上搜索域:

[root@rac2 ~]# cat /etc/resolv.conf
search oracleblog.org
nameserver 192.168.190.220
nameserver 192.168.190.1

建立/etc/host.conf文件,指定解析顺序,先DNS,再hosts

order bind,hosts
multi on

ok,我们在安装界面输入完成后,valid SCAN,点击next,就会进入到安装的下一步。

此时,你可以nslookup SCAN,就会发现通过DNS服务,对3个IP192.168.190.201、192.168.190.202、192.168.190.203进行轮询了:

[root@rac1 ~]# nslookup rac-scan
Server:         192.168.190.220
Address:        192.168.190.220#53
 
Name:   rac-scan.oracleblog.org
Address: 192.168.190.202
Name:   rac-scan.oracleblog.org
Address: 192.168.190.203
Name:   rac-scan.oracleblog.org
Address: 192.168.190.201
 
[root@rac1 ~]# nslookup rac-scan
Server:         192.168.190.220
Address:        192.168.190.220#53
 
Name:   rac-scan.oracleblog.org
Address: 192.168.190.201
Name:   rac-scan.oracleblog.org
Address: 192.168.190.202
Name:   rac-scan.oracleblog.org
Address: 192.168.190.203
 
[root@rac1 ~]# nslookup rac-scan
Server:         192.168.190.220
Address:        192.168.190.220#53
 
Name:   rac-scan.oracleblog.org
Address: 192.168.190.203
Name:   rac-scan.oracleblog.org
Address: 192.168.190.201
Name:   rac-scan.oracleblog.org
Address: 192.168.190.202
 
[root@rac1 ~]#
 
 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/酷酷是懒虫/article/detail/976341
推荐阅读
相关标签
  

闽ICP备14008679号