新建的pdb默认处于mount状态,因为只有一个和pdb同名的服务与之相连,这个服务oracle建议用于管理。
实验建一个pdb
SQL> create pluggable database four admin user pdbadmin identified by dingjia ; Pluggable database created. SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 THIRD READ WRITE NO 4 FOUR MOUNTED
看到这个pdb处于mount状态,建一个服务
[oracle@rac2 ~]$ srvctl add service -d short -s web_online -pdb four -preferred short2
此时pdb仍然处于mount状态,需要重新启动:
SQL> startup force; ORACLE instance started. Total System Global Area 1207959552 bytes Fixed Size 2923776 bytes Variable Size 503317248 bytes Database Buffers 687865856 bytes Redo Buffers 13852672 bytes Database mounted. show pdbs; Database opened. SQL> CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 THIRD READ WRITE NO 4 FOUR READ WRITE NO SQL>
重新启动后处于open状态,
[oracle@rac1 ~]$ sqlplus / as sysdba SQL*Plus: Release 12.1.0.2.0 Production on Wed Jul 15 11:33:28 2020 Copyright (c) 1982, 2014, 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> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 THIRD READ WRITE NO 4 FOUR MOUNTED SQL> startup force; ORACLE instance started. Total System Global Area 1207959552 bytes Fixed Size 2923776 bytes Variable Size 503317248 bytes Database Buffers 687865856 bytes Redo Buffers 13852672 bytes Database mounted. Database opened. SQL> show pdbs; CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 THIRD READ WRITE NO 4 FOUR MOUNTED SQL>
在另外一个节点上重新启动,pdb照样处于mount状态,因为这个服务没有在这个节点上。
关闭这个service并不会关闭对应的pdb srvctl stop service -db short -service web_online