WHCSRL 技术网

Oracle数据库手工删除操作步骤

Oracle数据库手工删除操作步骤

数据库版本

[oracle@oracledb ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sun Oct 31 05:35:09 2021

Copyright (c) 1982, 2013, Oracle.  All rights reserved.
  • 1
  • 2
  • 3
  • 4
  • 5

1、关闭数据库和监听

登录oracle用户,停止Oracle数据库监听

[oracle@oracledb ~]$ echo $ORACLE_SID
oracledb
[oracle@oracledb ~]$ lsnrctl stop

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 31-OCT-2021 03:35:21

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
[oracle@oracledb ~]$ 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

关闭数据库实例

[oracle@oracledb ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sun Oct 31 03:35:43 2021

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

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

2、关闭EM

关闭em:

[oracle@oracledb ~]$ emctl stop dbconsole 
Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0 
Copyright (c) 1996, 2013 Oracle Corporation.  All rights reserved.
http://localhost:1158/em/console/aboutApplication
Stopping Oracle Enterprise Manager 11g Database Control ... 
 ...  Stopped. 
[oracle@oracledb ~]$ 
[oracle@oracledb ~]$ emctl status dbconsole              
Oracle Enterprise Manager 11g Database Control Release 11.2.0.4.0 
Copyright (c) 1996, 2013 Oracle Corporation.  All rights reserved.
http://localhost:1158/em/console/aboutApplication
Oracle Enterprise Manager 11g is not running.
[oracle@oracledb ~]$ 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

3、检查oracle进程

将存在的oracle进程手工kill

[oracle@oracledb ~]$  ps -ef | grep oracle | grep -v grep
avahi       830      1  0 02:31 ?        00:00:00 avahi-daemon: running [oracledb.local]
oracle     3424      1  0 02:31 ?        00:00:00 /app/oracle/product/11.2.0/db_1/perl/bin/perl /app/oracle/product/11.2.0/db_1/bin/emwd.pl dbconsole /app/oracle/product/11.2.0/db_1/localhost_oracledb/sysman/log/emdb.nohup
oracle     3454   3424  0 02:31 ?        00:00:09 /app/oracle/product/11.2.0/db_1/bin/emagent
oracle    15415   3424  1 04:28 ?        00:00:47 /app/oracle/product/11.2.0/db_1/jdk/bin/java -server -Xmx384M -XX:MaxPermSize=400M -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -DORACLE_HOME=/app/oracle/product/11.2.0/db_1 -Doracle.home=/app/oracle/product/11.2.0/db_1/oc4j -Doracle.oc4j.localhome=/app/oracle/product/11.2.0/db_1/localhost_oracledb/sysman -DEMSTATE=/app/oracle/product/11.2.0/db_1/localhost_oracledb -Doracle.j2ee.dont.use.memory.archive=true -Djava.protocol.handler.pkgs=HTTPClient -Doracle.security.jazn.config=/app/oracle/product/11.2.0/db_1/oc4j/j2ee/OC4J_DBConsole_localhost_oracledb/config/jazn.xml -Djava.security.policy=/app/oracle/product/11.2.0/db_1/oc4j/j2ee/OC4J_DBConsole_localhost_oracledb/config/java2.policy -Djavax.net.ssl.KeyStore=/app/oracle/product/11.2.0/db_1/sysman/config/OCMTrustedCerts.txt-Djava.security.properties=/app/oracle/product/11.2.0/db_1/oc4j/j2ee/home/config/jazn.security.props -DEMDROOT=/app/oracle/product/11.2.0/db_1/localhost_oracledb -Dsysman.md5password=true -Drepapi.oracle.home=/app/oracle/product/11.2.0/db_1 -Ddisable.checkForUpdate=true -Doracle.sysman.ccr.ocmSDK.websvc.keystore=/app/oracle/product/11.2.0/db_1/jlib/emocmclnt.ks -Dice.pilots.html4.ignoreNonGenericFonts=true -Djava.awt.headless=true -jar /app/oracle/product/11.2.0/db_1/oc4j/j2ee/home/oc4j.jar -config /app/oracle/product/11.2.0/db_1/oc4j/j2ee/OC4J_DBConsole_localhost_oracledb/config/server.xml
root      18667  18593  0 05:11 pts/3    00:00:00 su - oracle
oracle    18668  18667  0 05:11 pts/3    00:00:00 -bash
oracle    18799  18668  0 05:12 pts/3    00:00:00 ps -ef
[oracle@oracledb ~]$ kill -9 3424
[oracle@oracledb ~]$ kill -9 3454
[oracle@oracledb ~]$ kill -9 15415
[oracle@oracledb ~]$  ps -ef | grep oracle | grep -v grep
avahi       830      1  0 02:31 ?        00:00:00 avahi-daemon: running [oracledb.local]
root      18667  18593  0 05:11 pts/3    00:00:00 su - oracle
oracle    18668  18667  0 05:11 pts/3    00:00:00 -bash
oracle    18884  18668  0 05:13 pts/3    00:00:00 ps -ef
[oracle@oracledb ~]$ kill -9 830
-bash: kill: (830) - Operation not permitted
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

4、删除目录

删除软件和数据库目录

[oracle@oracledb ~]$ echo $ORACLE_BASE
/app/oracle
[oracle@oracledb ~]$ echo $ORACLE_HOME
/app/oracle/product/11.2.0/db_1
[oracle@oracledb ~]$ rm -rf /app/oracle
[oracle@oracledb ~]$ 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

5、删除oracle配置文件

删除/usr/local/bin目录下的dbhome、oraenv、coraenv文件

[oracle@oracledb ~]$ cd /usr/local/bin
[oracle@oracledb bin]$ ll
total 20
-rwxr-xr-x 1 oracle root 5778 Oct 28 22:01 coraenv
-rwxr-xr-x 1 oracle root 2415 Oct 28 22:01 dbhome
-rwxr-xr-x 1 oracle root 6183 Oct 28 22:01 oraenv
[oracle@oracledb bin]$ rm -rf *.*

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

6、删除启动和安装文件

删除oratab,oraInst.loc 文件:

[oracle@oracledb etc]$ ll oratab 
-rw-rw-r-- 1 oracle oinstall 784 Oct 29 01:57 oratab
[oracle@oracledb etc]$ rm -rf oratab
[oracle@oracledb etc]$ cd /home/oracle
[oracle@oracledb ~]$ ll
total 4
-rw-rw-r-- 1 oracle oinstall 60 Oct 28 20:03 oraInst.loc
[oracle@oracledb ~]$ cat oraInst.loc 
inventory_loc=/app/oracle/oraInventory
inst_group=oinstall
[oracle@oracledb ~]$ rm -rf oraInst.loc
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

7、删除临时目录中oracle相关文件

删除/tmp目录安装oracle产生的相关文件:

[oracle@oracledb etc]$ cd /tmp
[oracle@oracledb tmp]$ ll
total 3136
drwxr-xr-x  3 oracle  oinstall    4096 Oct 28 20:08 CVU_11.2.0.4.0_oracle
prw-------  1 root    root           0 Oct 31 01:45 hogsuspend
drwxr-xr-x  2 aisino  aisino         6 Oct 28 01:15 hsperfdata_aisino
drwxr-xr-x  2 oracle  oinstall      18 Oct 31 03:43 hsperfdata_oracle
drwxr-xr-x. 2 wangjun wangjun        6 Oct 27 23:53 hsperfdata_wangjun
drwxr-xr-x  2 oracle  oinstall       6 Oct 28 19:46 logs

[oracle@oracledb tmp]$  rm -rf ./CUV*
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

8、删除oracle用户和用户组

在root用户下执行

[root@oracledb ~]# userdel -r oracle
[root@oracledb ~]# groupdel dba
[root@oracledb ~]# groupdel oinstall
  • 1
  • 2
  • 3

到此为止,重启后Linux系统下的Oracle11g软件和数据库已完全删除!!!

推荐阅读