使用Deinstall專用工具刪除Oracle Database

realkid4發表於2011-11-23

 

通常情況下,Oracle資料庫安裝之後是不會輕易的刪除的。但是當我們進行日常實驗或者軟體故障問題調整時,是需要進行Database Server或者Client刪除的。

 

刪除Oracle軟體(主要是$ORACLE_HOME目錄下內容)主要有兩種方式,一種是使用內建在Oracle安裝目錄下的deinstall工具指令碼。其呼叫路徑分別為:

 

 

    $ORACLE_HOME/deinstall/deinstall       (unix platforms)

    %ORACLE_HOME%\deinstall\deinstall.bat   (windows platforms)

 

 

另一種方法是使用專門的deinstall工具進行刪除操作。該工具在Oracle官方網站上可以單獨的下載。

 

這兩種方式上,Oracle官方推薦的做法是使用後者,也就是專門的刪除工具。原因是內建的deinstall工具指令碼中常常帶有很多bug,很多時候不能完全的將其刪除乾淨。特別是Windows環境下的解除安裝工具,不能正常工作的場景很多。

 

本篇就來一步步的介紹使用deinstall解除安裝方法。

 

1、  環境介紹

 

首先看看我們的實驗環境,是Linux 4下的Oracle 11g。其中配置了完整的安裝路徑變數。

 

--環境變數資訊

[oracle@oracle11g ~]$ env | grep ORA

ORACLE_SID=wilson

ORACLE_BASE=/u01

ORACLE_HOME=/u01/oracle

 

 

首先,使用lsnrctl stop命令,將監聽程式停止工作。使用status引數進行確認。

 

--檢驗監聽器狀態

[oracle@oracle11g ~]$ lsnrctl status

 

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 18-NOV-2011 22:46:52

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle11g)(PORT=1521)))

TNS-12541: TNS:no listener

 TNS-12560: TNS:protocol adapter error

  TNS-00511: No listener

   Linux Error: 111: Connection refused

 

 

關閉資料庫伺服器。

 

 

[oracle@oracle11g ~]$ sqlplus /nolog

 

SQL*Plus: Release 11.2.0.1.0 Production on Fri Nov 18 22:47:02 2011

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

 

SQL> conn / as sysdba

Connected.

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

 

 

確定oracle相關程式全部停止。

 

 

[oracle@oracle11g ~]$ ps -ef | grep ora

root      5572  5540  0 22:43 pts/0    00:00:00 su - oracle

oracle    5573  5572  0 22:43 pts/0    00:00:00 -bash

oracle    5775  5573  0 22:47 pts/0    00:00:00 ps -ef

oracle    5776  5573  0 22:47 pts/0    00:00:00 grep ora

 

 

2、上傳和解壓deinstall程式

 

使用FTP客戶端,將下載的內容上傳到Linux目錄上。

 

 

[oracle@oracle11g test]$ ls -l

total 111264

-rw-r--r--  1 root root 113811593 Nov 18 22:56 linux_11203_deinstall.zip

 

 

使用unzip進行解壓檔案。

 

 

[oracle@oracle11g test]$ unzip linux_11203_deinstall.zip

Archive:  linux_11203_deinstall.zip

   creating: deinstall/

  inflating: deinstall/deinstall.pl 

   creating: deinstall/sysman/

   creating: deinstall/sysman/admin/

  inflating: deinstall/sysman/admin/supportedtzs.lst 

  inflating: deinstall/sysman/admin/nsupportedtzs.lst 

   creating: deinstall/sysman/admin/dtds/

  inflating: deinstall/sysman/admin/dtds/tagsize.properties 

   creating: deinstall/sysman/admin/scripts/

