# 요약
  # RAC 상태 확인
crs_stat -t
watch -n 1
crsctl stat res -t

srvctl status database -d racdb -v
srvctl status instance -d racdb -i racdb1
srvctl status nodeapps

# RAC 중단
srvctl stop instance -d racdb -i racdb1
srvctl stop asm -n rac1
srvctl stop nodeapps -n racdb1
crs_stop -all

# RAC 시작
srvctl start nodeapps -n racdb1
srvctl start asm -n rac1
srvctl start instance -d racdb -i racdb1
crs_start -all

■ RAC(Real Application Cluster)
■ RAC 장점
■ RAC 구조
1. Public Network(공용 네트워크)
2. Private Interconnect(전용 인터커넥트)
3. Virtual IP
4. 공유 스토리지(Shared Storage)
- 로 디바이스(Raw Device)
- 클러스터 파일 시스템(Clusterd File System)
- ASM(Automatic Storage Management)

# cluster

■ OCR(Oracle Cluster Repository)
/etc/oracle/ocr.loc
ocrcheck
ocrconfig -showbackup

■ Vote Disk
crsctl query css votedisk

■ RAC LOAD BALANCING
gv$instance

(LOAD_BALANCE=YES)

# CTF(Connect Time Failover)

# TAF(Transparent Application Failover)
(FAILOVER=YES)
(FAILOVER_MODE=(TYPE=SESSION)(METHOD=BASIC))
(FAILOVER_MODE=(TYPE=SELECT)(METHOD=BASIC))

 


 

# 현재 RAC 상태 확인 - 1
crs_stat -t

[oracle@rac1 ~]$ crs_stat -t
Name           Type           Target    State     Host
------------------------------------------------------------
ora.DATA.dg    ora....up.type ONLINE    ONLINE    rac1
ora.FRA.dg     ora....up.type ONLINE    ONLINE    rac1
ora....ER.lsnr ora....er.type ONLINE    ONLINE    rac1
ora....N1.lsnr ora....er.type ONLINE    ONLINE    rac2
ora.asm        ora.asm.type   ONLINE    ONLINE    rac1
ora.eons       ora.eons.type  ONLINE    ONLINE    rac1
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE
ora....network ora....rk.type ONLINE    ONLINE    rac1
ora.oc4j       ora.oc4j.type  OFFLINE   OFFLINE
ora.ons        ora.ons.type   ONLINE    ONLINE    rac1
ora....SM1.asm application    ONLINE    ONLINE    rac1
ora....C1.lsnr application    ONLINE    ONLINE    rac1
ora.rac1.gsd   application    OFFLINE   OFFLINE
ora.rac1.ons   application    ONLINE    ONLINE    rac1
ora.rac1.vip   ora....t1.type ONLINE    ONLINE    rac1
ora....SM2.asm application    ONLINE    ONLINE    rac2
ora....C2.lsnr application    ONLINE    ONLINE    rac2
ora.rac2.gsd   application    OFFLINE   OFFLINE
ora.rac2.ons   application    ONLINE    ONLINE    rac2
ora.rac2.vip   ora....t1.type ONLINE    ONLINE    rac2
ora.racdb.db   ora....se.type ONLINE    ONLINE    rac1
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    rac2
[oracle@rac2 ~]$ crs_stat -t
Name           Type           Target    State     Host
------------------------------------------------------------
ora.DATA.dg    ora....up.type ONLINE    ONLINE    rac1
ora.FRA.dg     ora....up.type ONLINE    ONLINE    rac1
ora....ER.lsnr ora....er.type ONLINE    ONLINE    rac1
ora....N1.lsnr ora....er.type ONLINE    ONLINE    rac2
ora.asm        ora.asm.type   ONLINE    ONLINE    rac1
ora.eons       ora.eons.type  ONLINE    ONLINE    rac1
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE
ora....network ora....rk.type ONLINE    ONLINE    rac1
ora.oc4j       ora.oc4j.type  OFFLINE   OFFLINE
ora.ons        ora.ons.type   ONLINE    ONLINE    rac1
ora....SM1.asm application    ONLINE    ONLINE    rac1
ora....C1.lsnr application    ONLINE    ONLINE    rac1
ora.rac1.gsd   application    OFFLINE   OFFLINE
ora.rac1.ons   application    ONLINE    ONLINE    rac1
ora.rac1.vip   ora....t1.type ONLINE    ONLINE    rac1
ora....SM2.asm application    ONLINE    ONLINE    rac2
ora....C2.lsnr application    ONLINE    ONLINE    rac2
ora.rac2.gsd   application    OFFLINE   OFFLINE
ora.rac2.ons   application    ONLINE    ONLINE    rac2
ora.rac2.vip   ora....t1.type ONLINE    ONLINE    rac2
ora.racdb.db   ora....se.type ONLINE    ONLINE    rac1
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    rac2

 

