I did this small how to with purpose of copy a patched Oracle Home between servers. But you can use it as a ” best practice” and have a regular backup of your Oracle Home in case of you, or other guy on your team, accidentally remove part of or entire files and folders on it.
I will reproduce the steps on my virtual machine, I hope that is not your case, on a production database server, but, nobody knows when shit happens, and you may need this procedure to recover and put online your database after an accident.
As you can see, my database is up and runing in my Oracle 18c home.
[oracle@ora18c3 ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 18.0.0.0.0 - Production on Thu Jun 13 18:44:55 2019
Version 18.3.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 READ WRITE NO
5 PDB2 READ WRITE NO
SQL>
SQL>
The location of my ORACLE HOME is listed for this database on my file /etc/oratab
[oracle@ora18c3 ~]$ cat /etc/oratab
#Backup file is /u01/app/18.0.0/grid/srvm/admin/oratab.bak.ora18c3 line added by Agent
#
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third field indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
db02:/u01/app/oracle/product/18.0.0/db_1:N # line added by Agent
+ASM:/u01/app/18.0.0/grid:N # line added by Agent
db01:/u01/app/oracle/product/18.0.0/db_1:N # line added by Agent
Now, let’s issue a backup of my oracle home, do this procedure with root user. You can backup OH online, no problem at all on the database side to issue this step.
[root@ora18c3 db_1]# tar -cf /media/bkp/dbhome18c_installed.tar .
[root@ora18c3 db_1]#
[root@ora18c3 db_1]# ls -ltrh /media/bkp/*home18c*
-rwxrwx---. 1 root vboxsf 9.3G Jun 13 18:58 /media/bkp/dbhome18c_installed.tar
[root@ora18c3 db_1]#
Now, I will cause some damage to my Oracle Home to return the backup of it.
[oracle@ora18c3 db_1]$ ps -ef | grep smon
oracle 11124 1 0 18:29 ? 00:00:00 asm_smon_+ASM
oracle 20849 1 0 18:41 ? 00:00:00 ora_smon_db01
oracle 31126 19386 0 18:59 pts/0 00:00:00 grep --color=auto smon
I will remove all files on my Oracle home…
[oracle@ora18c3 db_1]$ pwd
/u01/app/oracle/product/18.0.0/db_1
[oracle@ora18c3 db_1]$
[oracle@ora18c3 db_1]$ du -sh .
9.4G .
[oracle@ora18c3 db_1]$
[oracle@ora18c3 db_1]$ rm -rf *
[oracle@ora18c3 db_1]$
[oracle@ora18c3 db_1]$
[oracle@ora18c3 db_1]$ ls -ltrh
total 0
[oracle@ora18c3 db_1]$ pwd
/u01/app/oracle/product/18.0.0/db_1
[oracle@ora18c3 db_1]$
It can happen with anyone, just work in a wrong directory and issue the command rm -rf…
[oracle@ora18c3 db_1]$ sqlplus "/as sysdba"
-bash: /u01/app/oracle/product/18.0.0/db_1/bin/sqlplus: No such file or directory
[oracle@ora18c3 db_1]$
Now my sqlplus and all utilities were gone!!!
[oracle@ora18c3 db_1]$ ps -ef | grep smon
oracle 11124 1 0 18:29 ? 00:00:00 asm_smon_+ASM
oracle 32033 19386 0 19:01 pts/0 00:00:00 grep --color=auto smon
[oracle@ora18c3 db_1]$
[oracle@ora18c3 db_1]$
As you can see, database is down… On alert I can see these messages below
2019-06-13T19:01:18.456507+02:00
Errors in file /u01/app/oracle/diag/rdbms/db01/db01/trace/db01_psp0_20809.trc:
ORA-07274: spdcr: access error, access to oracle denied.
Linux-x86_64 Error: 2: No such file or directory
Errors in file /u01/app/oracle/diag/rdbms/db01/db01/trace/db01_psp0_20809.trc (incident=45633) (PDBNAME=CDB$ROOT):
ORA-7274 [] [] [] [] [] [] [] [] [] [] [] []
Incident details in: /u01/app/oracle/diag/rdbms/db01/db01/incident/incdir_45633/db01_psp0_20809_i45633.trc
2019-06-13T19:01:19.845668+02:00
USER (ospid: 20809): terminating the instance due to ORA error 7274
2019-06-13T19:01:19.889661+02:00
System state dump requested by (instance=1, osid=20809 (PSP0)), summary=[abnormal instance termination].
System State dumped to trace file /u01/app/oracle/diag/rdbms/db01/db01/trace/db01_diag_20825_20190613130119.trc
2019-06-13T19:01:26.111518+02:00
Instance terminated by USER, pid = 20809
As root user again, let’s restore our backuped Oracle Home to the correct path using these commands below.
[root@ora18c3 ~]# cd /u01/app/oracle/product/18.0.0/db_1/
[root@ora18c3 db_1]#
[root@ora18c3 db_1]#
[root@ora18c3 db_1]# tar -xf /media/bkp/dbhome18c_installed.tar .
Now as Oracle, let’s check the size of the folder..
[oracle@ora18c3 ~]$ cd /u01/app/oracle/product/18.0.0/db_1/
[oracle@ora18c3 db_1]$ du -sh .
9.4G .
As you could see, is the same size as a original one, 9.4Gb, good for us. To garantee that everything is good, I will do a relink on Oracle binaries before to
try open my database again.
[oracle@ora18c3 bin]$ pwd
/u01/app/oracle/product/18.0.0/db_1/bin
[oracle@ora18c3 bin]$ relink all
writing relink log to: /u01/app/oracle/product/18.0.0/db_1/install/relink_2019-06-13_19-17-53PM.log
[oracle@ora18c3 bin]$ cat /u01/app/oracle/product/18.0.0/db_1/install/relink_2019-06-13_19-17-53PM.log | grep -i "Code 1\|Fatal\|Error"
[oracle@ora18c3 bin]$
[oracle@ora18c3 bin]$
Really awesome!!! no errors on the relink file, so it means that we successfully restore our original Oracle home and now we can startup our database again.
[oracle@ora18c3 ~]$ . oraenv
ORACLE_SID = [db01] ? db01
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@ora18c3 ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 18.0.0.0.0 - Production on Thu Jun 13 19:25:41 2019
Version 18.3.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 2432694552 bytes
Fixed Size 8898840 bytes
Variable Size 654311424 bytes
Database Buffers 1761607680 bytes
Redo Buffers 7876608 bytes
Database mounted.
Database opened.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 READ WRITE NO
5 PDB2 READ WRITE NO
SQL>
I hope this article helps you to restore this situation that I described in the benning, and, please, include a backup of your Oracle Home in your schedules of backup,
otherwise you will need to reinstall Oracle again and maybe patch all patches that you already applied on your Oracle Home before the crash.
All the Best,
Rodrigo Mufalani
Disclaimer: “The postings on this site are my own and don’t necessarily represent may actual employer positions, strategies or opinions. The information here was edited
to be useful for general purpose, specific data and identifications was removed to allow reach generic audience and to be useful.”