904 Bedford St, New York NY 10014

(+1) 5184-453-1514

Network Connections- Containers and Pluggables

If you are initiating a remote connection through the network, then you need to first set up a listener on the target database server and create a password file (see Chapter 2 for details). Once the listener and password files are established, you can connect remotely over the network, as shown here:

$ sqlplus user/password@connection_string SQL> show user con_id con_name user

USER is “user” CON_ID———–3

CON_NAME—————MMPDB

USER is “user”

For details on implementing a listener for pluggables, see Chapter 2; we also review it later in this chapter.

Displaying Currently Connected Container Information

There are a couple of easy techniques for displaying the name of the CDB that you are currently connected to. This example uses the SHOW command to display the container ID, the name, and the user:

SQL> show con_id con_name user

You can also display the same information via an SQL query:

SQL> SELECT SYS_CONTEXT(‘USERENV’, ‘CON_ID’) AS con_id, SYS_CONTEXT(‘USERENV’, ‘CON_NAME’) AS cur_container, SYS_CONTEXT(‘USERENV’, ‘SESSION_USER’) AS cur_user

FROM DUAL;

Here is some sample output:

CON_ID                   CUR_CONTAINER           CUR_USER

1                               CDB$ROOT                     USER

Starting/Stopping the Root Container

You can start/stop the CDB only while connected as a privileged user to the root container. To start a CDB, first connect as SYS or a user with SYSOPER privileges, and issue the startup command:

$ sqlplus / as sysdba SQL> startup;

Starting the CDB database does not open any associated PDBs unless you have saved the state of the PDB to open automatically. It is recommended to make sure you set the PDBs to start automatically. You can open all PDBs with this command:

SQL> alter pluggable database all open;

To shut down a CDB database, issue the following command:

SQL> shutdown immediate;

The prior line shuts down the CDB instance and disconnects any users connected to the database. If any pluggable databases are open, they are closed, and users are disconnected.

For Oracle Restart, the SRVCTL command can be used to start, modify, and stop instances. SRVCTL can be used for CDBs and PDBs, and services need to be created for the PDBs.

$ srvctl start database

The environment variables are part of the Oracle Restart configuration, and there are several parameters that can be passed in for starting up with different spfiles and parameter files using start options such as mount, restrict, open, and recover.

$ srvctl stop database – db mmdb23c

The default option is immediate, but you can specify stop options of normal and abort.

To create a service for a PDB, use the following:

$ srvctl add service -db mmdb23c -service mmpdbsrv -pdb mmpdb

Now you can use the service to perform commands in a RAC environment or configurations for the PDB. You can modify, stop, and start services, as well as relocate, remove, and get the status of services.

Search

Popular Posts

  • Recovery Catalog Versions – RMAN Backups and Reporting
    Recovery Catalog Versions – RMAN Backups and Reporting

    I recommend that you create a recovery catalog for each version of the target databases that you are backing up. Doing so will save you some headaches with compatibility issues and upgrades. I have found it easier to use a recovery catalog when the database version of the rman client is the same version used…

  • Registering a Target Database – RMAN Backups and Reporting
    Registering a Target Database – RMAN Backups and Reporting

    Now, you can register a target database with the recovery catalog. Log in to the target database server. Ensure that you can establish connectivity to the recovery catalog database. For instance, one approach is to populate the TNS_ADMIN/tnsnames.ora file with an entry that points to the remote database. On the target database server, register the…

  • Creating a Recovery Catalog – RMAN Backups and Reporting
    Creating a Recovery Catalog – RMAN Backups and Reporting

    When I use a recovery catalog, I prefer to have a dedicated database that is used only for the recovery catalog. This ensures that the recovery catalog is not affected by any maintenance or downtime required by another application (and vice versa). Listed next are the steps for creating a recovery catalog: 1. Create a…

Tags