# 실시간 RAC 상태 조회
watch -n 1(초)

[oracle@rac1 ~]$ watch -n 1 'crs_stat -t'

Every 1.0s: crs_stat -t                                 Wed Mar  6 09:58:15 2024

Name           Type           Target    State     Host
------------------------------------------------------------
ora.DATA.dg    ora....up.type ONLINE    ONLINE    rac1
ora.FRA.dg     ora....up.type ONLINE    ONLINE    rac1
ora....ER.lsnr ora....er.type ONLINE    ONLINE    rac1
ora....N1.lsnr ora....er.type ONLINE    ONLINE    rac2
ora.asm        ora.asm.type   ONLINE    ONLINE    rac1
ora.eons       ora.eons.type  ONLINE    ONLINE    rac1
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE
ora....network ora....rk.type ONLINE    ONLINE    rac1
ora.oc4j       ora.oc4j.type  OFFLINE   OFFLINE
ora.ons        ora.ons.type   ONLINE    ONLINE    rac1
ora....SM1.asm application    ONLINE    ONLINE    rac1
ora....C1.lsnr application    ONLINE    ONLINE    rac1
ora.rac1.gsd   application    OFFLINE   OFFLINE
ora.rac1.ons   application    ONLINE    ONLINE    rac1
ora.rac1.vip   ora....t1.type ONLINE    ONLINE    rac1
ora....SM2.asm application    ONLINE    ONLINE    rac2
ora....C2.lsnr application    ONLINE    ONLINE    rac2
ora.rac2.gsd   application    OFFLINE   OFFLINE
ora.rac2.ons   application    ONLINE    ONLINE    rac2
ora.rac2.vip   ora....t1.type ONLINE    ONLINE    rac2
ora.racdb.db   ora....se.type ONLINE    ONLINE    rac1
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    rac2

> 1초마다 갱신되고 있다.
> 화면 나가기 ctrl + c
> 오프라인 상태는 9c까지 사용하던 기능으로 지금은 사용하지 않는다.(잔재)

 

# 현재 RAC 상태 확인 - 2
crsctl stat res -t

