Monday, September 12, 2022

OCI VMDB System : Delete old Oracle Home post database upgrade using dbcli

After the database upgrade from 12c to 19c, you will find two Oracle Homes on the server. Follow below steps to delete 12c oracle home


=> Find the database home ID of 12c oracle home


[root@sitdb ~]# dbcli list-dbhomes

ID                                       Name                 DB Version                               Home Location                                 Status
---------------------------------------- -------------------- ---------------------------------------- --------------------------------------------- ----------
6f64870a-8b63-4530-8a9d-132438e273a5     OraDB12102_home1     12.1.0.2.220719                          /u01/app/oracle/product/12.1.0.2/dbhome_1     Configured
03f77e36-98c1-4f0d-ac7f-923e9073a654     OraDB19000_home1     19.15.0.0.0                              /u01/app/oracle/product/19.0.0.0/dbhome_1     Configured
[root@sitdb ~]# 

=> Run delete command 

dbcli delete-dbhome -i 6f64870a-8b63-4530-8a9d-132438e273a5

=> [root@sitdb log]# dbcli delete-dbhome -i 6f64870a-8b63-4530-8a9d-132438e273a5

Job details
----------------------------------------------------------------
                     ID:  9b02b85f-6123-4def-a738-5062701483bb
            Description:  Database Home OraDB12102_home1 Deletion with id 6f64870a-8b63-4530-8a9d-132438e273a5
                 Status:  Running
                Created:  September 6, 2022 3:38:50 PM GST
               Progress:  0%
                Message:
             Error Code:
Task Name                                                                Start Time                          End Time                            Status
------------------------------------------------------------------------ ----------------------------------- ----------------------------------- ----------


[root@sitdb log]# dbcli describe-job -i 9b02b85f-6123-4def-a738-5062701483bb

Job details
----------------------------------------------------------------
                     ID:  9b02b85f-6123-4def-a738-5062701483bb
            Description:  Database Home OraDB12102_home1 Deletion with id 6f64870a-8b63-4530-8a9d-132438e273a5
                 Status:  Failure
                Created:  September 6, 2022 3:38:50 PM GST
               Progress:  5%
                Message:  DCS-10329:Failed to delete database home with id : 6f64870a-8b63-4530-8a9d-132438e273a5.
             Error Code:  DCS-10329
                  Cause:  Failed to delete database home.
                 Action:  Contact Oracle support for assistance.
Task Name                                                                Start Time                          End Time                            Status
------------------------------------------------------------------------ ----------------------------------- ----------------------------------- ----------
DbHome service deletion for 6f64870a-8b63-4530-8a9d-132438e273a5         September 6, 2022 3:38:50 PM GST    September 6, 2022 3:39:10 PM GST    Failure
DbHome service deletion for 6f64870a-8b63-4530-8a9d-132438e273a5         September 6, 2022 3:38:50 PM GST    September 6, 2022 3:39:10 PM GST    Failure
Delete dbhome with ID: 6f64870a-8b63-4530-8a9d-132438e273a5              September 6, 2022 3:38:51 PM GST    September 6, 2022 3:39:09 PM GST    Failure


[root@sitdb log]#

=> Failed due to below perl errors 

com.oracle.dcs.commons.utils.CommonsUtils: perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-16"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.

Fix: Delete all patches from 12c home 

unset 19c environment and set 12c environment 

unset ORACLE_HOME
unset ORACLE_UNQNAME
unset LD_LIBRARY_PATH
unset ORACLE_SID
export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/oracle/.local/bin:/home/oracle/bin
export ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/dbhome_1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH

[oracle@sitdb dbhome_1]$ opatch lspatches
33066573;
31413047;
21923026;
33613829;
34421053;
34269744;
34006650;
34006614;
32327201;
31335037;
30432084;
33912892;DATABASE PERL UPDATE IN 12.1.0.2.0 TO V5.32-1 (CVE-2022-23990 - LIBEXPAT UPDATE)
34086863;Database PSU 12.1.0.2.220719,Oracle JavaVM Component (JUL2022)
34113570;JDK BUNDLE PATCH 12.1.0.2.220719
34057733;Database Bundle Patch : 12.1.0.2.220719 (34057733)
32758932;OCW PATCH SET UPDATE 12.1.0.2.210720 (32758932)
OPatch succeeded.

