노드 오픈
(퍼티에서 192.168.56.101 / 192.168.56.102 둘 다로 접속하기)
# 오라클 계정으로 가기
[root@rac1 ~]# su - oracle
[root@rac2 ~]# su - oracle
# 현재 RAC 상태 체크하기
[oracle@rac1 ~]$ crs_stat -t
[oracle@rac2 ~]$ crs_stat -t
(한쪽 노드에서만 해도 됨, 어차피 한쪽 노드가 내려가 있으면
다른 쪽 노드에서 저 명령어를 수행해도 안 먹힌다.)
rac1 창에서 수행
rac2 창에서 수행
# 현재 RAC 상태를 실시간으로 조회하고 싶을 때
# 특정한 명령어 모니터링하기
[oracle@rac1 ~]$ watch -n 1 'crs_stat -t'
'crs_stat -t' 라는 명령어를 1초마다 한 번씩 던지고 모니터링:
오른쪽 위에 디지털 시계가 하나 생기면서 진짜 시계가 돌아가듯 1초씩 늘어난다.
(1초에 한 번씩 crs_stat -t 를 수행하는 것, 빠져나오고 싶으면 ctrl + c)
ctrl+c 해서 빠져나옴.
와중에 저기서 오프라인으로 되어 있는 것들 : 쓰지 않는 것들
(뭔가 문제가 발생하지는 않음, 그냥 잔재만 남아있는 것)
# 현재 RAC 상태를 보는 또다른 기능 : 아까랑 비슷한데 구분이 되어 있다는 점이 다르다.
[oracle@rac1 ~]$ crsctl stat res -t
# 데이터베이스의 상태, 인스턴스, 서비스 상태 정보 보기
[oracle@rac1 ~]$ srvctl status database -d racdb -v
(-v 는 출력 옵션, 현재 노드들이 어떻게 떠 있는지를 보여준다.)
running 은 올라와 있는 거고 not running 은 내려가 있는 것
(QUESTION. 난 이거 왜 한쪽만 뜨고 한쪽은 안떠?)
(ANSWER. 이거 설정이 뭔가 잘못된 거... 둘다 떠야 정상, 다른 화면들도 저렇게 뜨면 안됨
몽땅 비정상... 다시 수행해서 스크린샷 다시 붙여넣기)
첫번째 수행했을 때는 이렇게 나옴... 이렇게 나오면 뭔가 잘못된 것
두번째 수행했을 때처럼 이렇게 나와야 정상
만약 첫번째 수행 화면처럼 나온다면?
해결책
RAC 가상머신 복제파일을 실행했는데 상태가 이상할 때 해결책
1. 필요한 파일 다운로드
2. 맨 처음에 가상머신 만들 때 지정한 폴더 (나는 D 드라이브 아래 oracle_rac11g 폴더) 로 들어가서
grid 라는 이름의 새 폴더 만들고 > 거기다 asm_disk1, 2, 3, 4, 5, 6 파일 몽땅 옮기기
(시간이 어마어마하게 많이 걸림...)
3. 다 되면 > rac1, rac2 복제파일 실행 > rac1, rac2 설치
4. 도구 > 미디어 > grid 폴더에 있는 6개 파일 추가 버튼 눌러서 하나씩 추가
5. rac1 > 설정 > 저장소 > 컨트롤러 sATA 아래 있는 파일들 용량과 이름 확인 > 5G 짜리 6개 삭제
> 컨트롤러 sata 옆 맨 오른쪽 아이콘 눌러서 6개 추가 asm_disk 1, 2, 3, 4, 5, 6 > 확인버튼 누르기
6. rac2 에서도 5번 과정 반복 > 확인
7. 가상머신 rac1, rac2 실행 > 둘이 서로 호환되는지 체크하기
# 특정 인스턴스의 상태만 확인하기
rac1 의 상태만 확인해보자.
[oracle@rac1 ~]$ srvctl status instance -d racdb -i racdb1
Instance racdb1 is running on node rac1
# rac1 과 rac2 한꺼번에 확인하기
srvctl status instance -d racdb -i racdb1,racdb2
(racdb1,과 racdb2 사이에 띄어쓰기를 안해야 정상적으로 수행된다. 쉼표 하고 띄어쓰기하면 오류 남)
[oracle@rac1 ~]$ srvctl status instance -d racdb -i racdb1,racdb2
Instance racdb1 is running on node rac1
Instance racdb2 is running on node rac2
모든 노드 상태 확인
[oracle@rac1 ~]$ srvctl status nodeapps
rac2에서도 확인해보기
# RAC 중단
RAC 를 설치하면 여러 가지 관련 서비스들과 Application, Instance가 복합적으로 동작하게 된다.
그래서 RAC 를 중단할 때는 순서가 매우 중요하다.
# srvctl 명령을 사용하여 중단
순서는 instance 내리기 > ASM 내리기 > application 내리기
그런데 단계별로 내리자니 너무 힘들다.
그래서 저 모든 단계를 한꺼번에 수행하는데
지금은 각각의 단계에서 쓰는 명령어부터 배워보자.
(배우기만 하고 실제로 수행하지는 않음)
1. 양쪽 모두에서 instance 종료
srvctl stop instance -d racdb -i rac1
srvctl stop instance -d racdb -i rac2
2. ASM 종료
srvctl stop asm -n rac1
srvctl stop asm -n rac2
3. 어플리케이션 내리기
srvctl stop nodeapps -n rac1
srvctl stop nodeapps -n rac2
1, 2, 3 작업을 한꺼번에 해주는 명령어는
crs_stop -all
한번 수행해보면 (한쪽에서만 수행하면 됨)
[oracle@rac1 ~]$ crs_stop -all
[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.LISTENER.lsnr` on member `rac2`
Attempting to stop `ora.LISTENER_SCAN1.lsnr` on member `rac2`
Attempting to stop `ora.LISTENER.lsnr` on member `rac1`
Attempting to stop `ora.ons` on member `rac1`
Attempting to stop `ora.eons` on member `rac1`
CRS-2789: Cannot stop resource 'ora.gsd' as it is not running on server 'rac1'
CRS-2789: Cannot stop resource 'ora.gsd' as it is not running on server 'rac2'
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`
Attempting to stop `ora.eons` on member `rac2`
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`
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.LISTENER_SCAN1.lsnr` on member `rac2` succeeded.
Attempting to stop `ora.scan1.vip` on member `rac2`
Stop of `ora.rac2.vip` on member `rac2` succeeded.
Stop of `ora.scan1.vip` on member `rac2` succeeded.
Stop of `ora.ons` on member `rac2` succeeded.
CRS-2789: Cannot stop resource 'ora.ons' as it is not running on server 'rac2'
Attempting to stop `ora.net1.network` on member `rac2`
Stop of `ora.net1.network` on member `rac2` succeeded.
Stop of `ora.LISTENER.lsnr` on member `rac1` succeeded.
Stop of `ora.ons` on member `rac1` succeeded.
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.eons` on member `rac2` succeeded.
Stop of `ora.eons` on member `rac1` succeeded.
Attempting to stop `ora.asm` on member `rac2`
Attempting to stop `ora.asm` on member `rac1`
CRS-2673: Attempting to stop 'ora.asm' on 'rac2'
ORA-15097: cannot SHUTDOWN ASM instance with connected client
CRS-2675: Stop of 'ora.asm' on 'rac2' failed
CRS-2673: Attempting to stop 'ora.asm' on 'rac1'
ORA-15097: cannot SHUTDOWN ASM instance with connected client
CRS-2675: Stop of 'ora.asm' on 'rac1' failed
Stop of `ora.racdb.db` on member `rac2` succeeded.
Stop of `ora.racdb.db` on member `rac1` succeeded.
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 rac2 1'.
현재 상태 확인하기
[oracle@rac1 ~]$ srvctl status instance -d racdb -i racdb1,racdb2
Instance racdb1 is not running on node rac1
Instance racdb2 is not running on node rac2
맨 끝에 CRS-0216 어쩌고 나오는 거 선생님도 똑같이 뜨심. 만치에도...
(그런데 얘네는 그냥 무시하면 된다고 하심. 없어진 것들이라서 저런 메시지가 뜬 거라고 함...)
# RAC 시작하기
중단 순서가 instance > ASM > application 이었으므로
시작 순서는 application > ASM > instance
(1, 2, 3 은 실제로 수행하지는 않음... 그냥 구경만)
1. 양쪽 모두에서 instance 시작
srvctl start nodeapps -n racdb1
srvctl start nodeapps -n racdb2
2. ASM 시작
srvctl start asm -n rac1
srvctl start asm -n rac2
3. 어플리케이션 올리기
srvctl start instance -d racdb -i racdb1
srvctl start instance -d racdb -i racdb2
1, 2, 3 작업을 한번에 해주는 명령어: crs_start -all
(이것도 rac1 이나 rac2 둘 중 한쪽에서만 수행하기)
crs_start -all 명령어 수행하기 전에 먼저
현재 상태 정보 보기
[oracle@rac1 ~]$ crs_stat -t
몽땅 다 (다는 아닌데 거의 대부분) 오프라인 상태라고 나온다.
crs_start -all 명령어 수행 (한쪽 노드에서만)
[oracle@rac1 ~]$ crs_start -all
시간이 꽤나 걸린다...
[oracle@rac1 ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.DATA.dg ora....up.type OFFLINE ONLINE rac2
ora.FRA.dg ora....up.type OFFLINE ONLINE rac2
ora....ER.lsnr ora....er.type OFFLINE OFFLINE
ora....N1.lsnr ora....er.type OFFLINE OFFLINE
ora.asm ora.asm.type OFFLINE ONLINE rac2
ora.eons ora.eons.type OFFLINE OFFLINE
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type OFFLINE OFFLINE
ora.oc4j ora.oc4j.type OFFLINE OFFLINE
ora.ons ora.ons.type OFFLINE OFFLINE
ora....SM1.asm application OFFLINE ONLINE rac1
ora....C1.lsnr application OFFLINE OFFLINE
ora.rac1.gsd application OFFLINE OFFLINE
ora.rac1.ons application OFFLINE OFFLINE
ora.rac1.vip ora....t1.type OFFLINE OFFLINE
ora....SM2.asm application OFFLINE ONLINE rac2
ora....C2.lsnr application OFFLINE OFFLINE
ora.rac2.gsd application OFFLINE OFFLINE
ora.rac2.ons application OFFLINE OFFLINE
ora.rac2.vip ora....t1.type OFFLINE OFFLINE
ora.racdb.db ora....se.type OFFLINE OFFLINE
ora.scan1.vip ora....ip.type OFFLINE OFFLINE
[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
Attempting to start `ora.eons` on member `rac1`
Attempting to start `ora.eons` on member `rac2`
Attempting to start `ora.net1.network` on member `rac1`
Attempting to start `ora.net1.network` on member `rac2`
CRS-2664: Resource 'ora.asm' is already running on 'rac1'
CRS-2664: Resource 'ora.asm' is already running on 'rac2'
Start of `ora.net1.network` on member `rac2` succeeded.
Attempting to start `ora.rac1.vip` on member `rac2`
Start of `ora.net1.network` on member `rac1` succeeded.
Attempting to start `ora.scan1.vip` on member `rac1`
Start of `ora.rac1.vip` on member `rac2` succeeded.
Attempting to start `ora.ons` on member `rac2`
Start of `ora.eons` on member `rac1` succeeded.
Start of `ora.eons` on member `rac2` succeeded.
Start of `ora.scan1.vip` on member `rac1` succeeded.
Attempting to start `ora.LISTENER_SCAN1.lsnr` on member `rac1`
Attempting to start `ora.ons` on member `rac1`
Start of `ora.ons` on member `rac2` succeeded.
CRS-5702: Resource 'ora.ons' is already running on 'rac2'
Start of `ora.LISTENER_SCAN1.lsnr` on member `rac1` succeeded.
Attempting to stop `ora.rac1.vip` on member `rac2`
Attempting to stop `ora.LISTENER_SCAN1.lsnr` on member `rac1`
Stop of `ora.rac1.vip` on member `rac2` succeeded.
Attempting to start `ora.rac1.vip` on member `rac1`
Stop of `ora.LISTENER_SCAN1.lsnr` on member `rac1` succeeded.
Attempting to start `ora.LISTENER_SCAN1.lsnr` on member `rac2`
Start of `ora.LISTENER_SCAN1.lsnr` on member `rac2` succeeded.
Start of `ora.ons` on member `rac1` succeeded.
CRS-5702: Resource 'ora.ons' is already running on 'rac1'
Start of `ora.rac1.vip` on member `rac1` succeeded.
Attempting to start `ora.LISTENER.lsnr` on member `rac1`
Start of `ora.LISTENER.lsnr` on member `rac1` succeeded.
CRS-5702: Resource 'ora.LISTENER.lsnr' is already running on 'rac1'
Attempting to start `ora.racdb.db` on member `rac1`
Start of `ora.racdb.db` on member `rac1` succeeded.
Attempting to start `ora.rac2.vip` on member `rac2`
Attempting to stop `ora.LISTENER_SCAN1.lsnr` on member `rac2`
Stop of `ora.LISTENER_SCAN1.lsnr` on member `rac2` succeeded.
Attempting to start `ora.LISTENER_SCAN1.lsnr` on member `rac1`
Start of `ora.LISTENER_SCAN1.lsnr` on member `rac1` succeeded.
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.
CRS-0223: Resource 'ora.LISTENER.lsnr rac1 1' has placement error.
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-0223: Resource 'ora.ons rac1 1' has placement error.
CRS-0223: Resource 'ora.ons rac2 1' has placement error.
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
# DB 접속해보기
[oracle@rac1 ~]$ db_env
[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 ~]$ db_env
[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
SQL+ 로 접속하기
[oracle@rac1 ~]$ sqlplus / as sysdba
이 명령어 뭔가 되게 오랜만이네 ㅠㅠ
SQL> select name from v$database;
NAME
--------------
RACDB
SQL> select instance_name from v$instance;
INSTANCE_NAME
---------------------------
racdb1
rac2 에서도 똑같이 해보기
[oracle@rac2 ~]$ sqlplus / as sysdba
SQL> select name from v$database;
NAME
--------------
RACDB
SQL> select instance_name from v$instance;
INSTANCE_NAME
---------------------------
racdb2
근데 나 설정에 문제 있었어...
그래서 여기서부터 또 못 따라가게 됨.
그리고 1교시 때도 제대로 따라간 것도 아님.
아...... 열받아........................ ㅡㅡ...................
(그런데 천사같은 만치에가 다 고쳐줌... ㅠㅠ 가상머신도 주고 설정도 고쳐주고
역시 만치에는 사랑이야... ♡)