[oracle@rac1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       rac1
               ONLINE  ONLINE       rac2
ora.FRA.dg
               ONLINE  ONLINE       rac1
               ONLINE  ONLINE       rac2
ora.LISTENER.lsnr
               ONLINE  ONLINE       rac1
               ONLINE  ONLINE       rac2
ora.asm
               ONLINE  ONLINE       rac1                     Started
               ONLINE  ONLINE       rac2                     Started
ora.eons
               ONLINE  ONLINE       rac1
               ONLINE  ONLINE       rac2
ora.gsd
               OFFLINE OFFLINE      rac1
               OFFLINE OFFLINE      rac2
ora.net1.network
               ONLINE  ONLINE       rac1
               ONLINE  ONLINE       rac2
ora.ons
               ONLINE  ONLINE       rac1
               ONLINE  ONLINE       rac2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       rac2
ora.oc4j
      1        OFFLINE OFFLINE
ora.rac1.vip
      1        ONLINE  ONLINE       rac1
ora.rac2.vip
      1        ONLINE  ONLINE       rac2
ora.racdb.db
      1        ONLINE  ONLINE       rac1                     Open
      2        ONLINE  ONLINE       rac2                     Open
ora.scan1.vip
      1        ONLINE  ONLINE       rac2

 

# 데이터베이스의 상태, 인스턴스, 서비스의 상태 확인
srvctl status database -d racdb -v

[oracle@rac1 ~]$ srvctl status database -d racdb -v
Instance racdb1 is running on node rac1
Instance racdb2 is running on node rac2

[oracle@rac2 ~]$ srvctl status database -d racdb -v
Instance racdb1 is running on node rac1
Instance racdb2 is running on node rac2

> not running : DB 내려갔다

 

# 특정 인스턴스의 상태 확인
srvctl status instance -d racdb -i racdb1

[oracle@rac1 ~]$ srvctl status instance -d racdb -i racdb1
Instance racdb1 is running on node rac1


[oracle@rac1 ~]$ srvctl status instance -d racdb -i racdb2
Instance racdb2 is running on node rac2


[oracle@rac1 ~]$ srvctl status instance -d racdb -i racdb1,racdb2
Instance racdb1 is running on node rac1
Instance racdb2 is running on node rac2

> 다수 인스턴스 검색 시 ,(콤마) 사이에 공백 제외

 

# 모든 node 상태 확인
srvctl status nodeapps

[oracle@rac1 ~]$ srvctl status nodeapps
VIP rac1-vip is enabled
VIP rac1-vip is running on node: rac1
VIP rac2-vip is enabled
VIP rac2-vip is running on node: rac2
Network is enabled
Network is running on node: rac1
Network is running on node: rac2
GSD is disabled		-- 현재는 GSD 미사용
GSD is not running on node: rac1
GSD is not running on node: rac2
ONS is enabled
ONS daemon is running on node: rac1
ONS daemon is running on node: rac2
eONS is enabled
eONS daemon is running on node: rac1
eONS daemon is running on node: rac2

 

 

# RAC 중단
- RAC를 설치하면 여러가지 관련 서비스들과 Application, Instance가 복합적으로 동작을 하게된다.
- RAC를 중단할 때는 순서가 아주 중요하다.
- srvctl 명령을 사용하여 instance -> asm -> applicatin 순서로 종료한다.

1. instance 종료
srvctl stop instance -d racdb -i racdb1
srvctl stop instance -d racdb -i racdb2

2. asm 종료
srvctl stop asm -n rac1
srvctl stop asm -n rac2

3. application  종료
srvctl stop nodeapps -n racdb1
srvctl stop nodeapps -n racdb2

1, 2, 3 작업을 한번에 해주는 명령어
crs_stop -all

> 1개 노드에서만 작업하면 된다
> 다른 노드에서 watch -n 1 'crs_stat -t' 실행하면 실시간 상태 확인이 가능하다.

[oracle@rac1 ~]$ crs_stop -all
CRS-2500: Cannot stop resource 'ora.gsd' as it is not running
CRS-2500: Cannot stop resource 'ora.oc4j' as it is not running
Attempting to stop `ora.ons` on member `rac2`
Attempting to stop `ora.ons` on member `rac1`
Attempting to stop `ora.LISTENER.lsnr` on member `rac1`
Attempting to stop `ora.eons` on member `rac1`
Attempting to stop `ora.DATA.dg` on member `rac1`
Attempting to stop `ora.FRA.dg` on member `rac1`
Attempting to stop `ora.racdb.db` on member `rac1`
Attempting to stop `ora.eons` on member `rac2`
CRS-2789: Cannot stop resource 'ora.gsd' as it is not running on server 'rac1'
Attempting to stop `ora.DATA.dg` on member `rac2`
Attempting to stop `ora.FRA.dg` on member `rac2`
Attempting to stop `ora.racdb.db` on member `rac2`
CRS-2789: Cannot stop resource 'ora.gsd' as it is not running on server 'rac2'
Stop of `ora.ons` on member `rac1` succeeded.
CRS-2789: Cannot stop resource 'ora.ons' as it is not running on server 'rac1'
Stop of `ora.ons` on member `rac2` succeeded.
Attempting to stop `ora.LISTENER.lsnr` on member `rac2`
Attempting to stop `ora.LISTENER_SCAN1.lsnr` on member `rac2`
Stop of `ora.LISTENER.lsnr` on member `rac1` succeeded.
CRS-2789: Cannot stop resource 'ora.LISTENER.lsnr' as it is not running on server 'rac1'
Attempting to stop `ora.rac1.vip` on member `rac1`
Stop of `ora.rac1.vip` on member `rac1` succeeded.
Attempting to stop `ora.net1.network` on member `rac1`
Stop of `ora.net1.network` on member `rac1` succeeded.
Stop of `ora.LISTENER_SCAN1.lsnr` on member `rac2` succeeded.
Attempting to stop `ora.scan1.vip` on member `rac2`
Stop of `ora.LISTENER.lsnr` on member `rac2` succeeded.
CRS-2789: Cannot stop resource 'ora.LISTENER.lsnr' as it is not running on server 'rac2'
Attempting to stop `ora.rac2.vip` on member `rac2`
Stop of `ora.rac2.vip` on member `rac2` succeeded.
Stop of `ora.scan1.vip` on member `rac2` succeeded.
Attempting to stop `ora.net1.network` on member `rac2`
Stop of `ora.net1.network` on member `rac2` succeeded.
Stop of `ora.eons` on member `rac1` succeeded.
Stop of `ora.eons` on member `rac2` succeeded.
Stop of `ora.racdb.db` on member `rac1` succeeded.
Stop of `ora.racdb.db` on member `rac2` succeeded.
CRS-0216: Could not stop resource 'ora.LISTENER.lsnr rac1 1'.
CRS-0216: Could not stop resource 'ora.LISTENER.lsnr rac2 1'.
CRS-0216: Could not stop resource 'ora.asm rac1 1'.
CRS-0216: Could not stop resource 'ora.asm rac2 1'.
CRS-0216: Could not stop resource 'ora.gsd'.
CRS-0216: Could not stop resource 'ora.gsd rac1 1'.
CRS-0216: Could not stop resource 'ora.gsd rac2 1'.
CRS-0216: Could not stop resource 'ora.oc4j'.
CRS-0216: Could not stop resource 'ora.ons rac1 1'.

> not stop ...  지금은 미사용 기능이다.

 

# RAC 시작
srvctl 명령을 사용하여 applicatin -> asm -> instance 순서로 종료한다.

1. application  시작
srvctl start nodeapps -n racdb1
srvctl start nodeapps -n racdb2

2. asm 시작
srvctl start asm -n rac1
srvctl start asm -n rac2

3. instance 시작
srvctl start instance -d racdb -i racdb1
srvctl start instance -d racdb -i racdb2

1,2,3 작업을 한번에 해주는 명령어(1개 노드에서만 작업하면 된다.)
crs_start -all

[oracle@rac1 ~]$ crs_start -all
CRS-2501: Resource 'ora.gsd' is disabled
CRS-2501: Resource 'ora.oc4j' is disabled
CRS-2501: Resource 'ora.gsd' is disabled
CRS-2501: Resource 'ora.gsd' is disabled
CRS-2664: Resource 'ora.asm' is already running on 'rac1'
Attempting to start `ora.net1.network` on member `rac1`
CRS-2664: Resource 'ora.asm' is already running on 'rac2'
Start of `ora.net1.network` on member `rac1` succeeded.
Attempting to start `ora.ons` on member `rac1`
Start of `ora.ons` on member `rac1` succeeded.
Attempting to start `ora.eons` on member `rac1`
Attempting to start `ora.eons` on member `rac2`
Attempting to start `ora.rac1.vip` on member `rac1`
Attempting to start `ora.net1.network` on member `rac2`
Start of `ora.net1.network` on member `rac2` succeeded.
Start of `ora.eons` on member `rac2` succeeded.
Start of `ora.eons` on member `rac1` succeeded.
Start of `ora.rac1.vip` on member `rac1` succeeded.
Attempting to start `ora.LISTENER.lsnr` on member `rac1`
Attempting to start `ora.ons` on member `rac2`
Start of `ora.LISTENER.lsnr` on member `rac1` succeeded.
Attempting to start `ora.scan1.vip` on member `rac2`
Start of `ora.ons` on member `rac2` succeeded.
Start of `ora.scan1.vip` on member `rac2` succeeded.
Attempting to start `ora.LISTENER_SCAN1.lsnr` on member `rac2`
Start of `ora.LISTENER_SCAN1.lsnr` on member `rac2` succeeded.
Attempting to start `ora.rac2.vip` on member `rac2`
Attempting to start `ora.racdb.db` on member `rac1`
Start of `ora.rac2.vip` on member `rac2` succeeded.
Attempting to start `ora.LISTENER.lsnr` on member `rac2`
Start of `ora.LISTENER.lsnr` on member `rac2` succeeded.
Attempting to start `ora.racdb.db` on member `rac2`
Start of `ora.racdb.db` on member `rac2` succeeded.
Start of `ora.racdb.db` on member `rac1` succeeded.
CRS-2660: Resource 'ora.gsd' or all of its instances are disabled
CRS-2660: Resource 'ora.oc4j' or all of its instances are disabled
CRS-2660: Resource 'ora.rac1.gsd' or all of its instances are disabled
CRS-2660: Resource 'ora.rac2.gsd' or all of its instances are disabled


--- 정상 접속 확인
[oracle@rac1 ~]$ . oraenv
ORACLE_SID = [racdb1] ?
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 is /u01/app/oracle

[oracle@rac2 ~]$ . oraenv
ORACLE_SID = [racdb2] ?
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 is /u01/app/oracle


[oracle@rac1 ~]$ sqlplus / as sysdba

SQL> select name from v$database;
NAME
---------
RACDB

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
racdb1

 


 

■ RAC(Real Application Cluster)
- 동일한 데이터베이스에 대해 여러 instance를 실행하여 클러스터된 하드웨어를 사용할 수 있도록하는 소프트웨어이다.
- 데이터베이스 파일은 각 노드에 물리적 또는 논리적으로 연결된 디스크에 저장되므로 모든 활성 instacne에서 읽고 쓸 수 있다.

 

■ RAC 장점
1. 고가용성 : 24시간 끊김없는 서비스를 지원받을 수 있다.
            즉, 접속한 서버가 다운되었거나 인스턴스가 종료되어도 다른 서버에서 계속 서비스를 지원받을 수 있다.

2. 확장성 : 노드들을 계속 추가하면서 확장해 나갈 수 있다.
            노드의 갯수는 이론적으로 100개까지 가능하다.

 

■ RAC 구조
1. Public Network(공용 네트워크)
- Public IP
- 외부의 클라이언트들이 노드로 접속할 때 사용하는 ip

2. Private Interconnect(전용 인터커넥트)
- Private IP
- 노드간의 통신을 하기 위해서 사용하는 ip

3. Virtual IP
- failover를 지원하기 위해서 사용하는 ip

[oracle@rac1 ~]$ cat /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

## Public	-- 외부에서 접속, Putty
192.168.56.101 rac1
192.168.56.102 rac2

## Private	-- 절대 내부용
192.168.55.101 rac1-priv
192.168.55.102 rac2-priv

## Virtual	-- Public에서 파생, Client, failover 발생 시
192.168.56.111 rac1-vip
192.168.56.112 rac2-vip

## Grid Scan	-- Public에서 파생
192.168.56.120 rac-scan


4. 공유 스토리지(Shared Storage)

- 여러 노드가 데이터를 공유하기 위해서 공유 스토리지를 사용한다.
- 각 노드는 SAN(Storage Area Network) 스위치를 통해 스토리지와 통신한다.(허브역할)

- 로 디바이스(Raw Device)
    - 파일 시스템을 사용하지 않은 원시적인 형태의 디바이스를 의미한다.
    - 로 디바이스를 사용하는 경우에는 별도의 파일 시스템 없이 디스크를 직접 액세스한다.
    - 장점 : 쓰기 속도가 빠르다.
    - 단점 : 관리가 어렵다.
            (일반적인 cp, mv  이런 명령어 사용이 안된다)

- 클러스터 파일 시스템(Clusterd File System)
    - 로 디바이스의 불편함 즉 파일시스템을 사용할 수 없다는 단점으로 인해 클러스터 파일 시스템을 채택하는 
      경우가 많다.
    - 장점 : 관리가 쉽다.
    - 단점 : 비용이 많이 들고 잘깨진다.
    - veritas

- ASM(Automatic Storage Management)
    - 오라클 10g NF
    - 자동화 로드맵 중 스토리지에 대한 구현 제공
    - 스트라이핑, 미러링, 백업, 복구에 필요한 모든 기능 제공
    - 로 디바이스와 클러스터 파일 시스템의 장점인 볼륨 매니저 기능 제공
    - 장점 : OS의 RAID 기법을 구성하지 않고 오라클이 알아서 RAID 0+1의 스트라이핑과 미러링을 알아서 지원한다.
    - 단점 : 초창기 버전에서는 안정성이 떨어져 BUG에 대한 FIX를 해야할 일이 많았다.

> 볼륨 매니저 : 서로 다른 디스크를 논리적으로 묶어 하나로 사용가능하게 만드는 기능
                1GB + 5GB = 6GB

> RAID 0+1을 사용하면 디스크 그룹 고장이 아닌이상 어떻게든 복구 가능하다.
    - RAID 0 : 스트라이핑, extent가 디스크 그룹에 흩어져 저장
    - RAID 1 : 미러링(복제)

 

# cluster
여러대의 서버(노드)를 마치 하나의 서버(노드)처럼 보이게 하는 소프트웨어를 클러스터 소프트웨어라고 한다.
9i버전까지는 OS의 클러스터 소프트웨어 서비스를 이용해야한다.

IBM : HACMP(High Availability Cluster MultiProcessing)
HP  : HP-serviceGuard
SUN : SUN Cluster

오라클 10g 버전부터 oracle cluster 소프트웨어를 지원(grid)

 


 

■ OCR(Oracle Cluster Repository)
- RAC 구성의 전체 정보를 저장하고 있는 디스크로 RAC에서의 핵심 역할을 담당한다.
- RAC를 시작하려면 OCR에 저장되어있는 정보를 보고 RAC를 구성해야하는데 10g RAC까지는 RAC 시작 후 
  ASM instance를 시작하기 때문에 OCR을 ASM에 저장할 경우 RAC를 시작할 수 없게 되었다. 
  단, 11g에서는 이 부분이 개선되어 ASM 디스크를 사용한다.
- OCR이 장애가 나면 RAC 전체가 중단된다.
- 오라클에서 권장하는 OCR의 최소 크기는 100MB

# OCR File 위치

[oracle@rac1 ~]$ cat /etc/oracle/ocr.loc
ocrconfig_loc=+DATA
local_only=FALSE

 

# OCR 상태 확인

[oracle@rac1 ~]$ ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       2520
         Available space (kbytes) :     259600
         ID                       :  300245879
         Device/File Name         :      +DATA
                                    Device/File integrity check succeeded

                                    Device/File not configured

                                    Device/File not configured

                                    Device/File not configured

                                    Device/File not configured

         Cluster registry integrity check succeeded

         Logical corruption check bypassed due to non-privileged user

 

# OCR 자동 백업 수행(4시간, 매일, 매주)

[oracle@rac1 ~]$ ocrconfig -showbackup
PROT-24: Auto backups for the Oracle Cluster Registry are not available
PROT-25: Manual backups for the Oracle Cluster Registry are not available

 


 

■ Vote Disk
- RAC는 여러개의 instance node들로 구성되어있으며 각 node들이 문제(split brain)가 있는지 없는지를 실시간으로
  파악하고 있어야 한다. 그래야 클라이언트들이 요청하는 서비스를 정확하게 연결해 줄 수 있기 때문이다.
- cssd 프로세스는 각 node들이 정상적으로 작동하고 있는지 interconnect를 통해 매초마다 heartbeat를 보내고 
  각 node들은 그에 대한 응답을 다시 보내어서 자신이 정상적으로 동작하고 있다는 것을 알려주는 정보를 저장한다.
- 오라클에서 권장하는 vote disk의 최소 크기는 20MB
- 11g RAC부터는 OCR과 Vote Disk 모두 ASM storage에 저장할 수 있다.

[oracle@rac1 ~]$ crsctl query css votedisk
##  STATE    File Universal Id                File Name Disk group
--  -----    -----------------                --------- ---------
 1. ONLINE   9282108203824ff0bf1659fa37157579 (/dev/oracleasm/disks/ASMDISK01) [DATA]
 2. ONLINE   342d5dc1f7174fcfbf8b1fef4886eeea (/dev/oracleasm/disks/ASMDISK02) [DATA]
 3. ONLINE   6dc334443e0c4f89bfc3a9e2ed314949 (/dev/oracleasm/disks/ASMDISK03) [DATA]
Located 3 voting disk(s).

 


■ RAC LOAD BALANCING

# 연결 상태 확인

--- host 확인
[oracle@rac1 ~]$ cat /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

## Public
192.168.56.101 rac1
192.168.56.102 rac2

## Private
192.168.55.101 rac1-priv
192.168.55.102 rac2-priv

## Virtual
192.168.56.111 rac1-vip
192.168.56.112 rac2-vip

## Grid Scan
192.168.56.120 rac-scan


--- Oracle Home 확인
[oracle@rac1 ~]$ . oraenv
ORACLE_SID = [racdb1] ?
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 is /u01/app/oracle

--- DB 접속
[oracle@rac1 ~]$ sqlplus / as sysdba


SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
racdb1           OPEN



--- RAC2에서도 DB 접속 확인

[oracle@rac2 ~]$ . oraenv
ORACLE_SID = [racdb2] ?
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 is /u01/app/oracle

[oracle@rac2 ~]$ sqlplus / as sysdba


SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
racdb2           OPEN

 

# 전체 노드 한번에 보기
gv$instance

SQL> select instance_name, status from gv$instance;

INSTANCE_NAME    STATUS
---------------- ------------
racdb2           OPEN
racdb1           OPEN

 

# Listener 상태

[oracle@rac1 ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 06-MAR-2024 14:48:45

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                06-MAR-2024 13:21:39
Uptime                    0 days 1 hr. 27 min. 5 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/11.2.0/grid/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/rac1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.101)(PORT=1521)))  -- Public ip
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.111)(PORT=1521)))  -- Virtual ip
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "racdb" has 1 instance(s).
  Instance "racdb1", status READY, has 1 handler(s) for this service...
