Como desinstalar o OH sem remover o banco de dados

Categorias: Oracle Database · Instalação e upgrade

Olá galera, gostaria de compartilhar com vocês um método para realizar o deinstall do Oracle Database sem remover os arquivos do banco de dados durante o processo. Eu ajudei um amigo nessa situação semana passada e decidi publicar aqui para todo mundo. O cenário dele era remover o software do Oracle Database 11gR2 Standard Edition e instalar o Oracle Database 11gR2 Enterprise Edition no mesmo Oracle Home (OH) devido à limitação de espaço no filesystem. Resumindo… ele queria somente remover o software sem afetar o banco de dados.

Está claro que o procedimento de desinstalação remove todos os arquivos do banco de dados, mas encontrei uma solução bem fácil para evitar que o script de desinstalação faça isso: Mover todos os spfiles/pfiles armazenados no OH que será removido para um diretório temporário e só então executar o procedimento de desinstalação. Por favor, lembre-se de copiar todos os arquivos do Oracle Net, arquivos de senha e todos os demais arquivos específicos para o seu ambiente antes de executar o script de desinstalação, pois ele remove completamente toda a árvore de diretórios do OH.

Deinstall

Ajuste as variáveis de ambiente para o OH desejado:

[oracle@oracle-srv ~]$ . oraenv
ORACLE_SID = [UPGR] ? CDB1
The Oracle base remains unchanged with value /u01/app/oracle

Vá ao diretório do OH:

[oracle@oracle-srv ~]$ cd $ORACLE_HOME/dbs

Liste o conteúdo:

[oracle@oracle-srv dbs]$ ls
hc_CDB1.dat  init.ora  lkCDB1  orapwCDB1  spfileCDB1.ora

E mova todos os spfiles/pfiles:

[oracle@oracle-srv dbs]$ mv spfileCDB1.ora /tmp/spfileCDB1.ora_bkp

Vá ao diretório do script de desinstalação:

[oracle@oracle-srv dbs]$ cd ../deinstall/

Execute o script de desinstalação e forneça as informações necessárias (não informe o local do spfile):

[oracle@oracle-srv deinstall]$ ./deinstall
Checking for required files and bootstrapping ...
Please wait ...
Location of logs /u01/app/oraInventory/logs/

############ ORACLE DECONFIG TOOL START ############

######################### DECONFIG CHECK OPERATION START #########################
## [START] Install check configuration ##

Checking for existence of the Oracle home location /u01/app/oracle/product/12.1.0.2
Oracle Home type selected for deinstall is: Oracle Single Instance Database
Oracle Base selected for deinstall is: /u01/app/oracle
Checking for existence of central inventory location /u01/app/oraInventory

## [END] Install check configuration ##

Network Configuration check config START

Network de-configuration trace file location: /u01/app/oraInventory/logs/netdc_check2017-11-25_09-17-07-PM.log

Network Configuration check config END

Database Check Configuration START

Database de-configuration trace file location: /u01/app/oraInventory/logs/databasedc_check2017-11-25_09-17-15-PM.log

Use comma as separator when specifying list of values as input

Specify the list of database names that are configured in this Oracle home [CDB1]:

###### For Database 'CDB1' ######

Specify the type of this database (1.Single Instance Database|2.Oracle Restart Enabled Database) [1]: Specify the diagnostic destination location of the database [/u01/app/oracle/diag/rdbms/cdb1]: 1
Specify the storage type used by the Database ASM|FS []: FS

Specify the list of directories if any database files exist on a shared file system. If 'CDB1' subdirectory is found, then it will be deleted. Otherwise, the specified directory will be deleted. Alternatively, you can specify list of database files with full path [ ]:

Specify the fast recovery area location, if it is configured on the file system. If 'CDB1' subdirectory is found, then it will be deleted. []:

Specify the database spfile location [ ]:

Database Check Configuration END
Oracle Configuration Manager check START
OCM check log file location : /u01/app/oraInventory/logs//ocm_check4658.log
Oracle Configuration Manager check END

######################### DECONFIG CHECK OPERATION END #########################

####################### DECONFIG CHECK OPERATION SUMMARY #######################
Oracle Home selected for deinstall is: /u01/app/oracle/product/12.1.0.2
Inventory Location where the Oracle home registered is: /u01/app/oraInventory
The following databases were selected for de-configuration : CDB1
Database unique name : CDB1
Storage used : FS
Checking the config status for CCR
Oracle Home exists with CCR directory, but CCR is not configured
CCR check is finished
Do you want to continue (y - yes, n - no)? [n]: y
A log of this session will be written to: '/u01/app/oraInventory/logs/deinstall_deconfig2017-11-25_09-17-07-PM.out'
Any error messages from this session will be written to: '/u01/app/oraInventory/logs/deinstall_deconfig2017-11-25_09-17-07-PM.err'

######################## DECONFIG CLEAN OPERATION START ########################
Database de-configuration trace file location: /u01/app/oraInventory/logs/databasedc_clean2017-11-25_09-24-19-PM.log
Database Clean Configuration START CDB1
This operation may take few minutes.

Database Clean Configuration END CDB1

Network Configuration clean config START

Network de-configuration trace file location: /u01/app/oraInventory/logs/netdc_clean2017-11-25_09-28-35-PM.log

De-configuring Local Net Service Names configuration file...
Local Net Service Names configuration file de-configured successfully.