[oracle@sitdb dbhome_1]$

opatch nrollback -id 33066573,31413047,21923026,33613829,34421053,34269744,34006650,34006614,32327201,31335037,30432084,33912892,34086863,34113570,34057733,32758932

[oracle@sitdb dbhome_1]$ opatch lspatches

There are no Interim patches installed in this Oracle Home "/u01/app/oracle/product/12.1.0.2/dbhome_1".
OPatch succeeded.

[oracle@sitdb dbhome_1]$

=> oracle home status will be still in deleting state. Update it backup to configured state before issuing delete command

[root@sitdb ~]# su - mysql

Last login: Wed Aug 24 09:53:41 +04 2022

[mysql@sitdb ~]$ /opt/oracle/mysql_compact/mysql-shell/bin/mysqlsh

MySQL Shell 8.0.21-commercial
Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.
Type '\help' or '\?' for help; '\quit' to exit.
 MySQL  JS > \sql
Switching to SQL mode... Commands end with ;
 MySQL  SQL > \connect root@localhost:3306
Creating a session to 'root@localhost:3306'
Fetching schema names for autocompletion... Press ^C to stop.
Your MySQL connection id is 12
Server version: 8.0.21-commercial MySQL Enterprise Server - Commercial
No default schema selected; type \use <schema> to set one.
 MySQL  localhost:3306 ssl  SQL > \use metastore
Default schema set to `metastore`.
Fetching table and column names from `metastore` for auto-completion... Press ^C to stop.
 MySQL  localhost:3306 ssl  metastore  SQL > 
MySQL  localhost:3306 ssl  metastore  SQL > select * from DatabaseHome;
+--------------------------------------+----------------------------+----------------------------+------------------+------------+-----------+-------------------------------------------+-----------------+---------------+------+-----------------+
| id                                   | updatedTime                | createTime                 | name             | status     | dbEdition | dbHomeLocation                            | dbVersion       | isCustomClone | ocid | unifiedAuditing |
+--------------------------------------+----------------------------+----------------------------+------------------+------------+-----------+-------------------------------------------+-----------------+---------------+------+-----------------+
| 03f77e36-98c1-4f0d-ac7f-923e9073a654 | 2022-09-06 10:16:17.755000 | 2022-09-06 10:06:54.962000 | OraDB19000_home1 | Configured | EE        | /u01/app/oracle/product/19.0.0.0/dbhome_1 | 19.15.0.0.0     | 0             | NULL | false           |
| 6f64870a-8b63-4530-8a9d-132438e273a5 | 2022-09-06 15:38:51.746000 | 2022-08-24 09:56:58.041000 | OraDB12102_home1 | Deleting   | EE        | /u01/app/oracle/product/12.1.0.2/dbhome_1 | 12.1.0.2.220719 | 0             | NULL | false           |
+--------------------------------------+----------------------------+----------------------------+------------------+------------+-----------+-------------------------------------------+-----------------+---------------+------+-----------------+
2 rows in set (0.0023 sec)
 MySQL  localhost:3306 ssl  metastore  SQL > update DatabaseHome set status='Configured' where id='6f64870a-8b63-4530-8a9d-132438e273a5';
Query OK, 1 row affected (0.0125 sec)
Rows matched: 1  Changed: 1  Warnings: 0
 MySQL  localhost:3306 ssl  metastore  SQL > commit;
Query OK, 0 rows affected (0.0002 sec)
 MySQL  localhost:3306 ssl  metastore  SQL >  select * from DatabaseHome;