Service "racdbXDB" has 1 instance(s).
  Instance "racdb1", status READY, has 1 handler(s) for this service...
The command completed successfully

> Grid s/w 설치 시 자동 구성되어 listener.ora 파일이 grid 디렉터리에 위치하고 있다.

 

# Client(외부) > Node 접속

--- Client > Windows > 탐색기

--- tnsnames.ora : TNS 구성
C:\oraclexe\app\oracle\product\11.2.0\server\network\ADMIN\tnsnames.ora

racdb =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.111)(PORT = 1521))   -- Virtual ip rac1
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.112)(PORT = 1521))   -- Virtual ip rac2
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = racdb)
    )
  )

: 추가 후 저장



--- Client > Windows > cmd session 1

C:\> sqlplus sys/oracle@racdb as sysdba
...
Connected to:
Oracle Database 11g Release 11.2.0.1.0 - Production
With the Real Application Clusters and Automatic Storage Management options

SQL> select instance_name,status from v$instance;

INSTANCE_NAME                    STATUS
-------------------------------- ------------------------
racdb1                           OPEN



--- Client > Windows > cmd session 2

C:\>sqlplus sys/oracle@racdb as sysdba


SQL> select instance_name,status from v$instance;

INSTANCE_NAME                    STATUS
-------------------------------- ------------------------
racdb1                           OPEN

