命令行删除Oracle实例

本文的所有操作过程已经在单实例数据库测试环境中执行,需要删除实例的数据库版本为Oracle 11.2.0.1.0,需要删除的数据库实例名为bgsp。

步骤一:关闭数据库
1.export ORACLE_SID=bgsp
2.sqlplus / as sysdba
3.shutdown immediate

步骤二:删除实例相关文件,此处实例为bgsp(如出现文件存放在其他路径的情况,需特殊处理,如将下文find命令中$ORACLE_BASE命令进行替换)
1.find $ORACLE_BASE/ -name bgsp
[oracle@localhost-a ~]$ find $ORACLE_BASE/ -name bgsp
/Oracle_11g/flash_recovery_area/bgsp
/Oracle_11g/oradata/bgsp
/Oracle_11g/cfgtoollogs/dbca/bgsp
/Oracle_11g/cfgtoollogs/emca/bgsp
/Oracle_11g/oracle/localhost-a_bgsp/sysman/emd/state/storage/bgsp
/Oracle_11g/admin/bgsp
/Oracle_11g/diag/rdbms/bgsp
/Oracle_11g/diag/rdbms/bgsp/bgsp
2.用命令删除查询后文件(注意:如果上一步骤查出来的文件有非实例相关文件,则不能直接通过 "-exec rm -rf {} \;"命令进行删除,建议一条一条删除,以免误删除文件)
find $ORACLE_BASE/ -name bgsp -exec rm -rf {} \;
[oracle@localhost-a ~]$ find $ORACLE_BASE/ -name bgsp -exec rm -rf {} \;
find: `/Oracle_11g/flash_recovery_area/bgsp': No such file or directory
find: `/Oracle_11g/oradata/bgsp': No such file or directory
find: `/Oracle_11g/cfgtoollogs/dbca/bgsp': No such file or directory
find: `/Oracle_11g/cfgtoollogs/emca/bgsp': No such file or directory
find: `/Oracle_11g/oracle/localhost-a_bgsp/sysman/emd/state/storage/bgsp': No such file or directory
find: `/Oracle_11g/admin/bgsp': No such file or directory
find: `/Oracle_11g/diag/rdbms/bgsp': No such file or directory
[oracle@localhost-a ~]$ find $ORACLE_BASE/ -name bgsp

步骤三:删除配置文件(先查询,然后检查是否有非实例相关文件,然后根据情况删除)
1.find $ORACLE_BASE/* -name '*[Bb][Gg][Ss][Pp]*' | grep -v admin | grep -v oradata | xargs rm -rf
[oracle@localhost-a ~]$ find $ORACLE_BASE/* -name '*[Bb][Gg][Ss][Pp]*' | grep -v admin | grep -v oradata
/Oracle_11g/flash_recovery_area/BGSP
/Oracle_11g/oracle/rdbms/log/bgsp_ora_12586.trc
/Oracle_11g/oracle/rdbms/log/bgsp_ora_15261.trc
/Oracle_11g/oracle/rdbms/log/bgsp_ora_19341.trc
/Oracle_11g/oracle/rdbms/log/bgsp_ora_19562.trc
/Oracle_11g/oracle/rdbms/log/bgsp_ora_7391.trc
/Oracle_11g/oracle/rdbms/log/bgsp_ora_15191.trc
/Oracle_11g/oracle/rdbms/log/bgsp_ora_17827.trc
/Oracle_11g/oracle/rdbms/log/bgsp_ora_12319.trc
/Oracle_11g/oracle/localhost-a_bgsp
/Oracle_11g/oracle/localhost-a_bgsp/sysman/emd/collection/oracle_database_bgsp.xml
/Oracle_11g/oracle/oc4j/j2ee/OC4J_DBConsole_localhost-a_bgsp
/Oracle_11g/oracle/dbs/orapwbgsp
/Oracle_11g/oracle/dbs/lkBGSP
/Oracle_11g/oracle/dbs/spfilebgsp.ora
/Oracle_11g/oracle/dbs/hc_bgsp.dat
/Oracle_11g/oracle/EMStagePatches_bgsp
[oracle@localhost-a ~]$ find $ORACLE_BASE/* -name '*[Bb][Gg][Ss][Pp]*' | grep -v admin | grep -v oradata | xargs rm -rf
[oracle@localhost-a ~]$ find $ORACLE_BASE/* -name '*[Bb][Gg][Ss][Pp]*' | grep -v admin | grep -v oradata

步骤四:删除实例配置文件中的信息
1.vi /etc/oratab
2.找到 bgsp:/Oracle_11g/oracle:N
3.将该行信息删除,并保存文件

经过以上步骤可实现命令行干净的实例删除。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/854acb82028eee2c786e65f583f0c88d.html