본문 바로가기
★━Oracle ExaData〃/3. Oracle DB

Oracle 19c HOME 디렉토리 변경하기

by Raynee 2023. 8. 7.
반응형

Oracle DB HOME 경로 변경

  • 기존 경로 : /u01/app/oracle/product/19.0.0/dbhome_1
  • 변경 경로 : /u01/app/oracle/product/19.0.0.0/dbhome_2

Profile HOME 경로
export ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1
export ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_2

기존 DB 종료 및 tar 압축

DB 및 리스너 종료

[FLUTEDB]oracle@flute$ sqlplus / as sysdba
SQL> shutdown immediate

[FLUTEDB]oracle@flute$ lsnrctl stop

[FLUTEDB]oracle@flute$ ps -ef | grep ora
root     18489 18223  0 13:20 pts/0    00:00:00 su - oracle
oracle   18490 18489  0 13:20 pts/0    00:00:00 -bash
oracle   19393 18490  0 13:32 pts/0    00:00:00 ps -ef
oracle   19394 18490  0 13:32 pts/0    00:00:00 grep --color=auto ora

TAR로 HOME 디렉토리 압축

[FLUTEDB]oracle@flute$ cd $ORACLE_HOME
[FLUTEDB]oracle@flute$ pwd
/u01/app/oracle/product/19.0.0/dbhome_1
[FLUTEDB]oracle@flute$ tar -cvf ora_home.tar *

[FLUTEDB]oracle@flute$ ls -l ora_home.tar
-rw-r--r-- 1 oracle oinstall 7420774400 Aug  6 13:34 ora_home.tar

새로운 오라클 홈 경로 생성 후 압축 해제

[FLUTEDB]oracle@flute$ mkdir -p /u01/app/oracle/product/19.0.0.0/dbhome_2

[FLUTEDB]oracle@flute$ tar -xvf ora_home.tar -C /u01/app/oracle/product/19.0.0.0/dbhome_2

[FLUTEDB]oracle@flute$ cd /u01/app/oracle/product/19.0.0.0/dbhome_2

기존 ORACLE_HOE 경로 삭제

[FLUTEDB]oracle@flute$ cd /u01/app/oracle/product/
[FLUTEDB]oracle@flute$ ls -l
total 0
drwxr-xr-x. 3 oracle oinstall 22 Aug  4 06:35 19.0.0
drwxr-xr-x  3 oracle oinstall 22 Aug  6 13:37 19.0.0.0

[FLUTEDB]oracle@flute$ rm -rf 19.0.0
[FLUTEDB]oracle@flute$ cd 19.0.0.0/dbhome_2/

ORACLE HOME 변경 작업

bash_profile 변경

oracle / root user의 .bash_profile에서 ORACLE_HOME 경로 변경

[FLUTEDB]oracle@flute$ vi ~/.bash_profile
export ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_2

[FLUTEDB]oracle@flute$ . ~/.bash_profile
[FLUTEDB]oracle@flute$ echo $ORACLE_HOME
/u01/app/oracle/product/19.0.0.0/dbhome_2

relink 작업

relink 명령어 실행

[FLUTEDB]oracle@flute$ cd $ORACLE_HOME
[FLUTEDB]oracle@flute$ pwd
/u01/app/oracle/product/19.0.0.0/dbhome_2

[FLUTEDB]oracle@flute$ relink all
writing relink log to: /u01/app/oracle/product/19.0.0.0/dbhome_2/install/relinkActions2023-08-06_01-45-15PM.log

서버 기동시 oracle db 자동 시작을 하고 싶으면 oratab 수정
N -> Y 로 변경시 서버 재기동시 DB 자동 실행

[FLUTEDB]oracle@flute$ vi /etc/oratab
#FLUTEDB:/u01/app/oracle/product/19.0.0/dbhome_1:N
FLUTEDB:/u01/app/oracle/product/19.0.0.0/dbhome_2:Y

Inventory.xml 경로 변경

oraInventory의 inventory.xml 파일에 ORACLE_HOME 경로가 이전으로 되어 있음.

[FLUTEDB]oracle@flute$ cat /u01/app/oraInventory/ContentsXML/inventory.xml
<?xml version = '1.0' encoding = 'UTF-8' standalone = 'yes'?>
<!-- Copyright (c) 1999, 2023, Oracle. All rights reserved. -->
<!-- Do not modify the contents of this file by hand. --><INVENTORY>
   <VERSION_INFO>
      <SAVED_WITH>13.9.4.0.0</SAVED_WITH>
      <MINIMUM_VER>2.1.0.6.0</MINIMUM_VER>
   </VERSION_INFO>
   <HOME_LIST>
      <HOME NAME="OraDB19Home1" LOC="/u01/app/oracle/product/19.0.0/dbhome_1" TYPE="O" IDX="1"/>
      <HOME NAME="agent13c1" LOC="/u01/app/em13c/agent_13.5.0.0.0" TYPE="O" IDX="2"/>
   </HOME_LIST>
   <COMPOSITEHOME_LIST/>
[FLUTEDB]oracle@flute$ cd $ORACLE_HOME/oui/bin

[FLUTEDB]oracle@flute$ ./detachHome.sh -silent -local -invPtrLoc $ORACLE_HOME/oraInst.loc
oc
./detachHome.sh: line 5: cd: /u01/app/oracle/product/19.0.0/dbhome_1/oui/bin: No such file or directory
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB.   Actual 20475 MB    Passed
The inventory pointer is located at /u01/app/oracle/product/19.0.0.0/dbhome_2/oraInst.loc
You can find the log of this install session at:
 /u01/app/oraInventory/logs/DetachHome2023-08-06_02-01-34PM.log