> 계속 1번 node만 접속되고 있다.
> TNS 정보에 첫번째 address에 해당하는 ip 주소가 접속하는데 우선권이 높다.

 

# Client(외부) > Node 접속 + TNS 구성 : (LOAD_BALANCE=YES)

--- Client > Windows > 탐색기

--- tnsnames.ora : TNS 구성
C:\oraclexe\app\oracle\product\11.2.0\server\network\ADMIN\tnsnames.ora

racdb =
  (DESCRIPTION =
    (LOAD_BALANCE=YES)
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.111)(PORT = 1521))   -- Virtual ip rac1
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.112)(PORT = 1521))   -- Virtual ip rac2
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = racdb)
    )
  )

: 수정 후 저장



--- Client > Windows > cmd session 1

C:\>sqlplus sys/oracle@racdb as sysdba


SQL> select instance_name,status from v$instance;

INSTANCE_NAME                    STATUS
-------------------------------- ------------------------
racdb1                           OPEN



--- Client > Windows > cmd session 2

C:\>sqlplus sys/oracle@racdb as sysdba


SQL> select instance_name,status from v$instance;

INSTANCE_NAME                    STATUS
-------------------------------- ------------------------
racdb2                           OPEN

> 계속 반복해보면 racdb1, racdb2 노드를 랜덤으로 접속하고 있다.

 

