转载 Oracle 12c RAC 连接PDB 报ORA-01033 ORACLE initialization or shutdown in progress 错误解决方法

转载 本文链接:https://www.cndba.cn/dave/article/217

在12c RAC 中每个节点的CDB 管理自己的PDB,也就是说,当我们在节点1对PDB进行操作时,不会影响到节点2的PDB.

示例:

--节点1:
SQL> show pdbs

    CON_ID CON_NAME              OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
     2 PDB$SEED              READ ONLY  NO
     3 DAVE               MOUNTED
SQL> alter pluggable database dave open;

Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME              OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
     2 PDB$SEED              READ ONLY  NO
     3 DAVE               READ WRITE NO
SQL>




--节点2:

SQL> show pdbs

    CON_ID CON_NAME              OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
     2 PDB$SEED              READ ONLY  NO
     3 DAVE               MOUNTED
SQL>



在客户端通过service 连接时:

cndba_rac=
(DESCRIPTION =
 (ADDRESS_LIST =
  (LOAD_BALANCE = yes)
  (FAILOVER=ON)
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.31)(PORT = 1521))
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.41)(PORT = 1521))
 )
 (CONNECT_DATA =
   (SERVICE_NAME =dave)
   (failover_mode=(type=select)(method=basic))
   )
)


因为这种方式配置了负载均衡和故障转移,先tnsping 测试service是否正常。

C:/Users/Dave>tnsping cndba_rac

TNS Ping Utility for 64-bit Windows: Version 11.2.0.4.0 - Production on 27-OCT-2015 19:29:14

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

Used parameter files:
D:/app/Dave/product/11.2.0/dbhome_1/NETWORK/ADMIN/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (LOAD_BALANCE = yes) (FAILOVER=ON) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.31)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.41)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME =dave) (failover_mode=(type=select)(method=basic))))
OK (80 msec)


--连接到PDB:

C:/Users/Dave>sqlplus system/oracle@cndba_rac

SQL*Plus: Release 11.2.0.4.0 Production on Tue Oct 27 19:41:19 2015

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
cndba1

SQL>


此时连接到节点1,所以正常连接,但是RAC 有负载均衡的概念,如果连接到节点2,就会异常,我们这里多连接几次。

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options

C:/Users/Dave>sqlplus system/oracle@cndba_rac

SQL*Plus: Release 11.2.0.4.0 Production on Tue Oct 27 19:43:12 2015

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options

C:/Users/Dave>sqlplus system/oracle@cndba_rac

SQL*Plus: Release 11.2.0.4.0 Production on Tue Oct 27 19:43:35 2015

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

ERROR:
ORA-01033: ORACLE initialization or shutdown in progress
Process ID: 0
Session ID: 0 Serial number: 0


Enter user-name:




ORA-01033的错误出现,但如果我们看CDB,都是正常的,只是PDB没有open。

解决方法就是在启动CDB的时候,一定要检查PDB 是否都mount了,可以创建触发器,在启动CDB的时候,自动open PDB.

触发器如下:

CREATE OR REPLACE TRIGGER open_pdbs
  AFTER STARTUP ON DATABASE
BEGIN
   EXECUTE IMMEDIATE 'ALTER PLUGGABLE DATABASE ALL OPEN';
END open_pdbs;
/
posted @ 2019-07-23 11:44  云刄  阅读(851)  评论(0编辑  收藏  举报