Focus On Oracle

Installing, Backup & Recovery, Performance Tuning,
Troubleshooting, Upgrading, Patching

Oracle Engineered System


当前位置: 首页 » 技术文章 » Oracle

Oracle RAC GNS(Grid Naming Service)

在11gR2以上的RAC中,我们有三种方式配置SCAN IP(/etc/hosts,DNS,GNS)。第一种使用最频繁,第二种次之,第三种用到的很少,毕竟又多了一处单点故障


Grid Naming Service (GNS)
A generic service which resolves the names of hosts in a delegated normal DNS zone by mapping them to IP addresses within the zone. GNS enables the use of Dynamic Host Configuration Protocol (DHCP) address for Oracle RAC database nodes, simplifying deployment. GNS also resolves host names passed back from a SCAN listener.

Multicast domain name service (mDNS): Allows DNS requests. The mDNS process is
a background process on Linux and UNIX, and a service on Windows.
Oracle Grid Naming Service (GNS): Is a gateway between the cluster mDNS and
external DNS servers. The GNS process performs name resolution within the cluster



如果用GNS,我们需要配置DNS和DHCP服务器。整个RAC的架构也会发生变化。一般情况下,我们需要先设置Public IP,Private IP,SCAN VIP,如果使用GNS,我们只需要设置Public IP和Private IP,其他VIP都从DHCP中动态获取,GNS Server必须为固定IP。简单地可以把GNS的作用理解为集群中的DNS服务器,且只服务于集群中的Virtual IP。


服务器信息一览表

Node Name Usage Public IP Private IP Virtual IP SCAN VIP
ohs1.ohsdba.cn GI/DB Server 10.0.2.21 172.0.16.21 从DHCP获得
ohs2.ohsdba.cn 10.0.2.22 172.0.16.22
ohs3.ohsdba.cn 10.0.2.23 172.0.16.23
od.ohsdba.cn DNS/DHCP/NTP 10.0.2.10 N/A  
gns.ohsdba.cn GNS Server 10.0.2.11 N/A 在DNS配置文件中









安装配置DNS

[root@od ~]# rpm -q bind-
bind-9.8.2-0.47.rc1.el6.x86_64
[root@od ~]# rpm -q bind-chroot
bind-chroot-9.8.2-0.47.rc1.el6.x86_64

[root@od ~]#

修改DNS服务器的配置文件/etc/named.conf

zone "." IN {                //设置根区域
        type hint;           //设置区域类型(hint表示根域,master表示主域,slave表示从域 )
        file "/dev/null";    //设置对应的根域地址数据库文件
};
[root@od ~]# cat /var/named/chroot/etc/named.conf


options {
        directory "/var/named";     // Base directory for named
        allow-transfer {"none";};   // Slave serves that can pull zone transfer. Ban everyone by default
        };

