12c, how to connect pluggable database:
- Using the default service connection PDB, after creating the PDB, automatically adding the PDB-named service in the listener;
- The user creates a service in cluster, and the user creates a service using the Srvctl command and relates to the PDB;
- Use the command alter session set CONTAINER=PDB;
- Use Enterprise Manager Express.
1. Use the default service connection PDB:
After the PDB is created, you can see a service with the PDB name in the LSNRCTL status command, as in the following pdb01:
[[email protected] ~]$ lsnrctl Statuslsnrctl forLinux:version12.2.0.1.0 -Production on A-May- . the: -: +Copyright (c)1991, ., Oracle. Allrights reserved. Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) (HOST=ORA12C) (PORT=1521)) STATUS ofThe LISTENER------------------------Alias listenerversion Tnslsnr forLinux:version12.2.0.1.0 -Productionstart Date A-May- . the: +: -Uptime0Days0hr.1 min. -Sectrace Level offSecurity on: Local OS authenticationsnmpOFFListener ParameterFile /U01/App/Oracle/Product/12.2.0/Db_1/Network/Admin/Listener.oralistenerLog File /U01/App/Oracle/Diag/Tnslsnr/ora12c/Listener/Alert/Log. xmllistening Endpoints Summary ... (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) (HOST=ORA12C) (PORT=1521)) ) (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC) (KEY=EXTPROC1521))) Services Summary ... Service "4d852a2714024610e0537838a8c07c53" has1instance (s). Instance "db12g", status ready, have1Handler (s) forThis service ... Service "db12g" has1instance (s). Instance "db12g", status ready, have1Handler (s) forThis service ... Service "Db12gxdb" has1instance (s). Instance "db12g", status ready, have1Handler (s) forThis service ... Service "PDB01" has1 instance (s). Instance "db12g", status ready, have 1 handler (s) forThis service ... The command completed successfully
Here to modify the Tnsname.ora file, add a PDB record, you can connect the PDB:
[[email protected] admin]$ vi Tnsnames.ora # Tnsnames.ora Network ConfigurationFile:/U01/App/Oracle/Product/12.2.0/Db_1/Network/Admin/tnsnames.ora# Generated byOracle configuration Tools. listener_db12g=(ADDRESS=(PROTOCOL=TCP) (HOST=ORA12C) (PORT= 1521)) db12g=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) (HOST=ORA12C) (PORT= 1521)) (Connect_data=(SERVER=dedicated) (Service_Name=db12g)) )pdb01 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = ora12c) (PORT = 1521)) (Connect_data = (SERVER = Dedica TED) (service_name = Pdb01 )))
To connect using the service:
[[email protected] admin]$ sqlplus Scott/Tiger@pdb01SQL*Plus:release12.2.0.1.0Production onFri May A the: -: - .Copyright (c)1982, ., Oracle. Allrights reserved. Connected to: OracleDatabase12c Enterprise Edition Release12.2.0.1.0 -64bitProductionsql>Show Con_namecon_name------------------------------PDB01
2. Add the service connection PDB in the cluster using the SRVCTL command (this applies to the RAC environment):
Create the service, where the CDB name is called the cpdb,pdb name Pdb01,service is Das, the preferred node instance name is CPDB1, and the secondary Select node instance name is CPDB2:
[[email protected] bin] Add - - - - -Available CPDB2
To view the service created:
[[email protected] bin] <databasename>-<servicename>
Also add Tnsname.ora records:
= = = = = Scan-= 1521 ) ) = = dedicated) = Das) ))
Start Service:
[[email protected] bin] - -Service Das
To test the connection:
SQL> connect sys/oracle@das as sysdbaconnected.sql> SHOW con_id; con_id3SQL> SHOW con_name; CON_NAMEPDB01
3. Switch using the command:
[[email protected] bin]$ sqlplus/ asSysdbasql*Plus:release12.1.0.1.0Production onWed May A -: About: - .Copyright (c)1982, ., Oracle. Allrights reserved. Connected to: OracleDatabase12c Enterprise Edition Release12.1.0.1.0 -64bitProduction withThe partitioning,Realapplication Clusters, Automatic Storage Management, olap,advanced Analytics and RealApplication Testing Optionssql>show Con_name; Con_namecdb$rootsql> ALTERSESSIONSETCONTAINER=PDB01; Session altered. SQL>SHOW Con_name; CON_NAMEPDB01
4. Connect using Enterprise Manager Express:
To check if the port is configured for EM before use, you need to configure the port for EM:
Sql> SelectDbms_xdb_config.gethttpsport fromdual; Gethttpsport------------ 0SQL> execDbms_xdb_config.sethttpsport (5500);P L/Sqlproceduresuccessfully completed. SQL> SelectDbms_xdb_config.gethttpsport fromdual; Gethttpsport------------ 5500
Switch to the PDB and configure the EM port for the PDB:
SQL>alterset= pdb01; Session altered. SQL>Select from dual; Gethttpport 5051
Then use EM and the configured port to connect the PDB.
Oracle 12c Connection PDB