天天看點

ORA-44787: Service cannot be switched into

切換pdb時報錯:

SQL> alter session set container=pdb3;
ERROR:
ORA-44787: Service cannot be switched into.

SQL> !oerr ora 44787
44787, 0000, "Service cannot be switched into."
// *Document: Yes
// *Cause: The service did not exist in the new pluggable database or the service was not started in the pluggable database.
// *Action: Use a valid service name for the pluggable database or start the service in the pluggable database first.      

檢查服務名及注冊情況:

----service
SQL> column con_id format 99
SQL> column pdb format a15
SQL> column network_name format a30
select con_id, pdb, network_name from cdb_services where pdb is not null and con_id > 2 order by pdb;SQL> SQL> SQL>

CON_ID PDB             NETWORK_NAME
------ --------------- ------------------------------
     3 PDB3            pdb3.localdomain

---lsnr
$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 07-NOV-2022 03:30:37

Copyright (c) 1991, 2016, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=prodb)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                07-NOV-2022 03:27:35
Uptime                    0 days 0 hr. 3 min. 1 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/19/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/prodb/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=prodb)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "CDB1" has 1 instance(s).
  Instance "CDB1", status UNKNOWN, has 1 handler(s) for this service...
Service "CDB1.localdomain" has 1 instance(s).
  Instance "CDB1", status READY, has 1 handler(s) for this service...
Service "CDB1XDB.localdomain" has 1 instance(s).
  Instance "CDB1", status READY, has 1 handler(s) for this service...
Service "CDB2" has 1 instance(s).
  Instance "CDB2", status UNKNOWN, has 1 handler(s) for this service...
Service "DB12" has 1 instance(s).
  Instance "DB12", status UNKNOWN, has 1 handler(s) for this service...
Service "DB11" has 2 instance(s).
  Instance "DB11", status UNKNOWN, has 1 handler(s) for this service...
  Instance "DB11", status READY, has 1 handler(s) for this service...
Service "CDB3" has 1 instance(s).
  Instance "CDB3", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

未發現pdb3.localdomain注冊到監聽      

解決辦法:

SQL> alter pluggable database pdb3 close immediate;
SQL> alter pluggable database pdb3 open;
SQL> alter session set container=pdb3;