# Client > 특정 노드에만 접속 수행

--- Client > Windows > 탐색기

--- tnsnames.ora : TNS 구성
C:\oraclexe\app\oracle\product\11.2.0\server\network\ADMIN\tnsnames.ora

racdb =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.112)(PORT = 1521))   -- Virtual ip
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = racdb)
    )
  )

> 업무팀별로 1개 노드로만 접속을 제한하는 경우도 있다.
    - 실행계획, block 등에 성능저하 방지

 

# CTF(Connect Time Failover)

--- Client > Windows > 탐색기

--- tnsnames.ora : TNS 구성
C:\oraclexe\app\oracle\product\11.2.0\server\network\ADMIN\tnsnames.ora

racdb =
  (DESCRIPTION =
    (LOAD_BALANCE=YES)
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.111)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.112)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = racdb)
    )
  )


--- Client > Windows > cmd session

C:\>sqlplus sys/oracle@racdb as sysdba

SQL> select instance_name,status from v$instance;

INSTANCE_NAME                    STATUS
-------------------------------- ------------------------
racdb1                           OPEN

SQL> select * from all_objects;     -- Long Query
...

↓ 작업 중 racdb1 장애 발생


--- Putty > server session (rac1, rac2 무관)

[oracle@rac2 ~]$ srvctl stop instance -d racdb -i racdb1


