Oracle启动停止规范
更新:HHH   时间:2023-1-7


本启动停止规范适用于单实例数据库

一. 启动数据库:

sqlplus / as sysdba
SQL> startup

启动成功后,启动监听
lsnrctl status
启动监听后,动态监听需要等待一分钟左右,才可以将服务注册成功。或手动在SQLPLUS中发出alter system register;

二. 关闭数据库:

  1. 应用停掉

  2. 停监听器
    ps -ef|grep LOCAL|wc -l
    [oracle@r11g ~]$ lsnrctl stop

  3. 查看有没有JOB--如有需要确定是否停掉
    ps -ef|grep ora_j

  4. 查看有没有事务还未提交的--如有事务未提交确认是否需要等待事务完成
    sqlplus '/ as sysdba'
    select instance_name,status from v$instance;
    select open_mode,name from v$database;

是否有大的查询在进行
select count() from v$transaction;
select count(
) from v$session_longops where time_remaining>0;

是否有大的事务在进行
select sum(used_ublk) from v$transaction; ---如果有大量返回,参考本文最后
select to_char(start_time,'yyyy/mm/dd hh34:mi:ss') start_t from v$transaction;

是否有事务需要在数据库OPEN时进行实例恢复
select from v$fast_start_transactions;
and/or
select
from v$fast_start_servers;

  1. 手工切换log
    SQL> alter system switch logfile;
    SQL> /
    System altered.
    SQL> /
    System altered.

  2. 做checkpoint
    目的是把脏数据写入数据文件,避免造成数据丢失,减小关闭启动不起来这种现象发生
    SQL> alter system checkpoint;
    SQL> /
    System altered.
    SQL> /
    System altered.
    SQL> /
    System altered

  3. 关库
    SQL> shutdown immediate;
返回关系型数据库教程...