通常情况下,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
root557255400 22:43 pts/000:00:00 su - oracle
oracle557355720 22:43 pts/000:00:00 -bash
oracle577555730 22:47 pts/000:00:00 ps -ef
oracle577655730 22:47 pts/000: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-x20 oracle oinstall4096 Sep 22 14:24 deinstall
-rw-r--r--1 rootroot113811593 Nov 18 22:56 linux_11203_deinstall.zip
[oracle@oracle11g deinstall]$ ls
assistantscvdeinstall.xmllibperlsshUserSetup.sh
bindc_ocmdiagnosticslogsreadme.txtsysman
bootstrap.pldeinstalljlibmapfilesresponseusm
crsdeinstall.pljreouisrvmutl
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、结论
删除数据库是一种非经常性场景,但是预先准备,可以做到有备无患。