客户经常有这样的需求,数据库已迁移,但还是希望原库可以打开,就只能只读模式打开了

方法一

SYS@orcl> STARTUP OPEN READ ONLY;
ORACLE instance started.

Total System Global Area 4.0086E+10 bytes
Fixed Size                  2254976 bytes
Variable Size            1.5301E+10 bytes
Database Buffers         2.4696E+10 bytes
Redo Buffers               86413312 bytes
Database mounted.
Database opened.
SYS@orcl> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
ORCL     READ ONLY

SYS@orcl>

方法二、

SYS@orcl> startup mount;
ORACLE instance started.

Total System Global Area 4.0086E+10 bytes
Fixed Size                  2254976 bytes
Variable Size            6442452864 bytes
Database Buffers         3.3554E+10 bytes
Redo Buffers               86413312 bytes
Database mounted.
SYS@orcl> alter database open read only;

Database altered.

SYS@orcl> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
ORCL     READ ONLY


1、只读模式下不可以锁定用户
2、集群环境下,只要有个实例处在只读模式,另外一个实例无法锁定用户
3、集群环境下,某个实例处在restrict模式下,另外一个实例无法进入到只读模式
4、只读模式下,无法执行expdp导出操作

SYS@orcl2> STARTUP OPEN READ ONLY;
ORACLE instance started.

Total System Global Area 4.0086E+10 bytes
Fixed Size                  2254976 bytes
Variable Size            6845106048 bytes
Database Buffers         3.3152E+10 bytes
Redo Buffers               86413312 bytes
Database mounted.
ORA-16002: database already open for read/write access by another instance

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
ORA-31626: job does not exist
ORA-31633: unable to create master table "SYS.SYS_EXPORT_SCHEMA_05"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPV$FT", line 1038
ORA-16000: database open for read-only access

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