zone "2.0.10.IN-ADDR.ARPA." IN { // Reverse zone.
        type master;
        notify no;
        file "10.0.2.db";
};
zone "ohsdba.cn." IN {
        type master;
        notify no;
        file "ohsdba.cn.db";
};
[root@od ~]# cat /var/named/chroot/var/named/10.0.2.db
$TTL 1H
@       IN      SOA     od  root.ohsdba.cn.  (
                        2009011201      ; serial (todays date + todays serial #)
                        3H              ; refresh 3 hours
                        1H              ; retry 1 hour
                        1W              ; expire 1 week
                        1D )            ; minimum 24 hour
;
              NS        od.ohsdba.cn.
10            PTR       od.ohsdba.cn.
11            PTR       gns.ohsdba.cn. ; reverse mapping for GNS
21            PTR       ohs1.ohsdba.cn.
22            PTR       ohs2.ohsdba.cn.
23            PTR       ohs3.ohsdba.cn.
[root@od ~]# cat /var/named/chroot/var/named/ohsdba.cn.db
$TTL 1H         ; Time to live
$ORIGIN ohsdba.cn.
@       IN      SOA     od  root.ohsdba.cn.  (
                        2009011201      ; serial (todays date + todays serial #)
                        3H              ; refresh 3 hours
                        1H              ; retry 1 hour
                        1W              ; expire 1 week
                        1D )            ; minimum 24 hour
;
                  A         10.0.2.10
                  NS        od          ; Name server for ohsdba.cn
od                A         10.0.2.10
ohs1              A         10.0.2.21
ohs2              A         10.0.2.22
ohs3              A         10.0.2.23
gns               A         10.0.2.11   ; A record for the GNS
;
;sub-domain(us.ohsdba.cn) definitions
$ORIGIN us.ohsdba.cn.
@      IN         NS        gns.ohsdba.cn.     ; name server for the us.ohsdba.cn
[root@od ~]#

注意:此处域名us.ohsdba.cn为GNS所用,name server为gns.ohsdba.cn


查看、安装配置DHCP
[root@od ~]# rpm -q dhcp
dhcp-4.1.1-51.P1.0.1.el6.x86_64
[root@od ~]#
[root@od ~]# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see 'man 5 dhcpd.conf'
#
ddns-update-style interim;
ignore client-updates;
subnet 10.0.2.0 netmask 255.255.255.0 {
        option routers                  10.0.2.1;               # Default gateway to be used by DHCP clients
        option subnet-mask              255.255.255.0;          # Default subnet mask to be used by DHCP clients.
        option ip-forwarding            off;                    # Do not forward DHCP requests.
        option broadcast-address        10.0.2.255;             # Default broadcast address to be used by DHCP client.
        option domain-name              "us.ohsdba.cn";         # This domain name will be used for GNS
        option domain-name-servers      10.0.2.10;              # IP address of the DNS server. In this document it will be ohs1
        option time-offset              -19000;                 # Central Standard Time
        option ntp-servers              0.pool.ntp.org;         # Default NTP server to be used by DHCP clients

        range                           10.0.2.120 10.0.2.150;  # Range of IP addresses that can be issued to DHCP client
        default-lease-time              21600;                  # Amount of time in seconds that a client may keep the IP address
        max-lease-time                  43200;
}
[root@od ~]#

注意:dhcp此处domain-name为GNS sub domain的域名


RAC各节点/etc/hosts文件,resolv.conf
[orgrid@ohs1 ~]$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.2.21        ohs1.ohsdba.cn ohs1 # public address of node 1
10.0.2.22        ohs2.ohsdba.cn ohs2 # public address of node 2
10.0.2.23        ohs3.ohsdba.cn ohs3 # public address of node 3

172.16.0.21      ohs1-priv.ohsdba.cn ohs1-priv   # private address of node 1
172.16.0.22      ohs2-priv.ohsdba.cn ohs2-priv   # private address of node 2
172.16.0.23      ohs3-priv.ohsdba.cn ohs3-priv   # private address of node 3

10.0.2.10 od.ohsdba.cn #dns dhcp ntp server
[orgrid@ohs1 ~]$ cat /etc/resolv.conf
options timeout:1 attempts:1 rotate
search ohsdba.cn
nameserver 10.0.2.10

[orgrid@ohs1 ~]$


查看集群信息
[orgrid@ohs1 bin]$ olsnodes -c
ohs
[orgrid@ohs1 bin]$
[orgrid@ohs1 bin]$ olsnodes -s -a -n -t
ohs1    1       Active  Hub     Unpinned
ohs2    2       Active  Hub     Unpinned
ohs3    3       Active  Hub     Unpinned
[orgrid@ohs1 bin]$ 
[orgrid@ohs1 ~]$ nslookup pgold-scan.us.ohsdba.cn 10.0.2.10
Server:         10.0.2.10
Address:        10.0.2.10#53

Non-authoritative answer:
Name:   pgold-scan.us.ohsdba.cn
Address: 10.0.2.132
Name:   pgold-scan.us.ohsdba.cn
Address: 10.0.2.133
Name:   pgold-scan.us.ohsdba.cn
Address: 10.0.2.124
[orgrid@ohs1 ~]$ nslookup pgold-scan.us.ohsdba.cn 10.0.2.11
Server:         10.0.2.11
Address:        10.0.2.11#53

Name:   pgold-scan.us.ohsdba.cn
Address: 10.0.2.124
Name:   pgold-scan.us.ohsdba.cn
Address: 10.0.2.132
Name:   pgold-scan.us.ohsdba.cn
Address: 10.0.2.133
[orgrid@ohs1 ~]$
[orgrid@ohs1 ~]$ srvctl config asm
ASM home: <CRS home>
Password file: +SYSTEMDG/orapwASM
ASM listener: LISTENER
ASM instance count: 3
Cluster ASM listener: ASMNET1LSNR_ASM
[orgrid@ohs1 ~]$ 

[orgrid@ohs1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       ohs1                     STABLE
               ONLINE  ONLINE       ohs2                     STABLE
               ONLINE  ONLINE       ohs3                     STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       ohs1                     STABLE
               ONLINE  ONLINE       ohs2                     STABLE
               ONLINE  ONLINE       ohs3                     STABLE
ora.SYSTEMDG.dg
               ONLINE  ONLINE       ohs1                     STABLE
               ONLINE  ONLINE       ohs2                     STABLE
               ONLINE  ONLINE       ohs3                     STABLE
ora.net1.network
               ONLINE  ONLINE       ohs1                     STABLE
               ONLINE  ONLINE       ohs2                     STABLE
               ONLINE  ONLINE       ohs3                     STABLE
ora.ons
               ONLINE  ONLINE       ohs1                     STABLE
               ONLINE  ONLINE       ohs2                     STABLE
               ONLINE  ONLINE       ohs3                     STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       ohs2                     STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       ohs3                     STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       ohs1                     STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       ohs1                     169.254.229.106,STAB
                                                             LE
ora.asm
      1        ONLINE  ONLINE       ohs1                     Started,STABLE
      2        ONLINE  ONLINE       ohs2                     Started,STABLE
      3        ONLINE  ONLINE       ohs3                     Started,STABLE
ora.cvu
      1        ONLINE  ONLINE       ohs1                     STABLE
ora.gns
      1        ONLINE  ONLINE       ohs1                     STABLE
ora.gns.vip
      1        ONLINE  ONLINE       ohs1                     STABLE
ora.mgmtdb
      1        ONLINE  ONLINE       ohs1                     Open,STABLE
ora.oc4j
      1        ONLINE  ONLINE       ohs1                     STABLE
ora.ohs1.vip
      1        ONLINE  ONLINE       ohs1                     STABLE
ora.ohs2.vip
      1        ONLINE  ONLINE       ohs2                     STABLE
ora.ohs3.vip
      1        ONLINE  ONLINE       ohs3                     STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       ohs2                     STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       ohs3                     STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       ohs1                     STABLE
--------------------------------------------------------------------------------

GNS信息,状态

[orgrid@ohs1 ~]$ srvctl status gns

GNS is running on node ohs1.
GNS is enabled on node ohs1.
[orgrid@ohs1 ~]$ 

[orgrid@ohs1 ~]$ ps -ef|grep gns

root     11101     1  0 Sep22 ?        00:00:49 /pgold/orgrid/oracle/product/121/bin/gnsd.bin -trace-level 1 -ip-address 10.0.2.11 -startup-endpoint ipc://GNS_ohs1_10970_b4319bcd406418dd
orgrid   25121 22864  0 04:09 pts/5    00:00:00 grep gns
[orgrid@ohs1 ~]$
[orgrid@ohs1 ~]$ srvctl config gns -detail
GNS is enabled.
GNS is listening for DNS server requests on port 53
GNS is using port 5353 to connect to mDNS
GNS status: OK
Domain served by GNS: us.ohsdba.cn
GNS version: 12.1.0.2.0
Globally unique identifier of the cluster where GNS is running: 2a2665c1f069df50ff0fc959258473d8
Name of the cluster where GNS is running: ohs
Cluster type: server.
GNS log level: 1.
GNS listening addresses: tcp://10.0.2.11:34425.
GNS is individually enabled on nodes:
GNS is individually disabled on nodes: 
[orgrid@ohs1 ~]$ srvctl config nodeapps
Network 1 exists
Subnet IPv4: 10.0.2.0/255.255.255.0/eth0, dhcp
Subnet IPv6:
Ping Targets:
Network is enabled
Network is individually enabled on nodes:
Network is individually disabled on nodes:
VIP exists: network number 1, hosting node ohs1
VIP IPv4 Address: -/ohs1-vip/10.0.2.128
VIP IPv6 Address:
VIP is enabled.
VIP is individually enabled on nodes:
VIP is individually disabled on nodes:
VIP exists: network number 1, hosting node ohs2
VIP IPv4 Address: -/ohs2-vip/10.0.2.131
VIP IPv6 Address:
VIP is enabled.
VIP is individually enabled on nodes:
VIP is individually disabled on nodes:
VIP exists: network number 1, hosting node ohs3
VIP IPv4 Address: -/ohs3-vip/10.0.2.134
VIP IPv6 Address:
VIP is enabled.
VIP is individually enabled on nodes:
VIP is individually disabled on nodes:
ONS exists: Local port 6100, remote port 6200, EM port 2016, Uses SSL false
ONS is enabled
ONS is individually enabled on nodes:
ONS is individually disabled on nodes: 
[orgrid@ohs1 ~]$

[orgrid@ohs1 ~]$ dig pgold-scan.us.ohsdba.cn

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.47.rc1.el6 <<>> pgold-scan.us.ohsdba.cn
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3552
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;pgold-scan.us.ohsdba.cn.       IN      A

;; ANSWER SECTION:
pgold-scan.us.ohsdba.cn. 120    IN      A       10.0.2.132
pgold-scan.us.ohsdba.cn. 120    IN      A       10.0.2.133
pgold-scan.us.ohsdba.cn. 120    IN      A       10.0.2.124

;; AUTHORITY SECTION:
us.ohsdba.cn.           3600    IN      NS      gns.ohsdba.cn.

;; ADDITIONAL SECTION:
gns.ohsdba.cn.          3600    IN      A       10.0.2.11

;; Query time: 9 msec
;; SERVER: 10.0.2.10#53(10.0.2.10)
;; WHEN: Fri Sep 23 05:13:30 2016
;; MSG SIZE  rcvd: 123
[orgrid@ohs1 ~]$



GNS=>DNS Only

How To Convert an 11gR2 GNS Configuration To A Standard Configuration Using DNS Only (Doc ID 1489121.1)


Reference

http://docs.oracle.com/database/121/CWADD/intro.htm#CWADD90950

http://www.computernetworkingnotes.com/network-administrations/dns-server.html

http://72.32.201.108/rac/Oracle_RAC_with_GNS.html

https://oracle-base.com/articles/linux/dns-configuration-for-scan


关键词:oracle rac 

相关文章

Oracle宣布推出全球分布式自治数据库
Oracle 23c新特性---开发人员
Oracle 23c free FAQ
Oracle 23c free and OCI Base Service
Oracle 21c
基于PDB的Active Data Guard(Oracle 21.7+)
在Oracle数据库中使用REST
OGG from MySQL to Oracle
Oracle数据库容灾之两地三中心实践
低代码开发用Oracle Apex,看这篇就够了
Oracle Database 20c之SQL宏
Java beginner for Oracle DBA
Top