(篇幅原因,有省略……

 

 

進入deinstall目錄。使用deinstall是不需要額外的安裝過程的。

 

 

[oracle@oracle11g test]$ ls -l

total 111268

drwxr-xr-x  20 oracle oinstall      4096 Sep 22 14:24 deinstall

-rw-r--r--   1 root   root     113811593 Nov 18 22:56 linux_11203_deinstall.zip

 

[oracle@oracle11g deinstall]$ ls

assistants    cv            deinstall.xml  lib       perl        sshUserSetup.sh

bin           dc_ocm        diagnostics    logs      readme.txt  sysman

bootstrap.pl  deinstall     jlib           mapfiles  response    usm

crs           deinstall.pl  jre            oui       srvm        utl

 

 

3、呼叫指令碼語句

 

呼叫語句,刪除指定的$ORACLE_HOME

 

--指定刪除的$ORACLE_HOME

[oracle@oracle11g deinstall]$ ./deinstall -home /u01/oracle

Location of logs /test/deinstall/./logs/

 

############ ORACLE DEINSTALL & DECONFIG TOOL START ############

 

 

######################### CHECK OPERATION START #########################

## [START] Install check configuration ##

 

 

Checking for existence of the Oracle home location /u01/oracle

Oracle Home type selected for deinstall is: Oracle Single Instance Database

Oracle Base selected for deinstall is: /u01

Checking for existence of central inventory location /u01/oraInventory

Checking for sufficient temp space availability on node(s) : 'oracle11g'

 

## [END] Install check configuration ##

 

 

在指令碼執行中,會有若干的確認點,確認刪除的物件、監聽器的名稱等資訊。通常都會有預設值。

 

 

Network Configuration check config START

 

Network de-configuration trace file location: /test/deinstall/./logs/netdc_check2011-11-18_10-59-36-PM.log

 

Specify all Single Instance listeners that are to be de-configured [LISTENER]: (監聽器名稱)

Network Configuration check config END

Database Check Configuration START

Database de-configuration trace file location: /test/deinstall/./logs/databasedc_check2011-11-18_10-59-49-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 [wilson]:  (資料庫名稱)

 

###### For Database 'wilson' ######

Single Instance Database

The diagnostic destination location of the database: /u01/diag/rdbms/wilson

Storage type used by the Database: FS

Database file location: /u01/oradata/WILSON,/u01/flash_recovery_area/WILSON/controlfile

Fast recovery area location: /u01/flash_recovery_area/WILSON

database spfile location: /u01/oracle/dbs/spfilewilson.ora

 

The details of database(s) wilson have been discovered automatically. Do you still want to modify the details of wilson database(s)? [n]:    (確認刪除)

 

Database Check Configuration END

Enterprise Manager Configuration Assistant START

EMCA de-configuration trace file location: /test/deinstall/./logs/emcadc_check2011-11-18_11-00-21-PM.log

 

Checking configuration for database wilson

Enterprise Manager Configuration Assistant END

Oracle Configuration Manager check START

OCM check log file location : /test/deinstall/./logs//ocm_check_2011-11-18_11-00-22-PM.log

Oracle Configuration Manager check END

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

 

####################### CHECK OPERATION SUMMARY #######################

Oracle Home selected for deinstall is: /u01/oracle

Inventory Location where the Oracle home registered is: /u01/oraInventory

Following Single Instance listener(s) will be de-configured: LISTENER

The following databases were selected for de-configuration : wilson

Database unique name : wilson

Storage used : FS

Will update the Enterprise Manager configuration for the following database(s): wilson

No Enterprise Manager ASM targets to update

No Enterprise Manager listener targets to migrate

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: '/test/deinstall/./logs/deinstall_deconfig2011-11-18_10-59-33-PM.out'

Any error messages from this session will be written to: '/test/deinstall/./logs/deinstall_deconfig2011-11-18_10-59-33-PM.err'

 

######################## CLEAN OPERATION START ########################

 

Enterprise Manager Configuration Assistant START

 

EMCA de-configuration trace file location: /test/deinstall/./logs/emcadc_clean2011-11-18_11-00-21-PM.log

 

Updating Enterprise Manager Database Control configuration for database wilson

Updating Enterprise Manager ASM targets (if any)

Updating Enterprise Manager listener targets (if any)

Enterprise Manager Configuration Assistant END

Database de-configuration trace file location: /test/deinstall/./logs/databasedc_clean2011-11-18_11-00-42-PM.log

Database Clean Configuration START wilson

This operation may take few minutes.

Database Clean Configuration END wilson

 

Network Configuration clean config START

 

Network de-configuration trace file location: /test/deinstall/./logs/netdc_clean2011-11-18_11-01-58-PM.log

 

De-configuring Single Instance listener(s): LISTENER

De-configuring listener: LISTENER

    Stopping listener: LISTENER

    Warning: Failed to stop listener. Listener may not be running.

    Deleting listener: LISTENER

    Listener deleted successfully.

Listener de-configured successfully.

 

De-configuring Naming Methods configuration file...

Naming Methods 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 : /test/deinstall/./logs//ocm_clean_2011-11-18_11-00-22-PM.log

Oracle Configuration Manager clean END

Setting the force flag to false

Setting the force flag to cleanup the Oracle Base

Oracle Universal Installer clean START

 

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

 

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

 

Delete directory '/u01/oraInventory' on the local node : Done

 

The Oracle Base directory '/u01' will not be removed on local node. The directory is not empty.

 

Oracle Universal Installer cleanup was successful.

 

Oracle Universal Installer clean END

 

 

## [START] Oracle install clean ##

 

Clean install operation removing temporary directory '/tmp/deinstall2011-11-18_10-59-33PM' on node 'oracle11g'

 

## [END] Oracle install clean ##

 

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

 

####################### CLEAN OPERATION SUMMARY #######################

Updated Enterprise Manager configuration for database wilson

Successfully de-configured the following database instances : wilson

Following Single Instance listener(s) were de-configured successfully: LISTENER

Cleaning the config for CCR

As CCR is not configured, so skipping the cleaning of CCR configuration

CCR clean is finished

Successfully detached Oracle home '/u01/oracle' from the central inventory on the local node.

Successfully deleted directory '/u01/oracle' on the local node.

Successfully deleted directory '/u01/oraInventory' on the local node.

Oracle Universal Installer cleanup was successful.

(提示的額外刪除語句)

Run 'rm -rf /etc/oraInst.loc' as root on node(s) 'oracle11g' at the end of the session.

 

Run 'rm -rf /opt/ORCLfmap' as root on node(s) 'oracle11g' at the end of the session.

Oracle deinstall tool successfully cleaned up temporary directories.

#######################################################################

 

 

############# ORACLE DEINSTALL & DECONFIG TOOL END #############

 

 

之後,根據提示內容刪除剩餘檔案。確認$ORACLE_HOME刪除。

 

 

[oracle@oracle11g deinstall]$ env | grep ORA

ORACLE_SID=wilson

ORACLE_BASE=/u01

ORACLE_HOME=/u01/oracle

 

[oracle@oracle11g u01]$ ls

testscript

 

 

 

4、結論

 

刪除資料庫是一種非經常性場景,但是預先準備,可以做到有備無患。

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17203031/viewspace-711809/,如需轉載,請註明出處,否則將追究法律責任。

相關文章