'DetachHome' was successful.

oraInventory의 inventory.xml 파일에 ORACLE_HOME 경로가 없어진다.
난 왜 있찌??

[FLUTEDB]oracle@flute$ cat /u01/app/oraInventory/ContentsXML/inventory.xml
<?xml version="1.0" standalone="yes" ?>
<!-- Copyright (c) 1999, 2023, Oracle and/or its affiliates.
All rights reserved. -->
<!-- Do not modify the contents of this file by hand. -->
<INVENTORY>
<VERSION_INFO>
   <SAVED_WITH>12.2.0.7.0</SAVED_WITH>
   <MINIMUM_VER>2.1.0.6.0</MINIMUM_VER>
</VERSION_INFO>
<HOME_LIST>
<HOME NAME="agent13c1" LOC="/u01/app/em13c/agent_13.5.0.0.0" TYPE="O" IDX="2"/>
<HOME NAME="OraDB19Home1" LOC="/u01/app/oracle/product/19.0.0/dbhome_1" TYPE="O" IDX="1" REMOVED="T"/>
</HOME_LIST>
<COMPOSITEHOME_LIST>
</COMPOSITEHOME_LIST>
</INVENTORY>

OraInventory경로 재설정

[FLUTEDB]oracle@flute$ echo $ORACLE_BASE
/u01/app/oracle
[FLUTEDB]oracle@flute$ echo $ORACLE_HOME
/u01/app/oracle/product/19.0.0.0/dbhome_2
[FLUTEDB]oracle@flute$ $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/clone/bin/clone.pl ORACLE_BASE=$ORACLE_BASE ORACLE_HOME=$ORACLE_HOME OSDBA_GROUP=dba -defaultHomeName


[INFO] [INS-32183] Use of clone.pl is deprecated in this release. Clone operation is equivalent to performing a Software Only installation from the image.
You must use /u01/app/oracle/product/19.0.0.0/dbhome_2/runInstaller script available to perform the Software Only install. For more details on image based installation, refer to help documentation.

Starting Oracle Universal Installer...

You can find the log of this install session at:
 /u01/app/oraInventory/logs/cloneActions2023-08-06_02-05-10PM.log
..................................................   5% Done.
..................................................   10% Done.
..................................................   15% Done.
..................................................   20% Done.
..................................................   25% Done.
..................................................   30% Done.
..................................................   35% Done.
..................................................   40% Done.
..................................................   45% Done.
..................................................   50% Done.
..................................................   55% Done.
..................................................   60% Done.
..................................................   65% Done.
..................................................   70% Done.
..................................................   75% Done.
..................................................   80% Done.
..................................................   85% Done.
..........
Copy files in progress.

Copy files successful.

Link binaries in progress.
..........
Link binaries successful.

Setup files in progress.
..........
Setup files successful.

Setup Inventory in progress.

Setup Inventory successful.
..........
Finish Setup successful.
The cloning of OraHome1 was successful.
Please check '/u01/app/oraInventory/logs/cloneActions2023-08-06_02-05-10PM.log' for more details.

Setup Oracle Base in progress.

Setup Oracle Base successful.
..................................................   95% Done.

As a root user, execute the following script(s):
    1. /u01/app/oracle/product/19.0.0.0/dbhome_2/root.sh



..................................................   100% Done.

Root 권한으로 스크립트 실행

[root@flute ~]# /u01/app/oracle/product/19.0.0.0/dbhome_2/root.sh
Check /u01/app/oracle/product/19.0.0.0/dbhome_2/install/root_flute_2023-08-06_14-06-30-847686900.log for the output of root script

변경된 oraInventory 확인

[FLUTEDB]oracle@flute$ cat /u01/app/oraInventory/ContentsXML/inventory.xml
<?xml version="1.0" standalone="yes" ?>
<!-- Copyright (c) 1999, 2023, Oracle and/or its affiliates.
All rights reserved. -->
<!-- Do not modify the contents of this file by hand. -->
<INVENTORY>
<VERSION_INFO>
   <SAVED_WITH>12.2.0.7.0</SAVED_WITH>
   <MINIMUM_VER>2.1.0.6.0</MINIMUM_VER>
</VERSION_INFO>
<HOME_LIST>
<HOME NAME="agent13c1" LOC="/u01/app/em13c/agent_13.5.0.0.0" TYPE="O" IDX="2"/>
<HOME NAME="OraHome1" LOC="/u01/app/oracle/product/19.0.0.0/dbhome_2" TYPE="O" IDX="3"/>
<HOME NAME="OraDB19Home1" LOC="/u01/app/oracle/product/19.0.0/dbhome_1" TYPE="O" IDX="1" REMOVED="T"/>
</HOME_LIST>
<COMPOSITEHOME_LIST>
</COMPOSITEHOME_LIST>
</INVENTORY>

Oracld DB 및 리스터 기동

[FLUTEDB]oracle@flute$ sqlplus / as sysdba
SQL> startup;

[FLUTEDB]oracle@flute$ lsnrctl start

리스너의 빠른 등록을 위해 수동으로 등록
[FLUTEDB]oracle@flute$ sqlplus / as sysdba
SQL> alter system register;

[FLUTEDB]oracle@flute$ lsnrctl status
반응형

댓글