--- Client > Windows > cmd session

...
ERROR:
ORA-01089: 즉시 종료 중입니다 - 작업이 허용되지 않습니다
Process ID: 8538
Session ID: 155 Serial number: 107


SQL> exit

C:\>sqlplus sys/oracle@racdb as sysdba


SQL> select instance_name,status from v$instance;

INSTANCE_NAME                    STATUS
-------------------------------- ------------------------
racdb2                           OPEN

> racdb1 노드가 내려가면서 작업도 중단.
> 해당 세션에서 나와 재접속하면 racdb2에 접속 가능

--- Putty > server session

--- racdb1, racdb2 상태 확인
[oracle@rac2 ~]$ srvctl status instance -d racdb -i racdb1,racdb2
Instance racdb1 is not running on node rac1
Instance racdb2 is running on node rac2

--- racdb1 시작
[oracle@rac2 ~]$ srvctl start instance -d racdb -i racdb1

[oracle@rac2 ~]$ srvctl status instance -d racdb -i racdb1,racdb2
Instance racdb1 is running on node rac1
Instance racdb2 is running on node rac2


--- Client > Windows > cmd session

C:\>sqlplus sys/oracle@racdb as sysdba


SYS@racdb> select instance_name,status from gv$instance;

INSTANCE_NAME                    STATUS
-------------------------------- ------------------------
racdb1                           OPEN
racdb2                           OPEN

 

 

# TAF(Transparent Application Failover)
  (DESCRIPTION =
    (FAILOVER=YES)
    
    (CONNECT_DATA =
      (FAILOVER_MODE=(TYPE=SESSION)(METHOD=BASIC))
    )
  )

