共计 15175 个字符,预计需要花费 38 分钟才能阅读完成。
1. deinstall工具
1.1. 工具 介绍
deinstall工具是 Oracle 提供的数据库软件卸载工具,使用方法可以参考官方文档路径:Installing and Upgrading→Database Installation Guide for Linux→ 7 Removing Oracle Database Software
具体路径为:http://docs.oracle.com/cd/E11882_01/install.112/e47689/remove_oracle_sw.htm#LADBI1336
oracle总共提供了 2 种使用 deinstall 的方法:
(1)如果 Oracle 安装无误,可以直接 调用 $ORACLE_HOME 下的 脚本$ORACLE_HOME/deinstall/deinstall
(2)如果 Oracle 安装有问题或者是其他情况,可以 下载独立的 工具 后,然后使用工具进行卸载。
官方 文档 给出 的下载路径:
1.前往URL:
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
2.在 Oracle Database 11g Release 2 下载 区域 找到 对应的平台 版本 ,点击”See All”, 在新打开的页面底部可以 下载到 数据库 卸载 工具。
另外 ,使用单独的deinstall 进行卸载的时候,必须 指定 -home 参数 ,查看官方文档 说明:
- -home
- Use this flag to indicate the home path of the Oracle home to check or deinstall. To deinstall Oracle software using the deinstall command in the Oracle home you plan to deinstall, provide a parameter file in another location, and do not use the -home flag.
- If you run deinstall from the $ORACLE_HOME/deinstall path, then the -home flag is not required because the tool knows from which home it is being run. If you use the standalone version of the tool, then -home is mandatory.
简单 的说,就是使用第一种方法,可以直接 运行 脚本:
- $ORACLE_HOME/deinstall/deinstall
使用 第二种方法,必须带上 -home 参数:
- $ORACLE_HOME/deinstall/deinstall –home $ORACLE_HOME
这里 我们 将会 使用第一种方法进行卸载数据库 , 当然,第二种 方法 也是类似,只不过需要单独下载工具。
1.2. 环境 准备
查看 服务器的 环境 变量
- [oracle@DB074 ~]$env | grep ORA
- ORACLE_SID=cams
- ORACLE_BASE=/u01/app/oracle
- ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
查看监听 的状态,如监听 启动,则关闭监听。
- [oracle@DB074 ~]$ lsnrctl status
- LSNRCTL for Linux: Version 11.2.0.4.0 – Production on 11–SEP–2017 14:45:16
- Copyright (c) 1991, 2013, Oracle. All rights reserved.
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DB074.bj)(PORT=1521)))
- STATUS of the LISTENER
- ––––––––––––––––––––––––
- Alias LISTENER
- Version TNSLSNR for Linux: Version 11.2.0.4.0 – Production
- Start Date 11–SEP–2017 14:44:32
- Uptime 0 days 0 hr. 0 min. 44 sec
- Trace Level off
- Security ON: Local OS Authentication
- SNMP OFF
- Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
- Listener Log File /u01/app/oracle/diag/tnslsnr/DB074/listener/alert/log.xml
- Listening Endpoints Summary...
- (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DB074.bj)(PORT=1521)))
- (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
- Services Summary...
- Service “cams” has 1 instance(s).
- Instance “cams”, status READY, has 1 handler(s) for this service...
- Service “camsXDB” has 1 instance(s).
- Instance “cams”, status READY, has 1 handler(s) for this service...
- The command completed successfully
- [oracle@DB074 ~]$ lsnrctl stop
- LSNRCTL for Linux: Version 11.2.0.4.0 – Production on 11–SEP–2017 14:45:29
- Copyright (c) 1991, 2013, Oracle. All rights reserved.
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DB074.bj)(PORT=1521)))
- The command completed successfully
- [oracle@DB074 ~]$ lsnrctl status
- LSNRCTL for Linux: Version 11.2.0.4.0 – Production on 11–SEP–2017 14:45:36
- Copyright (c) 1991, 2013, Oracle. All rights reserved.
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DB074.bj)(PORT=1521)))
- TNS–12541: TNS:no listener
- TNS–12560: TNS:protocol adapter error
- TNS–00511: No listener
- Linux Error: 111: Connection refused
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
- TNS–12541: TNS:no listener
- TNS–12560: TNS:protocol adapter error
- TNS–00511: No listener
- Linux Error: 2: No such file or directory
查看数据库实例 的状态,如数据库 实例启动,则关闭 数据库 实例。
- [oracle@DB074 ~]$ ps –ef | grep smon
- oracle 3559 1 0 14:44 ? 00:00:00 ora_smon_cams
- oracle 3662 31107 0 14:47 pts/1 00:00:00 grep smon
- [oracle@DB074 ~]$ sqlplus / as sysdba
- SQL*Plus: Release 11.2.0.4.0 Production on Mon Sep 11 14:47:25 2017
- Copyright (c) 1982, 2013, Oracle. All rights reserved.
- Connected to:
- Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 – 64bit Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
- SYS@cams>shutdown immediate;
- Database closed.
- Database dismounted.
- ORACLE instance shut down.
- SYS@cams>exit
- Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 – 64bit Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
- [oracle@DB074 ~]$ ps –ef | grep smon
- oracle 3675 31107 0 14:47 pts/1 00:00:00 grep smon
最后 , 确保没有 oracle 进程启动
- [oracle@DB074 ~]$ ps –ef | grep ora
- root 1987 1945 0 Sep09 ? 00:01:16 hald–addon–storage: polling /dev/sr0 (every 2 sec)
- oracle 3677 31107 0 14:48 pts/1 00:00:00 ps –ef
- oracle 3678 31107 0 14:48 pts/1 00:00:00 grep ora
- root 31106 30170 0 11:34 pts/1 00:00:00 su – oracle
- oracle 31107 31106 0 11:34 pts/1 00:00:00 –bash
1.3. 执行 deinstall 卸载脚本
在 oracle 用户下,执行 deinstall 脚本
- [oracle@DB074 ~]$ $ORACLE_HOME/deinstall/deinstall
整个 交互过程如下:
- [oracle@DB074 ~]$ $ORACLE_HOME/deinstall/deinstall
- Checking for required files and bootstrapping ...
- Please wait ...
- Location of logs /tmp/deinstall2017–09–11_02–50–04PM/logs/
- ############ ORACLE DEINSTALL & DECONFIG TOOL START ############
- ######################### CHECK OPERATION START #########################
- ## [START] Install check configuration ##
- Checking for existence of the Oracle home location /u01/app/oracle/product/11.2.0/db_1
- 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
- Checking for sufficient temp space availability on node(s) : ‘DB074’
- ## [END] Install check configuration ##
- Network Configuration check config START
- Network de–configuration trace file location: /tmp/deinstall2017–09–11_02–50–04PM/logs/netdc_check2017–09–11_02–50–10–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: /tmp/deinstall2017–09–11_02–50–04PM/logs/databasedc_check2017–09–11_02–51–44–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 [cams]:(这里需要确认数据库名称,默认值没问题,直接回车)
- ###### For Database ‘cams’ ######
- Single Instance Database
- The diagnostic destination location of the database: /u01/app/oracle/diag/rdbms/cams
- Storage type used by the Database: FS
- Database file location: /u01/app/oracle/oradata/cams,/u01/app/oracle/fast_recovery_area/cams,/home/oracle/cams/tablespace
- Fast recovery area location: /u01/app/oracle/fast_recovery_area/CAMS
- database spfile location: /u01/app/oracle/product/11.2.0/db_1/dbs/spfilecams.ora
- The details of database(s) cams have been discovered automatically. Do you still want to modify the details of cams database(s)? [n]:(这里需要确认数据库详细信息,默认值没问题,不需要修改,直接回车)
- Database Check Configuration END
- Enterprise Manager Configuration Assistant START
- EMCA de–configuration trace file location: /tmp/deinstall2017–09–11_02–50–04PM/logs/emcadc_check2017–09–11_02–52–24–PM.log
- Checking configuration for database cams
- Enterprise Manager Configuration Assistant END
- Oracle Configuration Manager check START
- OCM check log file location : /tmp/deinstall2017–09–11_02–50–04PM/logs//ocm_check4203.log
- Oracle Configuration Manager check END
- ######################### CHECK OPERATION END #########################
- ####################### CHECK OPERATION SUMMARY #######################
- Oracle Home selected for deinstall is: /u01/app/oracle/product/11.2.0/db_1
- Inventory Location where the Oracle home registered is: /u01/app/oraInventory
- Following Single Instance listener(s) will be de–configured: LISTENER
- The following databases were selected for de–configuration : cams
- Database unique name : cams
- Storage used : FS
- Will update the Enterprise Manager configuration for the following database(s): cams
- 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(输入 y,然后回车)
- A log of this session will be written to: ‘/tmp/deinstall2017-09-11_02-50-04PM/logs/deinstall_deconfig2017-09-11_02-50-09-PM.out’
- Any error messages from this session will be written to: ‘/tmp/deinstall2017-09-11_02-50-04PM/logs/deinstall_deconfig2017-09-11_02-50-09-PM.err’
- ######################## CLEAN OPERATION START ########################
- Enterprise Manager Configuration Assistant START
- EMCA de–configuration trace file location: /tmp/deinstall2017–09–11_02–50–04PM/logs/emcadc_clean2017–09–11_02–52–24–PM.log
- Updating Enterprise Manager Database Control configuration for database cams
- 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: /tmp/deinstall2017–09–11_02–50–04PM/logs/databasedc_clean2017–09–11_02–53–16–PM.log
- Database Clean Configuration START cams
- This operation may take few minutes.
- Database Clean Configuration END cams
- Network Configuration clean config START
- Network de–configuration trace file location: /tmp/deinstall2017–09–11_02–50–04PM/logs/netdc_clean2017–09–11_02–54–11–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 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 : /tmp/deinstall2017–09–11_02–50–04PM/logs//ocm_clean4203.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/app/oracle/product/11.2.0/db_1’ from the central inventory on the local node : Done
- Delete directory ‘/u01/app/oracle/product/11.2.0/db_1’ on the local node : Done
- Delete directory ‘/u01/app/oraInventory’ on the local node : Done
- Delete directory ‘/u01/app/oracle’ on the local node : Done
- Oracle Universal Installer cleanup was successful.
- Oracle Universal Installer clean END
- ## [START] Oracle install clean ##
- Clean install operation removing temporary directory ‘/tmp/deinstall2017-09-11_02-50-04PM’ on node ‘DB074’
- ## [END] Oracle install clean ##
- ######################### CLEAN OPERATION END #########################
- ####################### CLEAN OPERATION SUMMARY #######################
- Updated Enterprise Manager configuration for database cams
- Successfully de–configured the following database instances : cams
- 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/app/oracle/product/11.2.0/db_1’ from the central inventory on the local node.
- Successfully deleted directory ‘/u01/app/oracle/product/11.2.0/db_1’ on the local node.
- Successfully deleted directory ‘/u01/app/oraInventory’ on the local node.
- Successfully deleted directory ‘/u01/app/oracle’ on the local node.
- Oracle Universal Installer cleanup was successful.
- (在 deinstall 工具执行完之后,需要用 root 完成删除的内容)
- Run ‘rm -rf /etc/oraInst.loc’ as root on node(s) ‘DB074’ at the end of the session.
- Run ‘rm -rf /opt/ORCLfmap’ as root on node(s) ‘DB074’ at the end of the session.
- Run ‘rm -rf /etc/oratab’ as root on node(s) ‘DB074’ at the end of the session.
- Oracle deinstall tool successfully cleaned up temporary directories.
- #######################################################################
- ############# ORACLE DEINSTALL & DECONFIG TOOL END #############
根据 最后的提示信息,切换到 root 用户,删除相应 的文件
- [oracle@DB074 ~]$ su – root
- Password:
- [root@DB074 ~]# rm –rf /etc/oraInst.loc
- [root@DB074 ~]# rm –rf /opt/ORCLfmap
- [root@DB074 ~]# rm –rf /etc/oratab
切换到 oracle 用户,检查 $ORACLE_BASE 路径 下文件:
- [root@DB074 oracle]# su – oracle
- [oracle@DB074 ~]$ cd $ORACLE_BASE
- –bash: cd: /u01/app/oracle: No such file or directory
- [oracle@DB074 ~]$ cd /u01/app/
- [oracle@DB074 app]$ ll
- total 216
- drwxr–xr–x 7 oracle oinstall 4096 Aug 27 2013 database
- drwxr–xr–x 2 oracle oinstall 4096 May 9 13:31 dump
- –rw–r––r–– 1 root root 210877 Feb 6 2017 pdksh–5.2.14–37.el5_8.1.x86_64.rpm
显然 ,Oracle 数据库软件已经删除完毕。
2. 命令 行
假定服务器 原先是数据库服务器,现在要回收 作为应用 服务器,需要将数据库软件等完全删除。
(1)前期 准备工作
将需要 做保留的文件进行备份,如数据库数据,自定义 数据库 脚本等。
(2)查看 服务器的 环境 变量
- [oracle@DB074 ~]$ env | grep ORA
- ORACLE_SID=cams
- ORACLE_BASE=/u01/app/oracle
- ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
(3)查看监听 的状态,如监听 启动,则关闭监听。
- [oracle@DB074 ~]$ lsnrctl status
- LSNRCTL for Linux: Version 11.2.0.4.0 – Production on 11–SEP–2017 14:45:16
- Copyright (c) 1991, 2013, Oracle. All rights reserved.
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DB074.bj)(PORT=1521)))
- STATUS of the LISTENER
- ––––––––––––––––––––––––
- Alias LISTENER
- Version TNSLSNR for Linux: Version 11.2.0.4.0 – Production
- Start Date 11–SEP–2017 14:44:32
- Uptime 0 days 0 hr. 0 min. 44 sec
- Trace Level off
- Security ON: Local OS Authentication
- SNMP OFF
- Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
- Listener Log File /u01/app/oracle/diag/tnslsnr/DB074/listener/alert/log.xml
- Listening Endpoints Summary...
- (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DB074.bj)(PORT=1521)))
- (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
- Services Summary...
- Service “cams” has 1 instance(s).
- Instance “cams”, status READY, has 1 handler(s) for this service...
- Service “camsXDB” has 1 instance(s).
- Instance “cams”, status READY, has 1 handler(s) for this service...
- The command completed successfully
- [oracle@DB074 ~]$ lsnrctl stop
- LSNRCTL for Linux: Version 11.2.0.4.0 – Production on 11–SEP–2017 14:45:29
- Copyright (c) 1991, 2013, Oracle. All rights reserved.
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DB074.bj)(PORT=1521)))
- The command completed successfully
- [oracle@DB074 ~]$ lsnrctl status
- LSNRCTL for Linux: Version 11.2.0.4.0 – Production on 11–SEP–2017 14:45:36
- Copyright (c) 1991, 2013, Oracle. All rights reserved.
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DB074.bj)(PORT=1521)))
- TNS–12541: TNS:no listener
- TNS–12560: TNS:protocol adapter error
- TNS–00511: No listener
- Linux Error: 111: Connection refused
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
- TNS–12541: TNS:no listener
- TNS–12560: TNS:protocol adapter error
- TNS–00511: No listener
- Linux Error: 2: No such file or directory
- (4)查看数据库实例的状态,如数据库实例启动,则关闭数据库实例。
- [oracle@DB074 ~]$ ps –ef | grep smon
- oracle 3559 1 0 14:44 ? 00:00:00 ora_smon_cams
- oracle 3662 31107 0 14:47 pts/1 00:00:00 grep smon
- [oracle@DB074 ~]$ sqlplus / as sysdba
- SQL*Plus: Release 11.2.0.4.0 Production on Mon Sep 11 14:47:25 2017
- Copyright (c) 1982, 2013, Oracle. All rights reserved.
- Connected to:
- Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 – 64bit Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
- SYS@cams>shutdown immediate;
- Database closed.
- Database dismounted.
- ORACLE instance shut down.
- SYS@cams>exit
- Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 – 64bit Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
- [oracle@DB074 ~]$ ps –ef | grep smon
- oracle 3675 31107 0 14:47 pts/1 00:00:00 grep smon
- [oracle@DB074 ~]$ ps –ef | grep smon
(5)检查确保没有 oracle 进程启动
- [oracle@DB074 ~]$ ps –ef | grep ora
- root 1987 1945 0 Sep09 ? 00:01:16 hald–addon–storage: polling /dev/sr0 (every 2 sec)
- oracle 3677 31107 0 14:48 pts/1 00:00:00 ps –ef
- oracle 3678 31107 0 14:48 pts/1 00:00:00 grep ora
- root 31106 30170 0 11:34 pts/1 00:00:00 su – oracle
- oracle 31107 31106 0 11:34 pts/1 00:00:00 –bash
(6)切换到 root 用户,完整 删除 安装目录(如 担心手滑,部分操作可以在 oracle 用户下完成)
- [root@DB074 oracle]# cd /
- [root@DB074 oracle]# rm –rf u01/
(7)将 bin 下面的文件删除,如果 不知道具体在 哪个 bin 路径下 (有/usr/bin,/usr/local/bin 等),可以先 查找 下系统路径
- [root@DB074 /]# find / –name oraenv
- /usr/local/bin/oraenv
- [root@DB074 /]# find / –name dbhome
- /usr/local/bin/dbhome
- [root@DB074 /]# find / –name coraenv
- /usr/local/bin/coraenv
- [root@DB074 /]# rm –rf /usr/local/bin/oraenv
- [root@DB074 /]# rm –rf /usr/local/bin/dbhome
- [root@DB074 /]# rm –rf /usr/local/bin/coraenv
(8)删除 配置文件
- [root@DB074 ~]# rm –rf /etc/oraInst.loc
- [root@DB074 ~]# rm –rf /opt/ORCLfmap
- [root@DB074 ~]# rm –rf /etc/oratab
(9)删除 home 目录
- [root@DB074 ~]# rm –rf /home/oracle
(10)删除 oracle 用户 和用户组
- [root@DB074 ~]# userdel –f oracle
- [root@DB074 ~]# groupdel –f oinstall
- [root@DB074 ~]# groupdel –f dba
(11)检查 是否有自启动服务,进行删除
- [root@DB074 ~]#chkconfig –list
- [root@DB074 ~]#chkconfig ––del XXX
3. 方法 对比
(1)两种 方法都能完成数据库软件的删除,使用 deinstall 工具的方法 比较柔和,使用命令行删除的方法比较暴力。
(2)第一种 方法删除后会有部分 信息 保留 , 如环境变量、安装软件、自定义目录等 ; 第二种方法可以对数据库进行完整删除,也可以只删除部分内容。当然,两种 方法 没有好坏之分 , 可以视情况 相结合 使用。
(3)第二种 方法操作过程中会多次在 root 用户下执行 rm -rf 命令 ,建议 用户 小心操作。
(4)文中 没有尝试 使用下载 的deinstall工具 进行 卸载操作,读者可以在工作之余在测试环境中进行尝试。
本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-10/147441.htm