+--------------------------------------+----------------------------+----------------------------+------------------+------------+-----------+-------------------------------------------+-----------------+---------------+------+-----------------+
| id                                   | updatedTime                | createTime                 | name             | status     | dbEdition | dbHomeLocation                            | dbVersion       | isCustomClone | ocid | unifiedAuditing |
+--------------------------------------+----------------------------+----------------------------+------------------+------------+-----------+-------------------------------------------+-----------------+---------------+------+-----------------+
| 03f77e36-98c1-4f0d-ac7f-923e9073a654 | 2022-09-06 10:16:17.755000 | 2022-09-06 10:06:54.962000 | OraDB19000_home1 | Configured | EE        | /u01/app/oracle/product/19.0.0.0/dbhome_1 | 19.15.0.0.0     | 0             | NULL | false           |
| 6f64870a-8b63-4530-8a9d-132438e273a5 | 2022-09-06 15:38:51.746000 | 2022-08-24 09:56:58.041000 | OraDB12102_home1 | Configured | EE        | /u01/app/oracle/product/12.1.0.2/dbhome_1 | 12.1.0.2.220719 | 0             | NULL | false           |
+--------------------------------------+----------------------------+----------------------------+------------------+------------+-----------+-------------------------------------------+-----------------+---------------+------+-----------------+
2 rows in set (0.0010 sec)
 MySQL  localhost:3306 ssl  metastore  SQL >
 MySQL  localhost:3306 ssl  metastore  SQL > \quit
Bye!

[mysql@sitdb ~]$ exit

[root@sitdb ~]# dbcli list-dbhomes

ID                                       Name                 DB Version                               Home Location                                 Status
---------------------------------------- -------------------- ---------------------------------------- --------------------------------------------- ----------
6f64870a-8b63-4530-8a9d-132438e273a5     OraDB12102_home1     12.1.0.2.220719                          /u01/app/oracle/product/12.1.0.2/dbhome_1     Configured
03f77e36-98c1-4f0d-ac7f-923e9073a654     OraDB19000_home1     19.15.0.0.0                              /u01/app/oracle/product/19.0.0.0/dbhome_1     Configured

[root@sitdb ~]#

=> Now run the delete command with force option

[root@sitdb ~]#  dbcli delete-dbhome -i 6f64870a-8b63-4530-8a9d-132438e273a5  --force

Job details
----------------------------------------------------------------
                     ID:  3784213a-f374-4d07-aec1-603bdc4e55d8
            Description:  Database Home OraDB12102_home1 Deletion with id 6f64870a-8b63-4530-8a9d-132438e273a5
                 Status:  Running
                Created:  September 12, 2022 1:39:51 PM GST
               Progress:  0%
                Message:
             Error Code:
Task Name                                                                Start Time                          End Time                            Status
------------------------------------------------------------------------ ----------------------------------- ----------------------------------- ----------
[root@sitdb ~]#

[root@sitdb ~]# dbcli describe-job -i 3784213a-f374-4d07-aec1-603bdc4e55d8

Job details
----------------------------------------------------------------
                     ID:  3784213a-f374-4d07-aec1-603bdc4e55d8
            Description:  Database Home OraDB12102_home1 Deletion with id 6f64870a-8b63-4530-8a9d-132438e273a5
                 Status:  Success
                Created:  September 12, 2022 1:39:51 PM GST
               Progress:  100%
                Message:
             Error Code:
Task Name                                                                Start Time                          End Time                            Status
------------------------------------------------------------------------ ----------------------------------- ----------------------------------- ----------
Delete dbhome with ID: 6f64870a-8b63-4530-8a9d-132438e273a5              September 12, 2022 1:39:53 PM GST   September 12, 2022 1:41:11 PM GST   Success
[root@sitdb ~]# dbcli list-dbhomes
ID                                       Name                 DB Version                               Home Location                                 Status
---------------------------------------- -------------------- ---------------------------------------- --------------------------------------------- ----------
03f77e36-98c1-4f0d-ac7f-923e9073a654     OraDB19000_home1     19.15.0.0.0                              /u01/app/oracle/product/19.0.0.0/dbhome_1     Configured
[root@sitdb ~]#

No comments:

Post a Comment