# FAILOVER_MODE = (TYPE= ?)
- NODE     : 그냥 실패가 된다. 세션이 끊어지기 때문에 새롭게 다시 접속해야한다. CTF와 비슷하다.
- SESSIION : 접속한 노드의 인스턴스가 내려가면서 수행하고있는 SQL문은 취소가 되고 살아있는 인스턴스로 자동으로
             접속된다.
- SELECT   : 접속한 노드의 인스턴스가 내려가면서 수행하고있는 SELECT문이 다른 살아있는 인스턴스로 자동으로 
             접속해서 수행된다.

# (METHOD=BASIC)
- 장애가 발생할 경우 다른 서버를 찾아서 접속을 시도하는 방식

 

# (FAILOVER_MODE=(TYPE=SESSION)(METHOD=BASIC)) 방식

--- Client > Windows > 탐색기

--- tnsnames.ora : TNS 구성
C:\oraclexe\app\oracle\product\11.2.0\server\network\ADMIN\tnsnames.ora

racdb_taf =
  (DESCRIPTION =
    (LOAD_BALANCE=YES)(FAILOVER=YES)
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.111)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.112)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = racdb)
      (FAILOVER_MODE=(TYPE=SESSION)(METHOD=BASIC))
    )
  )


--- Client > Windows > cmd session

C:\>sqlplus sys/oracle@racdb_taf as sysdba


SQL> select instance_name,status from v$instance;

INSTANCE_NAME                    STATUS
-------------------------------- ------------------------
racdb2                           OPEN


SQL> select * from dba_objects;
...

↓ 작업 중 racdb1 장애 발생


--- Putty > server session

[oracle@rac2 ~]$ srvctl stop instance -d racdb -i racdb2


--- Client > Windows > cmd session

...
ERROR:
ORA-25401: can not continue fetches

SQL> select instance_name,status from v$instance;

INSTANCE_NAME                    STATUS
-------------------------------- ------------------------
racdb1                           OPEN

> racdb2 인스턴스가 내려가면서 쿼리문장은 실패되었지만, 자동으로 살아있는 인스턴스로 접속이 진행되었다.

--- Putty > server session

--- racdb1 시작
[oracle@rac2 ~]$ srvctl start instance -d racdb -i racdb2

[oracle@rac2 ~]$ srvctl status instance -d racdb -i racdb1,racdb2
Instance racdb1 is running on node rac1
Instance racdb2 is running on node rac2

 

 

# (FAILOVER_MODE=(TYPE=SELECT)(METHOD=BASIC)) 방식

--- Client > Windows > 탐색기

--- tnsnames.ora : TNS 구성
C:\oraclexe\app\oracle\product\11.2.0\server\network\ADMIN\tnsnames.ora

racdb_taf =
  (DESCRIPTION =
    (LOAD_BALANCE=YES)(FAILOVER=YES)
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.111)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.112)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = racdb)
      (FAILOVER_MODE=(TYPE=SELECT)(METHOD=BASIC))
    )
  )


--- Client > Windows > cmd session

C:\>sqlplus sys/oracle@racdb_taf as sysdba


SQL> select instance_name,status from v$instance;

INSTANCE_NAME                    STATUS
-------------------------------- ------------------------
racdb1                           OPEN


SQL> select * from all_objects;
...

↓ 작업 중 racdb1 장애 발생


--- Putty > server session

[oracle@rac2 ~]$ srvctl stop instance -d racdb -i racdb1


--- Client > Windows > cmd session

...
select문이 잠깐 멈추더니 계속 실행
...
71402 rows selected.

SQL> select instance_name,status from v$instance;

INSTANCE_NAME                    STATUS
-------------------------------- ------------------------
racdb2                           OPEN

> SELECT문에 한하여 노드가 고장나도 다른 노드로 옮겨 실행한다.

--- Putty > server session

[oracle@rac2 ~]$ srvctl status instance -d racdb -i racdb1,racdb2
Instance racdb1 is not running on node rac1
Instance racdb2 is running on node rac2

--- racdb1 시작
[oracle@rac2 ~]$ srvctl start instance -d racdb -i racdb1

[oracle@rac2 ~]$ srvctl status instance -d racdb -i racdb1,racdb2
Instance racdb1 is running on node rac1
Instance racdb2 is running on node rac2

 

'Oracle 11g > RAC' 카테고리의 다른 글

100 RAC  (1) 2024.03.08
99 RAC GRD, Cache Fusion  (1) 2024.03.07
97-3 Oracle S/W, ASM Disk Group, RAC용 DB 설치  (0) 2024.03.05
96-2 그리드 삭제 후 설치 시  (0) 2024.03.04
96-1 Grid 11g 설치  (3) 2024.03.04