重启oracle某个实例_Oracle 启动实例(instance)、打开数据库

Oracle启动实例(instance)、打开数据库

by:授客 QQ:1033553122

启动实例(instance)、打开数据库

1.开启sqlplus

[laiyu@localhost ~]$ sqlplus /NOLOG

SQL*Plus: Release 11.2.0.1.0 Production on Wed Oct 15 20:02:09 2014

Copyright (c) 1982, 2009, Oracle. All rights reserved.

2.AS SYSDBA方式连接到数据库

SQL> CONNECT / AS SYSDBA

Connected to an idle instance.

SQL> CONNECT USERNAME AS SYSDBA

3.开启实例(使用SQL*PLUS)

STARTUP [选项]

选项说明:

NOMOUNT—开启实例,不加载数据库.允许访问数据库,仅用于创建数据库或重建控制文件

MOUNT—开启实例,并加载数据库,但不打开数据库。允许DBA进行操作,但是不允许普通的数据库访问。

OPEN—开启实例,加载数据库,打开数据库,等同STARTUP

FORCE-在启动或关闭遇到问题时,强制启动实例

OPEN RECOVER—在完成完整的备份后启动实例。

注意:通过共享服务处理器即共享池,连接到数据库无法启动实例

例:开启实例,加载并打开数据库

SQL> STARTUP

ORACLE instance started.

Total System Global Area 795127808 bytes

Fixed Size 1339456 bytes

Variable Size 478154688 bytes

Database Buffers 310378496 bytes

Redo Buffers 5255168 bytes

Database mounted.

Database opened.

SQL> STARTUP OPEN

ORACLE instance started.

Total System Global Area 795127808 bytes

Fixed Size 1339456 bytes

Variable Size 478154688 bytes

Database Buffers 310378496 bytes

Redo Buffers 5255168 bytes

Database mounted.

Database opened.

例:开启实例,但不加载数据库,不打开数据库

SQL> STARTUP NOMOUNT

ORACLE instance started.

Total System Global Area 795127808 bytes

Fixed Size 1339456 bytes

Variable Size 478154688 bytes

Database Buffers 310378496 bytes

Redo Buffers 5255168 bytes

例:开启实例,加载数据库,但不打开数据库

SQL> STARTUP MOUNT

ORACLE instance started.

Total System Global Area 795127808 bytes

Fixed Size 1339456 bytes

Variable Size 478154688 bytes

Database Buffers 310378496 bytes

Redo Buffers 5255168 bytes

Database mounted.

适用场景:

1)开启、禁用重做日志归档操作

2)执行数据库完整的备份操作

例:在启动时限制实例访问

在RESTRICT模式下开启实例,加载并打开数据库,这样,仅管理员用户可以访问实例。通常情况下,所有带有CREATE SESSION系统权限的用户可以连接到数据库。RESTRICT模式下,仅同时拥有CREATE SESSION和RESTRICTED SESSION系统权限的用户可以访问实例。数据库管理员无法通过Oracle网络监听器远程访问实例,仅可以本地访问实例

SQL> STARTUP RESTRICT

ORACLE instance started.

Total System Global Area 795127808 bytes

Fixed Size 1339456 bytes

Variable Size 478154688 bytes

Database Buffers 310378496 bytes

Redo Buffers 5255168 bytes

Database mounted.

Database opened.

禁用RESTRICTED SESSION会话

SQL> ALTER SYSTEM DISABLE RESTRICTED SESSION;

System altered.

反之,开启RESTRICTED SESSION会话

SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;

System altered.

适用场景:

1)执行数据导入导出

2)使用SQL*Loader执行数据加载

3)临时阻止用户使用数据

4)执行某些迁移或升级操作

例:强制启动实例

SQL> STARTUP FORCE

ORACLE instance started.

Total System Global Area 795127808 bytes

Fixed Size 1339456 bytes

Variable Size 478154688 bytes

Database Buffers 310378496 bytes

Redo Buffers 5255168 bytes

Database mounted.

Database opened.

适用场景:

1)不能使用NORMAL、IMMEDIATE、TRANSACTIONAL选项执行SHUTDOWN操作

2)启动实例时遇到问题

附:

查看数据库发行版本号

SQL> COL PRODUCT FORMAT A40

SQL> COL VERSION FORMAT A15

SQL> COL STATUS FORMAT A15

SQL> SELECT * FROM PRODUCT_COMPONENT_VERSION;

PRODUCT VERSION STATUS

---------------------------------------- --------------- ---------------

NLSRTL 11.2.0.1.0 Production

Oracle Database 11g Enterprise Edition 11.2.0.1.0 Production

PL/SQL 11.2.0.1.0 Production

TNS for Linux: 11.2.0.1.0 Production

或者

SQL> SELECT * FROM V$VERSION;

BANNER

---------------------------------------------------------------------------

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

PL/SQL Release 11.2.0.1.0 - Production

CORE 11.2.0.1.0 Production

TNS for Linux: Version 11.2.0.1.0 - Production

NLSRTL Version 11.2.0.1.0 – Production

版本号说明

改变数据库可用性

例1:

使数据库处于NOMOUNT状态

SQL> STARTUP NOMOUNT

ORACLE instance started.

Total System Global Area 795127808 bytes

Fixed Size 1339456 bytes

Variable Size 478154688 bytes

Database Buffers 310378496 bytes

Redo Buffers 5255168 bytes

把数据库从NOMOUNT状态改成MOUNT状态

SQL> ALTER DATABASE MOUNT;

Database altered.

把数据库从MOUNT状态变成OPEN状态

SQL> ALTER DATABASE OPEN;

Database altered.

例2:以只读方式打开数据库

SQL> STARTUP MOUNT

ORACLE instance started.

Total System Global Area 795127808 bytes

Fixed Size 1339456 bytes

Variable Size 478154688 bytes

Database Buffers 310378496 bytes

Redo Buffers 5255168 bytes

Database mounted.

SQL> ALTER DATABASE OPEN READ ONLY;

Database altered.

说明:

1)只读模式下,数据库不会往数据文件和日志文件写入数据,不会限制不生成重做日志文件的数据库恢复或改变数据库的操作。

2)只读模式下,查询必须使用一般本地管理表空间作为默认表空间,否则查询失败

例3:以可度可写方式打开数据库

SQL> STARTUP MOUNT

ORACLE instance started.

Total System Global Area 795127808 bytes

Fixed Size 1339456 bytes

Variable Size 478154688 bytes

Database Buffers 310378496 bytes

Redo Buffers 5255168 bytes

Database mounted.

SQL> ALTER DATABASE OPEN READ WRITE;

Database altered.

参考链接:

你可能感兴趣的:(重启oracle某个实例)