De-configuring backup files...
Backup files de-configured successfully.

The network configuration has been cleaned up successfully.

Network Configuration clean config END

Oracle Configuration Manager clean START
OCM clean log file location : /u01/app/oraInventory/logs//ocm_clean4658.log
Oracle Configuration Manager clean END

######################### DECONFIG CLEAN OPERATION END #########################

####################### DECONFIG CLEAN OPERATION SUMMARY #######################
Successfully de-configured the following database instances : CDB1
Cleaning the config for CCR
As CCR is not configured, so skipping the cleaning of CCR configuration
CCR clean is finished
#######################################################################

############# ORACLE DECONFIG TOOL END #############

Using properties file /tmp/deinstall2017-11-25_09-16-40PM/response/deinstall_2017-11-25_09-17-07-PM.rsp
Location of logs /u01/app/oraInventory/logs/

############ ORACLE DEINSTALL TOOL START ############

####################### DEINSTALL CHECK OPERATION SUMMARY #######################
A log of this session will be written to: '/u01/app/oraInventory/logs/deinstall_deconfig2017-11-25_09-17-07-PM.out'
Any error messages from this session will be written to: '/u01/app/oraInventory/logs/deinstall_deconfig2017-11-25_09-17-07-PM.err'

######################## DEINSTALL CLEAN OPERATION START ########################
## [START] Preparing for Deinstall ##
Setting LOCAL_NODE to oracle-srv
Setting CRS_HOME to false
Setting oracle.installer.invPtrLoc to /tmp/deinstall2017-11-25_09-16-40PM/oraInst.loc
Setting oracle.installer.local to false

## [END] Preparing for Deinstall ##

Setting the force flag to false
Setting the force flag to cleanup the Oracle Base
Oracle Universal Installer clean START

Detach Oracle home '/u01/app/oracle/product/12.1.0.2' from the central inventory on the local node : Done

Delete directory '/u01/app/oracle/product/12.1.0.2' on the local node : Done

The Oracle Base directory '/u01/app/oracle' will not be removed on local node. The directory is in use by Oracle Home '/u01/app/oracle/product/12.2.0.1'.

Oracle Universal Installer cleanup was successful.

Oracle Universal Installer clean END

## [START] Oracle install clean ##

Clean install operation removing temporary directory '/tmp/deinstall2017-11-25_09-16-40PM' on node 'oracle-srv'

## [END] Oracle install clean ##

######################### DEINSTALL CLEAN OPERATION END #########################

####################### DEINSTALL CLEAN OPERATION SUMMARY #######################
Successfully detached Oracle home '/u01/app/oracle/product/12.1.0.2' from the central inventory on the local node.
Successfully deleted directory '/u01/app/oracle/product/12.1.0.2' on the local node.
Oracle Universal Installer cleanup was successful.

Oracle deinstall tool successfully cleaned up temporary directories.
#######################################################################

############# ORACLE DEINSTALL TOOL END #############

A desinstalação finalizou com sucesso. Vamos ver como as coisas ficaram:

[oracle@oracle-srv deinstall]$ pwd
/u01/app/oracle/product/12.1.0.2/deinstall

Vou tentar subir um diretório:

[oracle@oracle-srv deinstall]$ cd ..
cd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

Como esperado todos os diretórios do OH foram removidos.

Então vou alternar para um diretório existente:

[oracle@oracle-srv ..]$ cd
[oracle@oracle-srv ~]$

E agora vamos verificar os arquivos do banco de dados:

[oracle@oracle-srv ~]$ cd /u02/oradata/CDB1

Liste o diretório dos arquivos do banco de dados:

[oracle@oracle-srv CDB1]$ ll
total 5378508
drwxr-x---. 3 oracle dba       4096 Sep 13 01:52 5907BDCE10441229E0530C0FA8C007D7
-rw-r-----. 1 oracle dba   17973248 Nov 13 02:06 control01.ctl
-rw-r-----. 1 oracle dba   17973248 Nov 13 02:06 control02.ctl
drwxr-xr-x. 2 oracle dba       4096 Jul 23  2016 pdb3
drwxr-x---. 2 oracle dba       4096 Aug 12  2016 pdbseed
-rw-r-----. 1 oracle dba  524288512 Nov 12 15:28 redo01.log
-rw-r-----. 1 oracle dba  524288512 Nov 13 02:05 redo02.log
-rw-r-----. 1 oracle dba  524288512 Nov 12 15:28 redo03.log
-rw-r-----. 1 oracle dba  524288512 Nov 12 15:28 redo04.log
-rw-r-----. 1 oracle dba  524288512 Nov 12 15:28 redo05.log
-rw-r-----. 1 oracle dba  576724992 Nov 13 02:05 sysaux01.dbf
-rw-r-----. 1 oracle dba  891297792 Nov 13 02:05 system01.dbf
-rw-r-----. 1 oracle dba  125837312 Nov 13 02:01 temp01.dbf
-rw-r-----. 1 oracle dba 1253056512 Nov 13 02:05 undotbs01.dbf
-rw-r-----. 1 oracle dba    5251072 Nov 13 02:05 users01.dbf

Está tudo intacto. Agora você pode seguir com sua próxima instalação no mesmo filesystem e usar todos os arquivos de configuração que você salvou do OH que foi removido.

Por hoje é só pessoal, grande abraço e até mais.

Franky

Comentários