tag:blogger.com,1999:blog-30059344688876877812024-03-19T08:34:19.443+01:00Database administrator workshopMy own Oracle journey. Technical information and guidance on real world scenarios.
I hope you enjoy this blog.Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.comBlogger154125tag:blogger.com,1999:blog-3005934468887687781.post-23594205261754155682014-06-13T12:49:00.000+01:002014-06-25T10:46:18.321+01:00How to encrypt the data (tablespace or column's table) using a software keystore previously known as Oracle WalletTo create a standard Oracle wallet and then add a master key to it you have to follow few basic steps:<br />
<b>1) Configure the sqlnet.ora file to define a file system location for the Software Keystore</b><br />
<b>2) Create the Software Keystore </b><br />
<b>3) Opening a Software Keystore </b><br />
<b>4) Setting the TDE Master Encryption Key in the Software Keystore </b><br />
<b>5) Encrypt the Data </b><br />
<br />
The first four steps are already described <a href="http://dbaworkshop.blogspot.it/2014/06/How-to-configure-Transparent-Data-Encryption-using-a-software-keystore-the-right-way-to-call-the-old-Oracle-Wallet.html" target="_blank">here</a>. Now it's time to encrypt your data.<br />
<br />
<b><span style="font-size: large;">5) Encrypt the Data </span></b><br />
Once you have created an Oracle Wallet and set a TDE master key in it, you can proceed to encrypt your data. Let's start creating a new encrypted tablespace first and then a column's table.
My current data files:
<br />
<pre class="cpp" name="code">SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
/app/oracle/oradata/CDB001/system01.dbf
/app/oracle/oradata/CDB001/sysaux01.dbf
/app/oracle/oradata/CDB001/undotbs01.dbf
/app/oracle/oradata/CDB001/users01.dbf</pre>
The statement to create an encrypted tablespace:
<br />
<pre class="cpp" name="code">SQL> create tablespace ts_encrypted datafile '/app/oracle/oradata/CDB001/ts_encrypted01.dbf' size 10M encryption default storage(encrypt);
Tablespace created.</pre>
Information about the encrypted tablespace available in the database.
<br />
<pre class="cpp" name="code">SQL> select a.name, b.TS#, b.ENCRYPTEDTS, b.ENCRYPTIONALG, b.CON_ID from V$TABLESPACE A, V$ENCRYPTED_TABLESPACES B
2 where A.ts# = B.ts#;
NAME TS# ENCRYPTEDTS ENCRYPTIONALG CON_ID
------------ --- ----------- ------------- ------
TS_ENCRYPTED 5 AES128 YES 1</pre>
How is it possible to test if the data is encrypted or not ? I'm going to create a table on the USERS (unencrypted) tablespace and another on the TS_ENCRYPTED tablespace. Because the Oracle Wallet is already open I can create on the encrypted tablespace the t1_encrypted table and insert some rows in it.
<br />
<pre class="cpp" name="code">SQL> create table t1_not_encrypted (text varchar2(255)) tablespace USERS;
Table created.
SQL> create table t1_encrypted (text varchar2(255)) tablespace TS_ENCRYPTED;
Table created.
SQL> insert into t1_not_encrypted values ('my name is marcov');
1 row created.
SQL> insert into t1_encrypted values ('the secrets of marcov');
1 row created.
SQL> commit;
Commit complete.</pre>
Flush the buffer cache to be sure all data is written to the datafiles.
<br />
<pre class="cpp" name="code">SQL> alter system flush buffer_cache;
System altered.</pre>
I'm able to grep and see the text on the USERS tablespace, but not that one on the TS_ENCRYPTED tablespace.
<br />
<pre class="cpp" name="code">[oracle@localhost oracle]$ strings /app/oracle/oradata/CDB001/users01.dbf|grep "my name is"
my name is marcov
[oracle@localhost oracle]$ strings /app/oracle/oradata/CDB001/ts_encrypted01.dbf|grep "secrets"
[oracle@localhost oracle]$</pre>
Let's see what happens when the Oracle Wallet is closed. The following command closes an open Oracle Wallet.
<br />
<pre class="cpp" name="code">SQL> administer key management set keystore close identified by "0racl30racle3";
keystore altered.
SQL> select * from v$encryption_wallet;
WRL_TYPE WRL_PARAMETER STATUS WALLET_TYPE WALLET_OR FULLY_BAC CON_ID
-------- -------------------------------------------------------- ------ ----------- --------- --------- ------
FILE /app/oracle/product/12.1.0/dbhome_1/admin/CDB001/wallet CLOSED UNKNOWN SINGLE UNDEFINED 0</pre>
When the Oracle Wallet is closed you can query every tables but those based on an encrypted tablespace.
<br />
<pre class="cpp" name="code">SQL> select * from t1_not_encrypted;
TEXT
-----------------
my name is marcov
SQL> select * from t1_encrypted;
select * from t1_encrypted
*
ERROR at line 1:
ORA-28365: wallet is not open</pre>
You have to open again the Oracle Wallet to successfully execute the query
<br />
<pre class="cpp" name="code">SQL> administer key management set keystore open identified by "0racl30racle3";
keystore altered.
SQL> select * from t1_encrypted;
TEXT
---------------------
the secrets of marcov</pre>
Let's see how a closed Oracle Wallet affects an encrypted column of a table.
I'm going to create a new table with two columns: one is encrypted and the other is not encrypted.
<br />
<pre class="cpp" name="code">SQL> create table c##marcov.t2_column_encrypted (text varchar2(255), text_encrypted varchar2(255) encrypt) tablespace USERS;
Table created.
SQL> insert into c##marcov.t2_column_encrypted values ('this column is not encrypted', 'the secrets of marcov');
1 row created.
SQL> commit;
Commit complete.</pre>
The Oracle Wallet is closed.
<br />
<pre class="cpp" name="code">SQL> administer key management set keystore close identified by "0racl30racle3";
keystore altered.</pre>
When the Oracle Wallet is closed I can able to query the non-encrypted column.
<br />
<pre class="cpp" name="code">SQL> select text from c##marcov.t2_column_encrypted;
TEXT
----------------------------
this column is not encrypted</pre>
But when I try to query the encrypted column it fails:
<br />
<pre class="cpp" name="code">SQL> select * from c##marcov.t2_column_encrypted;
select * from c##marcov.t2_column_encrypted
*
ERROR at line 1:
ORA-28365: wallet is not open</pre>
I need first to open the Oracle Wallet
<br />
<pre class="cpp" name="code">SQL> administer key management set keystore open identified by "0racl30racle3";
keystore altered.</pre>
Now I can query again the encrypted column of my table.
<br />
<pre class="cpp" name="code">SQL> select * from c##marcov.t2_column_encrypted;
TEXT TEXT_ENCRYPTED
---------------------------- ---------------------
this column is not encrypted the secrets of marcov</pre>
<br />
That's all.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-xqMvy2CkUNA/U5mThc7gydI/AAAAAAAAATw/6Qi8m26wNpc/s1600/Screenshot+from+2014-06-12+13:45:09.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-xqMvy2CkUNA/U5mThc7gydI/AAAAAAAAATw/6Qi8m26wNpc/s1600/Screenshot+from+2014-06-12+13:45:09.png" height="172" width="640" /></a></div>
<br />Anonymoushttp://www.blogger.com/profile/03503390772188094838noreply@blogger.com412tag:blogger.com,1999:blog-3005934468887687781.post-17080019281277924922014-06-12T15:00:00.000+01:002014-06-23T11:12:00.273+01:00How to configure Transparent Data Encryption using a software keystore, the right way to call the old Oracle WalletOracle uses an operating system file to contains authentication and signing credentials: this file, named ewallet.p12, is the so called Oracle wallet (now called more appropriately software/hardware keystore)<br />
<br />
The transparent data encryption (TDE) feature, used when you encrypt an entire tablespace, columns of a table, safely export data or complete your backup, is strongly based on the creation of the Oracle wallet to store the master key of the database.<br />
There are two kind of Oracle wallets: that one which you must manually open each time you restart a database instance to reenable encryption and decryption and that one automatically opened when an encryption operation is required.<br />
<br />
The first is protected by a password specified when you create it and before accessing the keys contained you are responsible of its opening.
The second is protected by a system-generated password and you don't need to open it manually.<br />
Once an Oracle Wallet is open, it remains open until you shutdown the database or manually close it.
<br />
<br />
As already stated here when talking about granting the minimum privilege, the Oracle Database 12c introduced the syskm administrative privilege: with this type of privilege you can perform every kind of key management operation without using the powerful sysdba privilege.<br />
It also unified some already known commands under a set of key management statements (ADMINISTER KEY MANAGEMENT) that you can see in today's scenario.<br />
<br />
To create a standard Oracle wallet and then add a master key to it you have to follow few basic steps:<br />
<b>1) Configure the sqlnet.ora file to define a file system location for the Software Keystore</b><br />
<b>2) Create the Software Keystore </b><br />
<b>3) Opening a Software Keystore </b><br />
<b>4) Setting the TDE Master Encryption Key in the Software Keystore </b><br />
<b>5) Encrypt the Data (have a look at the <a href="http://dbaworkshop.blogspot.it/2014/06/How-to-encrypt-the-data-tablespace-or-columns-table-using-a-software-keystore-previously-known-as-Oracle-Wallet.html" target="_blank">next post</a>) </b><br />
<br />
<b><span style="font-size: large;">1) Configure the sqlnet.ora file </span></b><br />
Oracle should know where to find the Oracle Wallet so you have to define a directory accessible by the Oracle Software.<br />
In the multitenant solution the Oracle Wallet location is valid for the CDB and every PDBs at the same time.
Edit your sqlnet.ora file and use the following syntax to let the database know where the software keystore is located on file system.<br />
Be sure that the directory exists to avoid the error "ORA-46633: creation of a password-based keystore failed":
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom admin]$ pwd
/opt/app/oracle/product/12.1.0/db_1/network/admin
[oracle@vsi08devpom admin]$ echo "ENCRYPTION_WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=/app/oracle/product/12.1.0/dbhome_1/admin/CDB001/wallet)))" >> sqlnet.ora
</pre>
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom admin]$ cat sqlnet.ora
# sqlnet.ora Network Configuration File: /app/oracle/product/12.1.0/dbhome_1/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
ENCRYPTION_WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=/app/oracle/product/12.1.0/dbhome_1/admin/CDB001/wallet)))</pre>
<br />
<b><span style="font-size: large;">2) Create the Oracle Wallet </span></b><br />
It's possible to create the Oracle Wallet using the owm gui utility (as you can read <a href="http://dbaworkshop.blogspot.com/2014/06/Steps-to-create-open-and-close-an-Oracle-Wallet-using-Oracle-Wallet-Manager.html" target="_blank">on this post</a>) or from sqlplus with a new set of key management statements (ADMINISTER KEY MANAGEMENT).<br />
The steps to create an Oracle Wallet must be executed from the sqlplus command line with a user who has been granted the new SYSKM administrative privilege:<br />
when in a multitenant environment you have to log in to the root container.
<br />
<pre class="cpp" name="code">SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT</pre>
<br />
To avoid the error "ORA-46633: creation of a password-based keystore failed", the directory you are going to specify in the create keystore statement must be already present.
<br />
<pre class="cpp" name="code">SQL> ADMINISTER KEY MANAGEMENT CREATE KEYSTORE '/app/oracle/product/12.1.0/dbhome_1/admin/CDB001/missing_directory' IDENTIFIED BY "0racle0racle";
ADMINISTER KEY MANAGEMENT CREATE KEYSTORE '/app/oracle/product/12.1.0/dbhome_1/admin/CDB001/missing_directory' IDENTIFIED BY "0racle0racle"
*
ERROR at line 1:
ORA-46633: creation of a password-based keystore failed</pre>
To create the keystore under the path specified in the sqlnet.ora file use the following statement:
<br />
<pre class="cpp" name="code">SQL> ADMINISTER KEY MANAGEMENT CREATE KEYSTORE '/app/oracle/product/12.1.0/dbhome_1/admin/CDB001/wallet' IDENTIFIED BY "0racle0racle";
keystore altered.</pre>
Querying the V$ENCRYPTION_WALLET view you can see the location, status and type of the wallet.
<br />
<pre class="cpp" name="code">SQL> select * from v$encryption_wallet;
WRL_TYPE WRL_PARAMETER STATUS WALLET_TYPE WALLET_OR FULLY_BAC CON_ID
-------- -------------------------------------------------------- ------ ----------- --------- --------- ------
FILE /app/oracle/product/12.1.0/dbhome_1/admin/CDB001/wallet CLOSED UNKNOWN SINGLE UNDEFINED 0</pre>
<br />
<b><span style="font-size: large;">3) Opening a Software Keystore </span></b><br />
To setup, configure and use encrypted tablespace or column the Oracle Wallet needs to be open.<br />
The v$encryption_wallet view says the status of the wallet is closed so you need to open it using the following statement:
<br />
<pre class="cpp" name="code">SQL> administer key management set keystore open identified by "0racle0racle";
keystore altered.</pre>
The status is now OPEN_NO_MASTER_KEY. This means that the wallet is open, but still a master key needs to be created.
<br />
<pre class="cpp" name="code">SQL> select * from v$encryption_wallet;
WRL_TYPE WRL_PARAMETER STATUS WALLET_TYPE WALLET_OR FULLY_BAC CON_ID
-------- -------------------------------------------------------- ------------------ ----------- --------- --------- ------
FILE /app/oracle/product/12.1.0/dbhome_1/admin/CDB001/wallet OPEN_NO_MASTER_KEY UNKNOWN PASSWORD UNDEFINED 0</pre>
<br />
<b><span style="font-size: large;">4) Setting the TDE Master Encryption Key in the Software Keystore</span></b><br />
You need to set a master key for the Oracle wallet used in the TDE activities on tables or tablespace.
<br />
<pre class="cpp" name="code">SQL> ADMINISTER KEY MANAGEMENT SET KEY USING TAG 'tde_mek' IDENTIFIED BY "0racle0racle" WITH BACKUP USING 'tde_mek_backup';
keystore altered.</pre>
If you need to change the password of your Oracle Wallet because of your company's security guidelines, you must use the WITH BACKUP option: in this way you are forced to take a backup of your "old" wallet.
<br />
<pre class="cpp" name="code">SQL> ADMINISTER KEY MANAGEMENT ALTER KEYSTORE PASSWORD IDENTIFIED BY "0racle0racle" set "0racl30racle3";
ADMINISTER KEY MANAGEMENT ALTER KEYSTORE PASSWORD IDENTIFIED BY "0racle0racle" set "0racl30racle3"
*
ERROR at line 1:
ORA-46631: keystore needs to be backed up</pre>
A change of the password doesn't prevent the normal use of every TDE operations: they continue to work as usual with the new password without interruptions. You need to provide the old password and the new password.
<br />
<pre class="cpp" name="code">SQL> ADMINISTER KEY MANAGEMENT ALTER KEYSTORE PASSWORD IDENTIFIED BY "0racle0racle" set "0racl30racle3" WITH BACKUP USING 'tde_mek_backup_001';
keystore altered.</pre>
<br />
To see now how to encrypt you data, read this post.<br />
<br />
That's all.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-QduLEuvNhlk/U5mPi9acZ2I/AAAAAAAAATo/8EXgU8f_9xc/s1600/Screenshot+from+2014-06-12+13%253A30%253A27.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-QduLEuvNhlk/U5mPi9acZ2I/AAAAAAAAATo/8EXgU8f_9xc/s1600/Screenshot+from+2014-06-12+13%253A30%253A27.png" height="164" width="640" /></a></div>
<br />Anonymoushttp://www.blogger.com/profile/03503390772188094838noreply@blogger.com143tag:blogger.com,1999:blog-3005934468887687781.post-17751612233958571042014-06-11T11:37:00.001+01:002014-06-12T09:36:12.923+01:00Steps to create, open and close an Oracle Wallet using Oracle Wallet Manager <br />
It's possible to create the Oracle Wallet using the <b>owm</b> gui utility or from <b>sqlplus</b> with a new set of key management statements (ADMINISTER KEY MANAGEMENT).<br />
<br />
Let's see first in this post how to proceed using the owm gui utility.<br />
Using the Oracle Wallet Manager it's possible to create standard wallets (PKCS #12, Public-Key Cryptography Standards) on file system or<br />
wallets (PKCS #11) used in conjunction of hardware security modules (HSM), tokens or smart cards.<br />
<br />
From the command line type:<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ owm &</pre>
<br />
The following screenshot appears:<br />
<a href="http://1.bp.blogspot.com/-h1deWItTI9w/U5guYKsWTyI/AAAAAAAAASc/_0SlYDjlux4/s1600/Screenshot+from+2014-05-23+11:04:08.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-h1deWItTI9w/U5guYKsWTyI/AAAAAAAAASc/_0SlYDjlux4/s1600/Screenshot+from+2014-05-23+11:04:08.png" height="307" width="400" /></a><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
To create a new wallet from the <b>Wallet</b> menu select <b>New</b>. If the Oracle software detects you don't have a default directory for the wallet it will ask you to create one: you can always choose a custom directory. The default path of the wallet directory is: $ORACLE_HOME/owm/wallets/user_name (/app/oracle/product/12.1.0/dbhome_1/owm/wallets/oracle in my case).<br />
<a href="http://3.bp.blogspot.com/-VjC-QPO0EoY/U5guhtqeY3I/AAAAAAAAASk/vWl88-Upj2Q/s1600/Screenshot+from+2014-05-23+11:09:04.png" imageanchor="1" style="clear: left; display: inline !important; margin-bottom: 1em; margin-right: 1em; text-align: center;"><img border="0" src="http://3.bp.blogspot.com/-VjC-QPO0EoY/U5guhtqeY3I/AAAAAAAAASk/vWl88-Upj2Q/s1600/Screenshot+from+2014-05-23+11:09:04.png" height="148" width="400" /></a><br />
<br />
In the next dialog box you are prompted to set a password, having a minimum of eight characters, containing alphabetic characters and numbers or special characters.<br />
<a href="http://3.bp.blogspot.com/-nc6l9sFOlDI/U5guhl6TP2I/AAAAAAAAATU/At-kJt6d8Kw/s1600/Screenshot+from+2014-05-23+11:20:24.png" imageanchor="1" style="clear: left; display: inline !important; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-nc6l9sFOlDI/U5guhl6TP2I/AAAAAAAAATU/At-kJt6d8Kw/s1600/Screenshot+from+2014-05-23+11:20:24.png" height="181" width="400" /></a><br />
<br />
As you can see on the following alert a new empty wallet has been created. If you need to add also a certificate request select Yes, otherwise to simply return to the Oracle Wallet Manager main window select No as I have done.<br />
<a href="http://1.bp.blogspot.com/-J00-kcpanwA/U5guhgCFtaI/AAAAAAAAASo/tKWINt4-Sy0/s1600/Screenshot+from+2014-05-23+11:22:26.png" imageanchor="1" style="clear: left; display: inline !important; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-J00-kcpanwA/U5guhgCFtaI/AAAAAAAAASo/tKWINt4-Sy0/s1600/Screenshot+from+2014-05-23+11:22:26.png" height="145" width="400" /></a><br />
<br />
From the Oracle Wallet Manager main window you can see the new wallet in the left pane. It's time to save the wallet: from the <b>Wallet</b> menu select "<b>Save In System Default</b>"<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-VD87p4BR2ws/U5guiF7E_lI/AAAAAAAAASs/6NI6Pib1jFI/s1600/Screenshot+from+2014-05-23+11:24:48.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-VD87p4BR2ws/U5guiF7E_lI/AAAAAAAAASs/6NI6Pib1jFI/s1600/Screenshot+from+2014-05-23+11:24:48.png" height="307" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
If the wallet is successfully saved the following message is displayed at the bottom of the window:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-mOnQfG8vGcI/U5guiqSc8UI/AAAAAAAAAS0/wLLm_S2YywY/s1600/Screenshot+from+2014-05-23+11:25:29.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-mOnQfG8vGcI/U5guiqSc8UI/AAAAAAAAAS0/wLLm_S2YywY/s1600/Screenshot+from+2014-05-23+11:25:29.png" height="56" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
Only when you save the new wallet you can find it under the specified directory.<br />
<pre class="cpp" name="code">[oracle@localhost oracle]$ pwd
/app/oracle/product/12.1.0/dbhome_1/owm/wallets/oracle
[oracle@localhost oracle]$ ls
cwallet.sso cwallet.sso.lck ewallet.p12 ewallet.p12.lck</pre>
<br />
If you want to close the wallet from the graphical user interface of the Oracle Wallet Manager, start again it and from Wallet menu of the main window select Close.<br />
<br />
If you want to open again the wallet, from <b>Wallet</b> menu of the main window select <b>Open</b> and then enter the path of the wallet. When prompted enter the right password.<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-RHZyKmXsxOc/U5guizHoM-I/AAAAAAAAATE/zYJWNDHqQwo/s1600/Screenshot+from+2014-06-11+12:19:29.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-RHZyKmXsxOc/U5guizHoM-I/AAAAAAAAATE/zYJWNDHqQwo/s1600/Screenshot+from+2014-06-11+12:19:29.png" height="362" width="400" /></a></div>
<a href="http://1.bp.blogspot.com/-EO252pccobU/U5gujA-v4FI/AAAAAAAAATA/fSWzt1EqxUU/s1600/Screenshot+from+2014-06-11+12:19:50.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-EO252pccobU/U5gujA-v4FI/AAAAAAAAATA/fSWzt1EqxUU/s1600/Screenshot+from+2014-06-11+12:19:50.png" height="116" width="320" /></a><br />
<div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
That's all.</div>
Anonymoushttp://www.blogger.com/profile/03503390772188094838noreply@blogger.com61tag:blogger.com,1999:blog-3005934468887687781.post-58140204280165311782014-05-15T13:37:00.000+01:002014-05-15T13:37:45.488+01:00How to use the new SYSBACKUP privilege to perform backup and recovery tasks without accessing to table dataThe SYSBACKUP is a new privilege introduced in the Oracle Database 12c release that allows a user to perform any backup or recovery operations.<br />
<br />
It is heartily suggested to create a new user with the SYSBACKUP privilege granted and perform daily backup activities with that new user, instead of using directly the SYSBACKUP user created by default during the database installation: the SYSBACKUP user should even remain locked. <br />
<br />
Before proceeding I will need to create a new user at the operating system level, but not belonging to the dba OS group: in this way, using the password file, I will able to assign the sysbackup privilege to a normal database user and forcing him to log in using a password.<br />
<br />
Indeed if I try to log into the database when I'm already authorized at the OS level because I'm the oracle OS user, I am allowed to connect with the SYSBACKUP privilege (and of course as SYSDBA, SYSOPER, SYSDG and SYSKM) even with a wrong user and/or password.<br />
Let's see few examples considering that when you are connecting AS SYSDBA the current schema is SYS (independently from the username you specify in the sqlplus connection) and the session USER is SYS; when you are connecting AS SYSBACKUP the current schema is again SYS, but the session user is identified as SYSBACKUP.<br />
<pre class="cpp" name="code">[oracle@localhost ~]$ id
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[oracle@localhost ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Wed May 7 06:12:19 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> select sys_context('USERENV', 'CURRENT_SCHEMA') current_schema from dual;
CURRENT_SCHEMA
------------------
SYS
SQL> select sys_context('USERENV', 'SESSION_USER') session_user from dual;
SESSION_USER
------------------
SYS
SQL> exit</pre>
In the previous example I was able to connect as SYSDBA because the user was "already" verified by the operating system; when I try to connect using a normal database user, in this case specifying marcov and its right password, it happens the same thing that is I'm not connected as the specified user, but as SYS user<br />
<pre class="cpp" name="code">[oracle@localhost ~]$ sqlplus marcov/marcov as sysdba
SQL> select sys_context('USERENV', 'CURRENT_SCHEMA') current_schema, sys_context('USERENV', 'SESSION_USER') session_user from dual;
CURRENT_SCHEMA SESSION_USER
-------------------- --------------------
SYS SYS</pre>
What does it happens when I try to connect AS SYSDBA using a normal database user and a wrong password ?<br />
Again I'm able to connect to the database as the SYS user.<br />
<pre class="cpp" name="code">[oracle@localhost ~]$ sqlplus marcov/m as sysdba
SQL> select sys_context('USERENV', 'CURRENT_SCHEMA') current_schema, sys_context('USERENV', 'SESSION_USER') session_user from dual;
CURRENT_SCHEMA SESSION_USER
-------------------- --------------------
SYS SYS</pre>
What does it happens when I try to connect AS SYSDBA using a non existing database user and a password ?<br />
Again I'm able to connect to the database as the SYS user.<br />
All this happens because I'm using the oracle user at the operating system level which belongs to the dba operating system group and so it's allowed <br />
to estabilish a connection to the local database. There is a correspondence between the OS groups and the database system privileges: the dba OS group maps to the SYSDBA database system privilege (as previously seen), the oper OS group (when created and specified during the installation process) maps to the SYSOPER database system privilege, the oinstall OS group doesn't map to any database system privilege.<br />
<pre class="cpp" name="code">[oracle@localhost ~]$ sqlplus m/m as sysdba
SQL> select sys_context('USERENV', 'CURRENT_SCHEMA') current_schema, sys_context('USERENV', 'SESSION_USER') session_user from dual;
CURRENT_SCHEMA SESSION_USER
-------------------- --------------------
SYS SYS</pre>
So the first step to test a connection AS SYSBACKUP database system privilege is to avoid a connection using the oracle operating system user: I need to create another user at the operating system level without special group. I'm going to create marcov OS user:<br />
<pre class="cpp" name="code">[root@localhost home]# useradd marcov -p marcov
[root@localhost home]# id marcov
uid=54322(marcov) gid=54323(marcov) groups=54323(marcov)</pre>
Now you have to configure this account to let it connect to the database: I simply copied the TNS file located at <br />
/app/oracle/product/12.1.0/dbhome_1/network/admin/tnsnames.ora, not accessible by the new user, under the default directory of marcov OS user (/home/marcov) and modified the /home/marcov/.bash_profile to add few environment variables to marcov's profile:<br />
<pre class="cpp" name="code">[root@localhost home]# cp /app/oracle/product/12.1.0/dbhome_1/network/admin/tnsnames.ora /home/marcov
[root@localhost home]# chown marcov.marcov /home/marcov/tnsnames.ora
[root@localhost home]# cat /home/marcov/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
TNS_ADMIN=/home/marcov
ORACLE_HOME=/app/oracle/product/12.1.0/dbhome_1
ORACLE_SID=CDB001
export TNS_ADMIN
export ORACLE_HOME
export ORACLE_SID
PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
export PATH</pre>
I've already a database schema named MARCOV. From the marcov OS user I'm now able to create a connection with the local database using that schema name and password specifying the tns entry of a pluggable database.<br />
<pre class="cpp" name="code">root@localhost ~]# su - marcov
[marcov@localhost ~]$ sqlplus marcov/marcov@PDB001
SQL> show user
USER is "MARCOV"</pre>
I'm not of course able to connect using the system privilege AS SYSBACKUP. If I try the error "ORA-01017: invalid username/password; logon denied" is raised.<br />
<pre class="cpp" name="code">[marcov@localhost ~]$ sqlplus marcov/marcov@PDB001 as sysbackup
SQL*Plus: Release 12.1.0.1.0 Production on Wed May 7 06:47:42 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
ERROR:
ORA-01017: invalid username/password; logon denied
Enter user-name: </pre>
I need to explicity grant the SYSBACKUP system privilege to the MARCOV database user:<br />
<pre class="cpp" name="code">[oracle@localhost ~]$ sqlplus / as sysdba
SQL> alter session set container=PDB001;
Session altered.
SQL> grant sysbackup to marcov;
Grant succeeded.</pre>
Once the GRANT command is assigned to MARCOV database user, you can see a new entry in the V$PWFILE_USERS view: the view says that the username MARCOV is into the orapwd file and can connect to the local database using the SYSBACKUP system privilege.<br />
<pre class="cpp" name="code">SQL> select * from v$pwfile_users;
USERNAME SYSDB SYSOP SYSAS SYSBA SYSDG SYSKM CON_ID
------------------------------ ----- ----- ----- ----- ----- ----- ----------
SYS TRUE TRUE FALSE FALSE FALSE FALSE 0
MARCOV FALSE FALSE FALSE TRUE FALSE FALSE 3</pre>
After having received the system privilege, MARCOV database user is now able to connect AS SYSBACKUP. Have a look at the CURRENT_SCHEMA and at the SESSION_USER values.<br />
<pre class="cpp" name="code">[marcov@localhost ~]$ sqlplus marcov/marcov@PDB001 as sysbackup
SQL> col current_schema format a10
SQL> col session_user format a20
SQL> select sys_context('USERENV', 'CURRENT_SCHEMA') current_schema, sys_context('USERENV', 'SESSION_USER') session_user from dual;
CURRENT_SC SESSION_USER
---------- --------------------
SYS SYSBACKUP</pre>
The main goal of the system privilege SYSBACKUP is to implement the so called separation of duties: you can grant SYSBACKUP privilege to a user allowed only to perform backup or recovery operation using the RMAN command line, but without possibility to see or access the data of the database.<br />
Let's first see what are the default system privileges and roles associated with the SYSBACKUP privilege.<br />
<pre class="cpp" name="code">SQL> show user;
USER is "SYSBACKUP"
SQL> set pages 999
SQL> col grantee format a25
SQL> col granted_role format a25
SQL> select * from dba_sys_privs where grantee = 'SYSBACKUP';
GRANTEE PRIVILEGE ADMIN_OPTION COMMON
------------------------- ---------------------------------------- ------------ ------
SYSBACKUP ALTER SYSTEM NO YES
SYSBACKUP AUDIT ANY NO YES
SYSBACKUP SELECT ANY TRANSACTION NO YES
SYSBACKUP SELECT ANY DICTIONARY NO YES
SYSBACKUP RESUMABLE NO YES
SYSBACKUP CREATE ANY DIRECTORY NO YES
SYSBACKUP UNLIMITED TABLESPACE NO YES
SYSBACKUP ALTER TABLESPACE NO YES
SYSBACKUP ALTER SESSION NO YES
SYSBACKUP ALTER DATABASE NO YES
SYSBACKUP CREATE ANY TABLE NO YES
SYSBACKUP DROP TABLESPACE NO YES
SYSBACKUP CREATE ANY CLUSTER NO YES
13 rows selected.
SQL> select * from dba_role_privs where grantee = 'SYSBACKUP';
GRANTEE GRANTED_ROLE ADMIN_OPTION DEFAULT_ROLE COMMON
------------------------- ------------------------- ------------ ------------ ------
SYSBACKUP SELECT_CATALOG_ROLE NO YES YES</pre>
The column COMMON (as states in the Oracle documentation: http://docs.oracle.com/cd/E16655_01/server.121/e17615/refrn23274.htm#REFRN23274)<br />
"indicates how the grant was made. Possible values: YES if the role was granted commonly (CONTAINER=ALL was used); NO if the role was granted locally (CONTAINER=ALL was not used)"<br />
<br />
When you are connected using MARCOV database user which has the SYSBACKUP system privilege you are able to use the DESCRIBE<br />
command on every database objects, but you are not allowed to have a look at the data contained by the object.<br />
Here is an example of what you receive (ORA-01031: insufficient privileges) when you try to see the data within the object.<br />
<pre class="cpp" name="code">SQL> show user;
USER is "SYSBACKUP"
SQL> select table_name from dba_tables where owner = 'MARCOV';
TABLE_NAME
------------------------
T2
T1
SQL> select * from MARCOV.T1;
select * from MARCOV.T1
*
ERROR at line 1:
ORA-01031: insufficient privileges
SQL> desc MARCOV.T1;
Name Null? Type
----------------------------------------- -------- ----------------------------
A NUMBER</pre>
If your database user with SYSBACKUP privilege needs to access some data, it should directly receive SELECT grant on specific tables.<br />
<br />
Once you have a database user with SYSBACKUP privilege you can create a RMAN connection to manage your backups.<br />
<pre class="cpp" name="code">[marcov@localhost ~]$ rman
Recovery Manager: Release 12.1.0.1.0 - Production on Wed May 7 13:46:50 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
RMAN> connect target 'marcov/marcov@PDB001 as sysbackup'
connected to target database: CDB001 (DBID=4134986109)
RMAN> select sys_context('USERENV', 'CURRENT_SCHEMA') current_schema, sys_context('USERENV', 'SESSION_USER') session_user from dual;
using target database control file instead of recovery catalog
CURRENT_SCHEMA SESSION_USER
------------------ ------------------
SYS SYSBACKUP</pre>
From the RMAN session you can for example take a backup of the current controlfile or have a list of available backups.<br />
<pre class="cpp" name="code">RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
51 Full 209.94M DISK 00:00:54 14-APR-14
BP Key: 51 Status: AVAILABLE Compressed: YES Tag: TAG20140414T151315
Piece Name: /app/oracle/fast_recovery_area/CDB001/E1F26215682E1142E045000000000001/backupset/2014_04_14/o1_mf_nnndf_TAG20140414T151315_9nqqw3np_.bkp
List of Datafiles in backup set 51
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
7 Full 3389939 14-APR-14 /app/oracle/oradata/CDB001/PDB001/system01.dbf
8 Full 3389939 14-APR-14 /app/oracle/oradata/CDB001/PDB001/sysaux01.dbf
9 Full 3389939 14-APR-14 /app/oracle/oradata/CDB001/PDB001/PDB001_users01.dbf
RMAN> backup current controlfile;
Starting backup at 07-MAY-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=72 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 07-MAY-14
channel ORA_DISK_1: finished piece 1 at 07-MAY-14
piece handle=/app/oracle/fast_recovery_area/CDB001/E1F26215682E1142E045000000000001/backupset/2014_05_07/o1_mf_ncnnf_TAG20140507T135023_9pn7j3y4_.bkp tag=TAG20140507T135023 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
Finished backup at 07-MAY-14
Starting Control File and SPFILE Autobackup at 07-MAY-14
piece handle=/app/oracle/fast_recovery_area/CDB001/autobackup/2014_05_07/o1_mf_s_846942632_9pn7j9dy_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 07-MAY-14
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
51 Full 209.94M DISK 00:00:54 14-APR-14
BP Key: 51 Status: AVAILABLE Compressed: YES Tag: TAG20140414T151315
Piece Name: /app/oracle/fast_recovery_area/CDB001/E1F26215682E1142E045000000000001/backupset/2014_04_14/o1_mf_nnndf_TAG20140414T151315_9nqqw3np_.bkp
List of Datafiles in backup set 51
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
7 Full 3389939 14-APR-14 /app/oracle/oradata/CDB001/PDB001/system01.dbf
8 Full 3389939 14-APR-14 /app/oracle/oradata/CDB001/PDB001/sysaux01.dbf
9 Full 3389939 14-APR-14 /app/oracle/oradata/CDB001/PDB001/PDB001_users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
56 Full 1.13M DISK 00:00:05 07-MAY-14
BP Key: 56 Status: AVAILABLE Compressed: YES Tag: TAG20140507T135023
Piece Name: /app/oracle/fast_recovery_area/CDB001/E1F26215682E1142E045000000000001/backupset/2014_05_07/o1_mf_ncnnf_TAG20140507T135023_9pn7j3y4_.bkp
Control File Included: Ckp SCN: 3418486 Ckp time: 07-MAY-14
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
57 Full 17.20M DISK 00:00:02 07-MAY-14
BP Key: 57 Status: AVAILABLE Compressed: NO Tag: TAG20140507T135032
Piece Name: /app/oracle/fast_recovery_area/CDB001/autobackup/2014_05_07/o1_mf_s_846942632_9pn7j9dy_.bkp
SPFILE Included: Modification time: 07-MAY-14
SPFILE db_unique_name: CDB001
Control File Included: Ckp SCN: 3418494 Ckp time: 07-MAY-14</pre>
When you want to connect to a specific pluggable database using the AS SYSBACKUP syntax directly from the Linux command line you should quote your command with single and double quotes.<br />
<pre class="cpp" name="code">[marcov@localhost ~]$ rman target '"marcov/marcov@PDB001 as sysbackup"'
Recovery Manager: Release 12.1.0.1.0 - Production on Wed May 7 13:52:19 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB001 (DBID=4134986109)
RMAN></pre>
As latest consideration the SYSBACKUP user accounts cannot be dropped.<br />
<pre class="cpp" name="code">[oracle@localhost ~]$ sqlplus / as sysdba
SQL> drop user SYSBACKUP;
drop user SYSBACKUP
*
ERROR at line 1:
ORA-28050: specified user or role cannot be dropped</pre>
You have no reason now to implement the right separation of duties that best fit for your requirements.<br />
<br />
That's all.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-hUGYRfbPUig/U3IMzGJKsTI/AAAAAAAAC78/cF8PDnZN9Qc/s1600/2014-05-07+15.41.05.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-hUGYRfbPUig/U3IMzGJKsTI/AAAAAAAAC78/cF8PDnZN9Qc/s1600/2014-05-07+15.41.05.jpg" height="480" width="640" /></a></div>
<br />
<br />Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com72tag:blogger.com,1999:blog-3005934468887687781.post-86970478333006057652014-03-13T23:26:00.000+01:002014-04-04T08:34:12.410+01:00How to rename everything on Oracle Database (redolog members, tablespaces, schema objects, PDBs, partitions, constraints)Few days ago I was wondering how many RENAME clauses are available on Oracle Database. I have summarized them here:<br />
<ol>
<li><b>Renaming redolog members;</b></li>
<li><b>Renaming tablespaces;</b></li>
<li><b>Renaming datafiles of a single offline tablespace;</b></li>
<li><b>Renaming constraints;</b></li>
<li><b>Renaming schema objects (tables, views, sequences, private synonyms, indexes, triggers);</b></li>
<li><b>Renaming table columns;</b></li>
<li><b>Renaming table and index partitions (subpartitions);</b></li>
<li><b>Restoring and Renaming table from the Recycle Bin;</b></li>
<li><b>Changing the domain in a global database name for a CDB;</b></li>
<li><b>Renaming a PDB;</b> </li>
</ol>
Let's review them with few examples.<br />
<br />
<ul>
<li><b>Renaming redolog members:</b></li>
</ul>
To complete this requirement you have to shutdown the database, move the redo log files to the new destination, startup the database in mount mode, rename the log members and then open the database.<br />
<pre class="cpp" name="code">[oracle@localhost admin]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Wed Mar 12 16:16:04 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> set lines 180
SQL> col member format a50
SQL> select GROUP#, MEMBER, CON_ID from V$LOGFILE;
GROUP# MEMBER CON_ID
---------- -------------------------------------------------- ----------
1 /app/oracle/oradata/CDB001/redo01.log 0
2 /app/oracle/oradata/CDB001/redo02.log 0
3 /app/oracle/oradata/CDB001/redo03.log 0
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> host mv /app/oracle/oradata/CDB001/redo01.log /app/oracle/oradata/CDB001/redo01_renamed.log
SQL> host mv /app/oracle/oradata/CDB001/redo02.log /app/oracle/oradata/CDB001/redo02_renamed.log
SQL> host mv /app/oracle/oradata/CDB001/redo03.log /app/oracle/oradata/CDB001/redo03_renamed.log
SQL> host ls -l /app/oracle/oradata/CDB001/*log
-rw-r-----. 1 oracle oinstall 52429312 Feb 7 15:59 /app/oracle/oradata/CDB001/redo01_renamed.log
-rw-r-----. 1 oracle oinstall 52429312 Mar 3 13:00 /app/oracle/oradata/CDB001/redo02_renamed.log
-rw-r-----. 1 oracle oinstall 52429312 Mar 12 16:17 /app/oracle/oradata/CDB001/redo03_renamed.log
SQL> startup mount;
ORACLE instance started.
Total System Global Area 626327552 bytes
Fixed Size 2291472 bytes
Variable Size 473958640 bytes
Database Buffers 146800640 bytes
Redo Buffers 3276800 bytes
Database mounted.
SQL> alter database rename file '/app/oracle/oradata/CDB001/redo01.log','/app/oracle/oradata/CDB001/redo02.log','/app/oracle/oradata/CDB001/redo03.log'
2 to '/app/oracle/oradata/CDB001/redo01_renamed.log','/app/oracle/oradata/CDB001/redo02_renamed.log','/app/oracle/oradata/CDB001/redo03_renamed.log';
Database altered.
SQL> alter database open;
Database altered.
SQL> select GROUP#, MEMBER, CON_ID from V$LOGFILE;
GROUP# MEMBER CON_ID
---------- -------------------------------------------------- ----------
1 /app/oracle/oradata/CDB001/redo01_renamed.log 0
2 /app/oracle/oradata/CDB001/redo02_renamed.log 0
3 /app/oracle/oradata/CDB001/redo03_renamed.log 0</pre>
<ul>
<li><b>Renaming tablespaces:</b></li>
</ul>
You can rename a permanent or temporary tablespace using the <i>ALTER TABLESPACE RENAME</i> statement. Just remember that you cannot rename SYSTEM or SYSAUX tablespace:
<br />
<pre class="cpp" name="code">SQL> select a.con_id, a.name, b.name from v$containers a, v$tablespace b where a.con_id = b.con_id order by 1,3;
CON_ID NAME NAME
---------- ------------------------------ ------------------------------
1 CDB$ROOT SYSAUX
1 CDB$ROOT SYSTEM
1 CDB$ROOT TEMP
1 CDB$ROOT UNDOTBS1
1 CDB$ROOT USERS
2 PDB$SEED SYSAUX
2 PDB$SEED SYSTEM
2 PDB$SEED TEMP
3 PDB001 SYSAUX
3 PDB001 SYSTEM
3 PDB001 TEMP
3 PDB001 USERS
4 PDB002 SYSAUX
4 PDB002 SYSTEM
4 PDB002 TEMP
4 PDB002 USERS
5 PDB003 SYSAUX
5 PDB003 SYSTEM
5 PDB003 TEMP
5 PDB003 USERS
20 rows selected.
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> alter tablespace USERS rename to USERS_CDBROOT;
Tablespace altered.
SQL> select a.con_id, a.name, b.name from v$containers a, v$tablespace b where a.con_id = b.con_id order by 1,3;
CON_ID NAME NAME
---------- ------------------------------ ------------------------------
1 CDB$ROOT SYSAUX
1 CDB$ROOT SYSTEM
1 CDB$ROOT TEMP
1 CDB$ROOT UNDOTBS1
1 CDB$ROOT USERS_CDBROOT
2 PDB$SEED SYSAUX
2 PDB$SEED SYSTEM
2 PDB$SEED TEMP
3 PDB001 SYSAUX
3 PDB001 SYSTEM
3 PDB001 TEMP
3 PDB001 USERS
4 PDB002 SYSAUX
4 PDB002 SYSTEM
4 PDB002 TEMP
4 PDB002 USERS
5 PDB003 SYSAUX
5 PDB003 SYSTEM
5 PDB003 TEMP
5 PDB003 USERS
20 rows selected.
SQL> alter session set container=PDB001;
Session altered.
SQL> alter pluggable database PDB001 open;
Pluggable database altered.
SQL> alter tablespace USERS rename to USERS_PDB001;
Tablespace altered.
SQL> select a.con_id, a.name, b.name from v$containers a, v$tablespace b where a.con_id = b.con_id order by 1,3;
CON_ID NAME NAME
---------- ------------------------------ ------------------------------
3 PDB001 SYSAUX
3 PDB001 SYSTEM
3 PDB001 TEMP
3 PDB001 USERS_PDB001</pre>
<ul>
<li><b>Renaming datafiles of a single offline tablespace:</b> </li>
</ul>
While the database is open, put the tablespace offline, rename the datafile at the operating system level, rename the datafile at the database level and finally take the tablespace online again.
<br />
<pre class="cpp" name="code">SQL> col file_name format a50
SQL> select file_name from dba_data_files where tablespace_name = 'USERS';
FILE_NAME
--------------------------------------------------
/app/oracle/oradata/CDB001/users01.dbf
SQL> alter tablespace USERS offline;
Tablespace altered.
SQL> host mv /app/oracle/oradata/CDB001/users01.dbf /app/oracle/oradata/CDB001/users01_renamed.dbf
SQL> host ls -l /app/oracle/oradata/CDB001/users01*
-rw-r-----. 1 oracle oinstall 5251072 Mar 12 16:36 /app/oracle/oradata/CDB001/users01_renamed.dbf
SQL> alter tablespace USERS rename datafile '/app/oracle/oradata/CDB001/users01.dbf'
2 to '/app/oracle/oradata/CDB001/users01_renamed.dbf';
Tablespace altered.
SQL> alter tablespace USERS online;
Tablespace altered.
SQL> select file_name from dba_data_files where tablespace_name = 'USERS';
FILE_NAME
--------------------------------------------------
/app/oracle/oradata/CDB001/users01_renamed.dbf</pre>
To rename datafiles included in multiple tablespaces follow the redo log file renaming procedure described above (<i>alter database rename file ...</i>).<br />
<br />
<ul>
<li><b>Renaming constraints:</b></li>
</ul>
You can rename any constraint defined on a table
<br />
<pre class="cpp" name="code">SQL> show user;
USER is "MARCOV"
SQL> select dbms_metadata.get_ddl('TABLE', 'T1') from dual;
DBMS_METADATA.GET_DDL('TABLE','T1')
---------------------------------------------------------
CREATE TABLE "MARCOV"."T1"
( "A" NUMBER
) SEGMENT CREATION IMMEDIATE
SQL> alter table T1 add constraint t1_mypk primary key (a);
Table altered.
SQL> select dbms_metadata.get_ddl('TABLE', 'T1') from dual;
DBMS_METADATA.GET_DDL('TABLE','T1')
---------------------------------------------------------
CREATE TABLE "MARCOV"."T1"
( "A" NUMBER,
CONSTRAINT "T1_MYPK" PRIMARY KEY ("A")
SQL> alter table T1 rename constraint T1_MYPK to T1_PK;
Table altered.
SQL> select dbms_metadata.get_ddl('TABLE', 'T1') from dual;
DBMS_METADATA.GET_DDL('TABLE','T1')
---------------------------------------------------------
CREATE TABLE "MARCOV"."T1"
( "A" NUMBER,
CONSTRAINT "T1_PK" PRIMARY KEY ("A")</pre>
<ul>
<li><b>Renaming schema objects</b> <b>(tables, views, sequences, private synonyms, indexes, triggers):</b></li>
</ul>
You can rename tables, views, sequences and private synonym using the rename statement.
<br />
<pre class="cpp" name="code">SQL> show user;
USER is "MARCOV"
SQL> create sequence T1_MYSEQ;
Sequence created.
SQL> rename T1_MYSEQ to T1_S001;
Table renamed.
SQL> create table mysecondtable (a number);
Table created.
SQL> rename mysecondtable to T2;
Table renamed.
SQL> select dbms_metadata.get_ddl('TABLE', 'T2') from dual;
DBMS_METADATA.GET_DDL('TABLE','T2')
---------------------------------------------------------
CREATE TABLE "MARCOV"."T2"
( "A" NUMBER
) SEGMENT CREATION DEFERRED
SQL> create or replace view T1_MYVIEW as select * from T1 where a <= 10;
View created.
SQL> rename T1_MYVIEW to T1_VIEW;
Table renamed.
SQL> select dbms_metadata.get_ddl('VIEW', 'T1_VIEW') from dual;
DBMS_METADATA.GET_DDL('VIEW','T1_VIEW')
---------------------------------------------------------
CREATE OR REPLACE FORCE EDITIONABLE VIEW "MARCOV"."T1_VIEW" ("A") AS
select "A" from T1 where a <= 10
SQL> create public synonym pub_t1 for t1;
Synonym created.
SQL> create synonym priv_t1 for t1;
Synonym created.</pre>
<br />
As you can see it is not possible to rename public synonymns, just the privates.
<br />
<pre class="cpp" name="code">SQL> rename pub_t1 to public_t1;
rename pub_t1 to public_t1
*
ERROR at line 1:
ORA-04043: object PUB_T1 does not exist
SQL> rename priv_t1 to private_t1;
Table renamed.</pre>
<br />
Synonym of a renamed object returns instead an error when used:<br />
<pre class="cpp" name="code">SQL> select count(*) from private_t1;
COUNT(*)
----------
1
SQL> rename t1 to t1_renamed;
Table renamed.
SQL> select count(*) from private_t1;
select count(*) from private_t1
*
ERROR at line 1:
ORA-00980: synonym translation is no longer valid
SQL> rename t1_renamed to t1;
Table renamed.
SQL> select count(*) from private_t1;
COUNT(*)
----------
1</pre>
To rename schema objects such as indexes and triggers you can use the <i>ALTER ... RENAME</i> statement
<br />
<pre class="cpp" name="code">SQL> show con_name;
CON_NAME
------------------------------
PDB001
SQL> show user
USER is "SYS"
SQL> select index_name from dba_indexes where table_name = 'T1';
INDEX_NAME
----------------------------------------
T1_MYPK
SQL> alter index MARCOV.T1_MYPK rename to T1_INDEX_PK;
Index altered.
SQL> create or replace trigger marcov.t1_mytrigger
2 before insert
3 on marcov.t1
4 for each row
5 declare
6 i number;
7 begin
8 i := 0;
9 end;
10 /
Trigger created.
SQL> alter trigger marcov.t1_mytrigger rename to t1_trigger;
Trigger altered.
SQL> select owner, trigger_name from dba_triggers where trigger_name = 'T1_TRIGGER';
OWNER TRIGGER_NAME
-------------------- ----------------------------------------
MARCOV T1_TRIGGER</pre>
<ul>
<li><b>Renaming table columns: </b></li>
</ul>
It's possible to rename existing columns of a table using the <i>ALTER TABLE ... RENAME COLUMN</i> statement
<br />
<pre class="cpp" name="code">SQL> alter table t1 rename column a to b;
Table altered.</pre>
<ul>
<li><b>Renaming table and index partitions (subpartitions):</b></li>
</ul>
The same <i>RENAME TO</i> statement could be applied to table or index partitions as in the following examples:
<br />
<pre class="cpp" name="code">SQL> alter table t1 add (a number);
Table altered.
SQL> create index T1_index_partitioned on T1 (a)
2 global partition by range (a)
3 (partition p1 values less than (10),
4 partition p2 values less than (100),
5 partition p3 values less than (maxvalue));
Index created.
SQL> alter index T1_index_partitioned rename partition p3 to pmax;
Index altered.
SQL> drop table t2 purge;
Table dropped.
SQL> create table T2 (a number, quarter date) partition by range (quarter)
2 (partition Q1_2012 values less than (to_date('01/04/2012','DD/MM/YYYY')),
3 partition Q2_2012 values less than (to_date('01/07/2012','DD/MM/YYYY')),
4 partition Q3_2012 values less than (to_date('01/10/2012','DD/MM/YYYY')),
5 partition Q4_2012 values less than (to_date('01/01/2013','DD/MM/YYYY')),
6 partition Q1_2013 values less than (to_date('01/04/2013','DD/MM/YYYY')),
7 partition Q2_2013 values less than (to_date('01/07/2013','DD/MM/YYYY')),
8 partition Q3_2013 values less than (to_date('01/10/2013','DD/MM/YYYY')),
9 partition Q4_2013 values less than (to_date('01/01/2014','DD/MM/YYYY')),
10 partition Q1_2014 values less than (to_date('01/04/2014','DD/MM/YYYY')),
11 partition Q2_2014 values less than (to_date('01/07/2014','DD/MM/YYYY')),
12 partition Q3_2014 values less than (to_date('01/10/2014','DD/MM/YYYY')),
13 partition Q4_2014 values less than (maxvalue));
Table created.
SQL> alter table t2 rename partition Q4_2014 to Q_MAX;
Table altered.</pre>
<ul>
<li><b>Restoring and Renaming table from the Recycle Bin: </b></li>
</ul>
You have a dropped table, it is still available in the recycle bin and you want to recover it using the <i>FLASHBACK TABLE ... TO BEFORE DROP</i> statement. With the clause <i>RENAME TO</i> you can rename the original table name and assign a new one during the recovery process.
<br />
<pre class="cpp" name="code">SQL> show user
USER is "MARCOV"
SQL> select * from tab;
no rows selected
SQL> create table T1 (a number);
Table created.
SQL> drop table t1;
Table dropped.
SQL> create table T1 (a number);
Table created.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
---------------------------------------- ------- ----------
BIN$9IBy6OCMQ0zgRQAAAAAAAQ==$0 TABLE
T1 TABLE
SQL> show recyclebin
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T1 BIN$9IBy6OCMQ0zgRQAAAAAAAQ==$0 TABLE 2014-03-13:17:32:48
SQL> flashback table "BIN$9IBy6OCMQ0zgRQAAAAAAAQ==$0" to before drop rename to T2;
Flashback complete.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
---------------------------------------- ------- ----------
T1 TABLE
T2 TABLE
SQL> show recyclebin
SQL></pre>
An equivalent statement to recover and rename the same table could be: <i>flashback table T1 to before drop rename to T2;</i> <br />
Don't forget that double quotes are required when dealing with system generated names
such as BIN$9IBy6OCMQ0zgRQAAAAAAAQ==$0.<br />
Dependent objects of a restored table from the recycle bin such as indexes mantains the system generated names, but you can rename them using the <i>ALTER INDEX ... RENAME TO</i> statement described above in the "Renaming Schema Objects" section.<br />
<br />
<ul>
<li><b>Changing the domain in a global database name for a CDB: </b></li>
</ul>
It's possible to modify the domain of a global database name using the <i>ALTER DATABASE RENAME GLOBAL_NAME TO database_name.network_domain_name </i>statement<i>
</i><br />
<pre class="cpp" name="code">SQL> select * from global_name;
GLOBAL_NAME
------------------------------------------------------
CDB001.MARCOV.COM
SQL> alter database rename global_name to CDB001.IT.MARCOV.COM;
Database altered.
SQL> select * from global_name;
GLOBAL_NAME
------------------------------------------------------
CDB001.IT.MARCOV.COM</pre>
Also the domain of each PDBs is affected when the previous statement is applied to the domain name of a CDB.<br />
<br />
<ul>
<li><b>Renaming a PDB:</b></li>
</ul>
For a pluggable database you cannot modify the domain name directly. When you only want to change the name of a specific PDB you can use the ALTER PLUGGABLE DATABASE RENAME GLOBAL_NAME TO statement. The pluggable database must be open in restricted mode.
<br />
<pre class="cpp" name="code">SQL> alter session set container=PDB001;
Session altered.
SQL> select * from global_name;
select * from global_name
*
ERROR at line 1:
ORA-01219: database or pluggable database not open: queries allowed on fixed
tables or views only
SQL> alter pluggable database PDB001 open;
Pluggable database altered.
SQL> select * from global_name;
GLOBAL_NAME
------------------------------------------------------
PDB001.IT.MARCOV.COM
SQL> alter pluggable database rename global_name to PDB001.ROME.IT.MARCOV.COM;
alter pluggable database rename global_name to PDB001.ROME.IT.MARCOV.COM
*
ERROR at line 1:
ORA-65045: pluggable database not in a restricted mode
SQL> alter pluggable database PDB001 close;
Pluggable database altered.
SQL> alter pluggable database PDB001 open restricted;
Pluggable database altered.
SQL> select * from global_name;
GLOBAL_NAME
------------------------------------------------------
PDB001.IT.MARCOV.COM
SQL> alter pluggable database rename global_name to PDB001.ROME.IT.MARCOV.COM;
alter pluggable database rename global_name to PDB001.ROME.IT.MARCOV.COM
*
ERROR at line 1:
ORA-65042: name is already used by an existing container
SQL> alter pluggable database rename global_name to PDB001_ROME.IT.MARCOV.COM;
Pluggable database altered.
SQL> select name, open_mode from V$PDBS;
NAME OPEN_MODE
------------------------------ ----------
PDB001_ROME READ WRITE
SQL> select * from global_name;
GLOBAL_NAME
------------------------------------------------------
PDB001_ROME.IT.MARCOV.COM</pre>
<br />
That's all.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-iLQ9-wuvMn0/UyIu4QPR8MI/AAAAAAAAC7o/JRq8wRjKl1g/s1600/2014-03-12+16.51.22.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-iLQ9-wuvMn0/UyIu4QPR8MI/AAAAAAAAC7o/JRq8wRjKl1g/s1600/2014-03-12+16.51.22.jpg" height="480" width="640" /></a></div>
Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com192tag:blogger.com,1999:blog-3005934468887687781.post-20246786284949939052014-03-06T15:10:00.000+01:002014-03-06T15:17:20.194+01:00RMAN and SQL statement enhancements in Oracle Database 12cOne of the most useful enhancement Oracle has introduced within
the release 12c in RMAN is the possibility to execute more SQL statements.<br />
<br />
Of course RMAN is primarily used for backup and recovery operations, but sometimes I need to run SQL commands: so in 11g or lower I have to open another terminal/tab or quit the current RMAN session and start a new one with sqlplus.<br />
<br />
In Oracle Database 12c instead most of the sql statements could be executed while still connected to the RMAN session.<br />
<br />
Let's start with few examples.<br />
<br />
In the first example I need to put offline a specific datafile because it should be recovered.<br />
On Oracle Database 11g I have the following information.
<br />
<pre class="cpp" name="code">[oracle@localhost ~]$ rman target /
Recovery Manager: Release 11.2.0.2.0 - Production on Wed Mar 5 06:44:03 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1229390655)
RMAN> report schema;
Report of database schema for database with db_unique_name ORCL
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 911 SYSTEM *** /home/oracle/app/oracle/oradata/orcl/system01.dbf
2 1105 SYSAUX *** /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
3 475 UNDOTBS1 *** /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
4 225 USERS *** /home/oracle/app/oracle/oradata/orcl/users01.dbf
5 82 EXAMPLE *** /home/oracle/app/oracle/oradata/orcl/example01.dbf
6 7 APEX *** /home/oracle/app/oracle/oradata/orcl/APEX.dbf
7 1 READ_ONLY *** /home/oracle/app/oracle/oradata/orcl/read_only01.dbf
8 1 ZZZ *** /home/oracle/app/oracle/oradata/orcl/ZZZ01.dbf
9 1 EXAMPLE *** /home/oracle/app/oracle/oradata/orcl/example02.dbf
10 1 APEX *** /home/oracle/app/oracle/oradata/orcl/APEX02.dbf
11 6 MARCOV *** /home/oracle/app/oracle/oradata/orcl/marcov01.dbf
12 1 TEST *** /home/oracle/app/oracle/oradata/orcl/test01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 /home/oracle/app/oracle/oradata/orcl/temp01.dbf
2 20 TEMP 50 /home/oracle/app/oracle/oradata/orcl/temp02.dbf</pre>
To put my datafile offline on RMAN 11g I need to execute the <i>"alter database"</i> SQL command.<br />
When I try to write it resting upon my memories I just start typing: <i>sql 'alter database datafile ...'</i><br />
Then I remember I have to enclose the entire SQL statement in double quotes because I need to specify single quotes for the filename.
So as soon as I'm ready to press the return key I have to delete every character already written with the backspace key.<br />
After I have completely rewritten the previous sql <i>'alter database datafile ...'</i> statement, I can execute the new correct (?) one.
<br />
<pre class="cpp" name="code">RMAN> sql "alter database datafile '/home/oracle/app/oracle/oradata/orcl/marcov01.dbf' offline";
sql statement: alter database datafile '/home/oracle/app/oracle/oradata/orcl/marcov01.dbf' offline
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of sql command on default channel at 03/05/2014 06:43:38
RMAN-10015: error compiling PL/SQL program</pre>
Another typing error ! When dealing with single quotes I usually forget to duplicate them. The right syntax is finally available.<br />
Just too many double and single quotes for me.
<br />
<pre class="cpp" name="code">RMAN> sql "alter database datafile ''/home/oracle/app/oracle/oradata/orcl/marcov01.dbf'' offline";
sql statement: alter database datafile ''/home/oracle/app/oracle/oradata/orcl/marcov01.dbf'' offline
RMAN> recover datafile 11;
Starting recover at 05-03-2014
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=48 device type=DISK
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 05-03-2014</pre>
The same syntax needs to be used when putting the datafile online again.
<br />
<pre class="cpp" name="code">RMAN> sql "alter database datafile ''/home/oracle/app/oracle/oradata/orcl/marcov01.dbf'' online";
sql statement: alter database datafile ''/home/oracle/app/oracle/oradata/orcl/marcov01.dbf'' online</pre>
Let's reproduce the same steps on Oracle Database 12c using the available RMAN enhancements.
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ rman target /
Recovery Manager: Release 12.1.0.1.0 - Production on Wed Mar 5 15:51:18 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB001 (DBID=4134963396)
RMAN> report schema;
using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name CDB001
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 790 SYSTEM *** /opt/app/oracle/oradata/CDB001/system01.dbf
3 2300 SYSAUX *** /opt/app/oracle/oradata/CDB001/sysaux01.dbf
4 150 UNDOTBS1 *** /opt/app/oracle/oradata/CDB001/undotbs01.dbf
5 250 PDB$SEED:SYSTEM *** /opt/app/oracle/oradata/CDB001/pdbseed/system01.dbf
6 5 USERS *** /opt/app/oracle/oradata/CDB001/users01.dbf
7 590 PDB$SEED:SYSAUX *** /opt/app/oracle/oradata/CDB001/pdbseed/sysaux01.dbf
8 270 PDB0101:SYSTEM *** /opt/app/oracle/oradata/CDB001/PDB0101/system01.dbf
9 650 PDB0101:SYSAUX *** /opt/app/oracle/oradata/CDB001/PDB0101/sysaux01.dbf
10 5 PDB0101:USERS *** /opt/app/oracle/oradata/CDB001/PDB0101/PDB0101_users01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 177 TEMP 32767 /opt/app/oracle/oradata/CDB001/temp01.dbf
2 20 PDB$SEED:TEMP 32767 /opt/app/oracle/oradata/CDB001/pdbseed/pdbseed_temp01.dbf
3 20 PDB0101:TEMP 32767 /opt/app/oracle/oradata/CDB001/PDB0101/temp01.dbf</pre>
When I need to put offline a datafile in RMAN 12c I can use the common SQL syntax without starting the command with the keyword <i>sql</i> or the necessity
to include double or single quotes. It's the same SQL command I use on a <i>sqlplus</i> session.
<br />
<pre class="cpp" name="code">RMAN> alter database datafile '/opt/app/oracle/oradata/CDB001/users01.dbf' offline;
Statement processed
RMAN> recover datafile 6;
Starting recover at 05-03-2014
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=278 device type=DISK
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 05-03-2014</pre>
The same consideration is valid when the datafile needs to be put online again. I don't need to prefix the <i>"alter database datafile ..."</i> command with the keyword <i>sql</i> and enclose the command with quotes.
<br />
<pre class="cpp" name="code">RMAN> alter database datafile '/opt/app/oracle/oradata/CDB001/users01.dbf' online;
Statement processed</pre>
What about <i>select</i> statement executed from the 11g RMAN client ? SQL commands that return data such as <i>select</i> statement are not useful in 11g because no data is simply returned.
<br />
<pre class="cpp" name="code">RMAN> sql 'select name, open_mode from v$database';
sql statement: select name, open_mode from v$database</pre>
On Oracle Database 12c I can execute, while connected to a RMAN session, the same <i>select</i> statement using the usual SQL syntax (again without prefixing the <i>sql</i> keyword and single quotes) and even obtain a result set.
<br />
<pre class="cpp" name="code">RMAN> select name, open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
CDB001 READ WRITE</pre>
What does it happen instead if I execute sql commands such as <i>describe</i> ?
On Oracle Database 11g and lower I can not use it at all, because RMAN throws a parse error.
<br />
<pre class="cpp" name="code">RMAN> sql 'desc v$database';
sql statement: desc dual
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of sql command on default channel at 03/05/2014 07:30:04
RMAN-11003: failure during parse/execution of SQL statement: desc dual
ORA-00900: invalid SQL statement</pre>
On RMAN 12c it is instead possible to execute that kind of command.<br />
<pre class="cpp" name="code">RMAN> desc dual;
Name Null? Type
----------------------------------------- -------- ----------------------------
DUMMY VARCHAR2(1)</pre>
There are many other SQL commands that can be executed from the 12c RMAN client.<br />
Here is an example of different SQL commands successfully executed within a RMAN session:
<br />
<pre class="cpp" name="code">RMAN> create table test (a number);
Statement processed
RMAN> select count(*) from test;
COUNT(*)
----------
0
RMAN> insert into test values (1);
Statement processed
RMAN> select count(*) from test;
COUNT(*)
----------
1
RMAN> rollback;
Statement processed
RMAN> select count(*) from test;
COUNT(*)
----------
0
RMAN> insert into test values (1);
Statement processed
RMAN> commit;
Statement processed</pre>
So now I have a committed row and I want to delete it.<br />
Can I use the <i>delete</i> command in RMAN ? Is Oracle able to distinguish the SQL <i>"delete from ..."</i> command from the RMAN <i>"delete backup ..."</i> command ?<br />
Lets' see if RMAN throws some errors.
<br />
<pre class="cpp" name="code">RMAN> delete from test;
Statement processed
RMAN> select count(*) from test;
COUNT(*)
----------
0</pre>
As you can see Oracle recognizes the right meaning of the <i>delete</i> command using the <i>from</i> clause in the case of SQL <i>"delete from ..."</i> command.<br />
When <i>backup</i> is specified Oracle instead looks for the cancellation of a backup.
<br />
<pre class="cpp" name="code">RMAN> list backup summary;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
38 B F A DISK 20-FEB-14 1 1 YES TAG20140220T163840
39 B F A DISK 20-FEB-14 1 1 YES TAG20140220T163840
40 B F A DISK 20-FEB-14 1 1 YES TAG20140220T163840
41 B F A DISK 20-FEB-14 1 1 YES TAG20140220T163840
42 B F A DISK 20-FEB-14 1 1 YES TAG20140220T163840
43 B F A DISK 20-FEB-14 1 1 NO TAG20140220T164653
44 B F A DISK 03-MAR-14 1 1 YES PDB001_FULL_20140303
45 B F A DISK 03-MAR-14 1 1 NO TAG20140303T153904
RMAN> delete backup tag 'TAG20140220T163840';
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=85 device type=DISK
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
38 38 1 1 AVAILABLE DISK /app/oracle/fast_recovery_area/CDB001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8d3v9_.bkp
39 39 1 1 AVAILABLE DISK /app/oracle/fast_recovery_area/CDB001/E1F26215682E1142E045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8l78o_.bkp
40 40 1 1 AVAILABLE DISK /app/oracle/fast_recovery_area/CDB001/E1F329ECE0F411E6E045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8n97w_.bkp
41 41 1 1 AVAILABLE DISK /app/oracle/fast_recovery_area/CDB001/E2B9BE56B8B936CEE045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8q9jq_.bkp
42 42 1 1 AVAILABLE DISK /app/oracle/fast_recovery_area/CDB001/E19363E52C005C9AE045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8so9h_.bkp
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/app/oracle/fast_recovery_area/CDB001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8d3v9_.bkp RECID=38 STAMP=840040723
deleted backup piece
backup piece handle=/app/oracle/fast_recovery_area/CDB001/E1F26215682E1142E045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8l78o_.bkp RECID=39 STAMP=840040919
deleted backup piece
backup piece handle=/app/oracle/fast_recovery_area/CDB001/E1F329ECE0F411E6E045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8n97w_.bkp RECID=40 STAMP=840040985
deleted backup piece
backup piece handle=/app/oracle/fast_recovery_area/CDB001/E2B9BE56B8B936CEE045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8q9jq_.bkp RECID=41 STAMP=840041081
deleted backup piece
backup piece handle=/app/oracle/fast_recovery_area/CDB001/E19363E52C005C9AE045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8so9h_.bkp RECID=42 STAMP=840041157
Deleted 5 objects</pre>
On RMAN 12c it is also possible to drop a table from the RMAN session.
<br />
<pre class="cpp" name="code">RMAN> drop table test purge;
Statement processed
RMAN> select count(*) from test;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 03/05/2014 21:03:59
ORA-00942: table or view does not exist</pre>
Are there SQL commands that can not be executed from the 12c RMAN client ?<br />
I was wondering if it is possible to change a container for example and
the answer is: you can not change the container in a RMAN session using the SQL syntax.
<br />
<pre class="cpp" name="code">RMAN> alter session set container=PDB001;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 03/05/2014 21:24:44
RMAN-06815: cannot change the container in RMAN session.</pre>
And finally have a look at the following example where the releases 11g and 12c have instead the same behaviour.<br />
<br />
I'm connected using the RMAN 11g client, but I have forgot to set the NLS_DATE_FORMAT environment variable.<br />
As a result when I execute commands such as <i>list backup</i> I'm not able to see time details, because RMAN by default shows only the date.
<br />
<pre class="cpp" name="code">[oracle@localhost ~]$ rman target /
Recovery Manager: Release 11.2.0.2.0 - Production on Tue Mar 5 21:38:10 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1229390655)
RMAN> list backup summary;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
257 B A A DISK 22-04-2013 1 1 YES TAG20130422T213335
258 B F A DISK 22-04-2013 1 1 YES TAG20130422T213339
259 B A A DISK 22-04-2013 1 1 YES TAG20130422T214537
260 B F A DISK 22-04-2013 1 1 NO TAG20130422T214539
261 B F A DISK 23-04-2013 1 1 NO TAG20130423T050224
262 B F A DISK 30-04-2013 1 1 NO TAG20130430T221302</pre>
To set the NLS_DATE_FORMAT variable on RMAN 11g I need to execute the SQL <i>"alter session"</i> command and it follows the previous logic applied to the first example (<i>sql "alter database datafile ..."</i>) with double and single quotes because I need to specify the date and time format.
<br />
<pre class="cpp" name="code">RMAN> sql "alter session set nls_date_format=''dd-mm-yyyy hh24:mi:ss''";
sql statement: alter session set nls_date_format=''dd-mm-yyyy hh24:mi:ss''
RMAN> list backup summary;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
257 B A A DISK 22-04-2013 1 1 YES TAG20130422T213335
258 B F A DISK 22-04-2013 1 1 YES TAG20130422T213339
259 B A A DISK 22-04-2013 1 1 YES TAG20130422T214537
260 B F A DISK 22-04-2013 1 1 NO TAG20130422T214539
261 B F A DISK 23-04-2013 1 1 NO TAG20130423T050224
262 B F A DISK 30-04-2013 1 1 NO TAG20130430T221302</pre>
The column <i>Completion</i> is still formatted using the default date settings. so RMAN ignores that new setting.<br />
Let's see the same example using a 12c RMAN client.
<br />
<pre class="cpp" name="code">[oracle@localhost admin]$ rman target /
Recovery Manager: Release 12.1.0.1.0 - Production on Wed Mar 5 21:43:45 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB001 (DBID=4134986109)
RMAN> list backup summary;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
43 B F A DISK 20-FEB-14 1 1 NO TAG20140220T164653
44 B F A DISK 03-MAR-14 1 1 YES PDB001_FULL_20140303
45 B F A DISK 03-MAR-14 1 1 NO TAG20140303T153904
RMAN> select sysdate from dual;
SYSDATE
---------
05-MAR-14</pre>
Even if I modify the NLS_DATE_FORMAT using the SQL statement, also RMAN 12c is not able to use it.
<br />
<pre class="cpp" name="code">RMAN> alter session set nls_date_format='dd-mm-yyyy hh24:mi:ss';
Statement processed
RMAN> list backup summary;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
43 B F A DISK 20-FEB-14 1 1 NO TAG20140220T164653
44 B F A DISK 03-MAR-14 1 1 YES PDB001_FULL_20140303
45 B F A DISK 03-MAR-14 1 1 NO TAG20140303T153904</pre>
Running a simple <i>select</i> it's possible to see the SQL session is instead able to use the new NLS_DATE_FORMAT setting.
<br />
<pre class="cpp" name="code">RMAN> select sysdate from dual;
SYSDATE
-------------------
05-03-2014 21:45:25</pre>
<br />
That's all.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-5kMtySVDQyc/UxiBF1cLBzI/AAAAAAAAC7Y/12S6W8viUsE/s1600/Screenshot+from+2014-03-06+15:06:44.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-5kMtySVDQyc/UxiBF1cLBzI/AAAAAAAAC7Y/12S6W8viUsE/s1600/Screenshot+from+2014-03-06+15:06:44.png" height="305" width="640" /></a></div>
Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com189tag:blogger.com,1999:blog-3005934468887687781.post-32567924073737099522014-03-04T15:23:00.000+01:002014-03-04T15:23:34.713+01:00How to identify which pdbs a backup set belong toI want to see what useful information are returned by few RMAN commands such as <i>report schema</i> or <i>list backup</i> when using the default RMAN configuration and getting some backups.<br />
<br />
When connected to the ROOT container issuing the RMAN <i>report schema </i>command is quite simple identify how many pluggable databases are plugged into the container database and, above all, the relationship with their datafiles and locations.<br />
<br />
In my case the container database, named CDB001, contains three pluggable databases named PDB001, PDB002 and PDB003: it is also possible to easily identify the seed container used as template when you want to create new PDBs.
<br />
<pre class="cpp" name="code">[oracle@localhost ~]$ rman target /
Recovery Manager: Release 12.1.0.1.0 - Production on Thu Feb 20 16:37:50 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB001 (DBID=4134986109)
RMAN> report schema;
using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name CDB001
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 780 SYSTEM *** /app/oracle/oradata/CDB001/system01.dbf
2 260 PDB$SEED:SYSTEM *** /app/oracle/oradata/CDB001/pdbseed/system01.dbf
3 800 SYSAUX *** /app/oracle/oradata/CDB001/sysaux01.dbf
4 625 PDB$SEED:SYSAUX *** /app/oracle/oradata/CDB001/pdbseed/sysaux01.dbf
5 310 UNDOTBS1 *** /app/oracle/oradata/CDB001/undotbs01.dbf
6 5 USERS *** /app/oracle/oradata/CDB001/users01.dbf
7 260 PDB001:SYSTEM *** /app/oracle/oradata/CDB001/PDB001/system01.dbf
8 635 PDB001:SYSAUX *** /app/oracle/oradata/CDB001/PDB001/sysaux01.dbf
9 5 PDB001:USERS *** /app/oracle/oradata/CDB001/PDB001/PDB001_users01.dbf
10 260 PDB002:SYSTEM *** /app/oracle/oradata/CDB001/PDB002/system01.dbf
11 635 PDB002:SYSAUX *** /app/oracle/oradata/CDB001/PDB002/sysaux01.dbf
12 5 PDB002:USERS *** /app/oracle/oradata/CDB001/PDB002/PDB002_users01.dbf
19 260 PDB003:SYSTEM *** /app/oracle/oradata/CDB001/PDB003/system01.dbf
20 635 PDB003:SYSAUX *** /app/oracle/oradata/CDB001/PDB003/sysaux01.dbf
21 5 PDB003:USERS *** /app/oracle/oradata/CDB001/PDB003/PDB001_users01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 73 TEMP 32767 /app/oracle/oradata/CDB001/temp01.dbf
2 61 PDB$SEED:TEMP 32767 /app/oracle/oradata/CDB001/pdbseed/temp01.dbf
3 20 PDB001:TEMP 32767 /app/oracle/oradata/CDB001/PDB001/temp01.dbf
4 20 PDB002:TEMP 32767 /app/oracle/oradata/CDB001/PDB002/temp01.dbf
5 20 PDB003:TEMP 32767 /app/oracle/oradata/CDB001/PDB003/temp01.dbf</pre>
<br />
After you successfully connect to the container database with RMAN it is not sufficient to have a look at the third line to determine if you are using the container database or a pluggable one.<br />
That line simply specifies you are connected to a target database and when connecting to a pluggable database it could be misleading.<br />
<br />
Have a look at the following attempts to connect first to the root container and then directly to the PDB001 pluggable database.<br />
Where and what are the differences if you exclude the time settings ?
<br />
<pre class="cpp" name="code">[oracle@localhost admin]$ rman target /
Recovery Manager: Release 12.1.0.1.0 - Production on Thu Feb 17 17:18:05 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB001 (DBID=4134986109)</pre>
<pre class="cpp" name="code">[oracle@localhost admin]$ rman target sys/oracle@PDB001
Recovery Manager: Release 12.1.0.1.0 - Production on Thu Feb 17 17:19:24 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB001 (DBID=4134986109)</pre>
<br />
When connected to a pluggable database using the <i>report schema</i> command is possible to deduce the PDB name looking at its datafiles and locations: indeed in this case only the datafiles associated with the connected PDB are listed in the output of the report schema command.
<br />
<pre class="cpp" name="code">RMAN> report schema;
using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name CDB001
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
7 260 SYSTEM *** /app/oracle/oradata/CDB001/PDB001/system01.dbf
8 635 SYSAUX *** /app/oracle/oradata/CDB001/PDB001/sysaux01.dbf
9 5 USERS *** /app/oracle/oradata/CDB001/PDB001/PDB001_users01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
3 20 TEMP 32767 /app/oracle/oradata/CDB001/PDB001/temp01.dbf</pre>
Quit the previous conection to the pluggable database and connect again to the ROOT container and have a look at the <i>list backup</i> command.<br />
<i>List backup</i> command is not so useful when you still don't have any backups available.
<br />
<pre class="cpp" name="code">RMAN> list backup;
specification does not match any backup in the repository</pre>
<br />
So let's get first a full database backup.<br />
When you are connected to the ROOT container any commands you send using RMAN are related to the ROOT container; of course you can, while connected to the ROOT container, execute command on the pluggable database but you have to specify the pluggable database name and additional syntax.
<br />
<pre class="cpp" name="code">RMAN> backup database;
Starting backup at 20-FEB-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=81 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=/app/oracle/oradata/CDB001/sysaux01.dbf
input datafile file number=00001 name=/app/oracle/oradata/CDB001/system01.dbf
input datafile file number=00005 name=/app/oracle/oradata/CDB001/undotbs01.dbf
input datafile file number=00006 name=/app/oracle/oradata/CDB001/users01.dbf
channel ORA_DISK_1: starting piece 1 at 20-FEB-14
channel ORA_DISK_1: finished piece 1 at 20-FEB-14
piece handle=/app/oracle/fast_recovery_area/CDB001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8d3v9_.bkp tag=TAG20140220T163840 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:03:16
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00008 name=/app/oracle/oradata/CDB001/PDB001/sysaux01.dbf
input datafile file number=00007 name=/app/oracle/oradata/CDB001/PDB001/system01.dbf
input datafile file number=00009 name=/app/oracle/oradata/CDB001/PDB001/PDB001_users01.dbf
channel ORA_DISK_1: starting piece 1 at 20-FEB-14
channel ORA_DISK_1: finished piece 1 at 20-FEB-14
piece handle=/app/oracle/fast_recovery_area/CDB001/E1F26215682E1142E045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8l78o_.bkp tag=TAG20140220T163840 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:06
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00011 name=/app/oracle/oradata/CDB001/PDB002/sysaux01.dbf
input datafile file number=00010 name=/app/oracle/oradata/CDB001/PDB002/system01.dbf
input datafile file number=00012 name=/app/oracle/oradata/CDB001/PDB002/PDB002_users01.dbf
channel ORA_DISK_1: starting piece 1 at 20-FEB-14
channel ORA_DISK_1: finished piece 1 at 20-FEB-14
piece handle=/app/oracle/fast_recovery_area/CDB001/E1F329ECE0F411E6E045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8n97w_.bkp tag=TAG20140220T163840 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:36
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00020 name=/app/oracle/oradata/CDB001/PDB003/sysaux01.dbf
input datafile file number=00019 name=/app/oracle/oradata/CDB001/PDB003/system01.dbf
input datafile file number=00021 name=/app/oracle/oradata/CDB001/PDB003/PDB001_users01.dbf
channel ORA_DISK_1: starting piece 1 at 20-FEB-14
channel ORA_DISK_1: finished piece 1 at 20-FEB-14
piece handle=/app/oracle/fast_recovery_area/CDB001/E2B9BE56B8B936CEE045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8q9jq_.bkp tag=TAG20140220T163840 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/app/oracle/oradata/CDB001/pdbseed/sysaux01.dbf
input datafile file number=00002 name=/app/oracle/oradata/CDB001/pdbseed/system01.dbf
channel ORA_DISK_1: starting piece 1 at 20-FEB-14
channel ORA_DISK_1: finished piece 1 at 20-FEB-14
piece handle=/app/oracle/fast_recovery_area/CDB001/E19363E52C005C9AE045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8so9h_.bkp tag=TAG20140220T163840 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
Finished backup at 20-FEB-14
Starting Control File and SPFILE Autobackup at 20-FEB-14
piece handle=/app/oracle/fast_recovery_area/CDB001/autobackup/2014_02_20/o1_mf_s_840041213_9jd8vj0m_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 20-FEB-14</pre>
With the <i>list command</i> you can display information about the available backups. Looking at that information you can be able to know that
the o1_mf_nnndf_TAG20140220T163840_9jd8l78o_.bkp backup is related to a full backup of the pluggable database named PDB001, the o1_mf_nnndf_TAG20140220T163840_9jd8n97w_.bkp backup is related to PDB002 and o1_mf_nnndf_TAG20140220T163840_9jd8q9jq_.bkp to PDB003.
<br />
<pre class="cpp" name="code">RMAN> list backup;
using target database control file instead of recovery catalog
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
38 Full 386.84M DISK 00:03:08 20-FEB-14
BP Key: 38 Status: AVAILABLE Compressed: YES Tag: TAG20140220T163840
Piece Name: /app/oracle/fast_recovery_area/CDB001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8d3v9_.bkp
List of Datafiles in backup set 38
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 3146659 20-FEB-14 /app/oracle/oradata/CDB001/system01.dbf
3 Full 3146659 20-FEB-14 /app/oracle/oradata/CDB001/sysaux01.dbf
5 Full 3146659 20-FEB-14 /app/oracle/oradata/CDB001/undotbs01.dbf
6 Full 3146659 20-FEB-14 /app/oracle/oradata/CDB001/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
39 Full 210.43M DISK 00:01:01 20-FEB-14
BP Key: 39 Status: AVAILABLE Compressed: YES Tag: TAG20140220T163840
Piece Name: /app/oracle/fast_recovery_area/CDB001/E1F26215682E1142E045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8l78o_.bkp
List of Datafiles in backup set 39
Container ID: 3, PDB Name: PDB001
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
7 Full 3147302 20-FEB-14 /app/oracle/oradata/CDB001/PDB001/system01.dbf
8 Full 3147302 20-FEB-14 /app/oracle/oradata/CDB001/PDB001/sysaux01.dbf
9 Full 3147302 20-FEB-14 /app/oracle/oradata/CDB001/PDB001/PDB001_users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
40 Full 210.28M DISK 00:01:31 20-FEB-14
BP Key: 40 Status: AVAILABLE Compressed: YES Tag: TAG20140220T163840
Piece Name: /app/oracle/fast_recovery_area/CDB001/E1F329ECE0F411E6E045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8n97w_.bkp
List of Datafiles in backup set 40
Container ID: 4, PDB Name: PDB002
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
10 Full 3120954 14-AUG-13 /app/oracle/oradata/CDB001/PDB002/system01.dbf
11 Full 3120954 14-AUG-13 /app/oracle/oradata/CDB001/PDB002/sysaux01.dbf
12 Full 3120954 14-AUG-13 /app/oracle/oradata/CDB001/PDB002/PDB002_users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
41 Full 210.24M DISK 00:01:14 20-FEB-14
BP Key: 41 Status: AVAILABLE Compressed: YES Tag: TAG20140220T163840
Piece Name: /app/oracle/fast_recovery_area/CDB001/E2B9BE56B8B936CEE045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8q9jq_.bkp
List of Datafiles in backup set 41
Container ID: 5, PDB Name: PDB003
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
19 Full 3121273 14-AUG-13 /app/oracle/oradata/CDB001/PDB003/system01.dbf
20 Full 3121273 14-AUG-13 /app/oracle/oradata/CDB001/PDB003/sysaux01.dbf
21 Full 3121273 14-AUG-13 /app/oracle/oradata/CDB001/PDB003/PDB001_users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
42 Full 207.56M DISK 00:00:53 20-FEB-14
BP Key: 42 Status: AVAILABLE Compressed: YES Tag: TAG20140220T163840
Piece Name: /app/oracle/fast_recovery_area/CDB001/E19363E52C005C9AE045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8so9h_.bkp
List of Datafiles in backup set 42
Container ID: 2, PDB Name: PDB$SEED
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 1786693 16-JUL-13 /app/oracle/oradata/CDB001/pdbseed/system01.dbf
4 Full 1786693 16-JUL-13 /app/oracle/oradata/CDB001/pdbseed/sysaux01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
43 Full 17.20M DISK 00:00:03 20-FEB-14
BP Key: 43 Status: AVAILABLE Compressed: NO Tag: TAG20140220T164653
Piece Name: /app/oracle/fast_recovery_area/CDB001/autobackup/2014_02_20/o1_mf_s_840041213_9jd8vj0m_.bkp
SPFILE Included: Modification time: 20-FEB-14
SPFILE db_unique_name: CDB001
Control File Included: Ckp SCN: 3148638 Ckp time: 20-FEB-14</pre>
<br />
Looking only at the name of the backup set how you can deduce which PDB that backup belongs to ?<br />
If your database is still available you can query the V$BACKUP_FILES view and match the container id with the V$CONTAINERS view for example.
<br />
<pre class="cpp" name="code">SQL> select pkey, name, guid, fname from v$containers a, v$backup_files b where a.con_id = b.con_id and file_type = 'PIECE' order by pkey;
PKEY NAME GUID FNAME
---------- -------- -------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------
38 CDB$ROOT E19363E52C015C9AE045000000000001 /app/oracle/fast_recovery_area/CDB001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8d3v9_.bkp
39 PDB001 E1F26215682E1142E045000000000001 /app/oracle/fast_recovery_area/CDB001/E1F26215682E1142E045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8l78o_.bkp
40 PDB002 E1F329ECE0F411E6E045000000000001 /app/oracle/fast_recovery_area/CDB001/E1F329ECE0F411E6E045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8n97w_.bkp
41 PDB003 E2B9BE56B8B936CEE045000000000001 /app/oracle/fast_recovery_area/CDB001/E2B9BE56B8B936CEE045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8q9jq_.bkp
42 PDB$SEED E19363E52C005C9AE045000000000001 /app/oracle/fast_recovery_area/CDB001/E19363E52C005C9AE045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8so9h_.bkp
43 CDB$ROOT E19363E52C015C9AE045000000000001 /app/oracle/fast_recovery_area/CDB001/autobackup/2014_02_20/o1_mf_s_840041213_9jd8vj0m_.bkp
6 rows selected.</pre>
<br />
But how can you identify which pluggable database the backup belongs to looking only at the location of the backup set ?<br />
From the file location you can only use the Globally Unique ID (associated with every pluggable databases by the Oracle software) and deduce the name of the pluggable database: if you don't have access to the database it is quite difficult to remember that association.<br />
For this reason when dealing with container and pluggable databases it is heartily recommended to tag your backups using specific names and easily refer to them when required.
<br />
<pre class="cpp" name="code">RMAN> backup pluggable database PDB001 tag 'PDB001_FULL_20140303';
Starting backup at 03-MAR-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=38 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00008 name=/app/oracle/oradata/CDB001/PDB001/sysaux01.dbf
input datafile file number=00007 name=/app/oracle/oradata/CDB001/PDB001/system01.dbf
input datafile file number=00009 name=/app/oracle/oradata/CDB001/PDB001/PDB001_users01.dbf
channel ORA_DISK_1: starting piece 1 at 03-MAR-14
channel ORA_DISK_1: finished piece 1 at 03-MAR-14
piece handle=/app/oracle/fast_recovery_area/CDB001/E1F26215682E1142E045000000000001/backupset/2014_03_03/o1_mf_nnndf_PDB001_FULL_20140303_9k94y5t2_.bkp tag=PDB001_FULL_20140303 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:06
Finished backup at 03-MAR-14
Starting Control File and SPFILE Autobackup at 03-MAR-14
piece handle=/app/oracle/fast_recovery_area/CDB001/autobackup/2014_03_03/o1_mf_s_841246744_9k950bv6_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 03-MAR-14</pre>
<pre class="cpp" name="code">RMAN> list backup of pluggable database PDB001;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
39 Full 210.43M DISK 00:01:01 20-FEB-14
BP Key: 39 Status: AVAILABLE Compressed: YES Tag: TAG20140220T163840
Piece Name: /app/oracle/fast_recovery_area/CDB001/E1F26215682E1142E045000000000001/backupset/2014_02_20/o1_mf_nnndf_TAG20140220T163840_9jd8l78o_.bkp
List of Datafiles in backup set 39
Container ID: 3, PDB Name: PDB001
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
7 Full 3147302 20-FEB-14 /app/oracle/oradata/CDB001/PDB001/system01.dbf
8 Full 3147302 20-FEB-14 /app/oracle/oradata/CDB001/PDB001/sysaux01.dbf
9 Full 3147302 20-FEB-14 /app/oracle/oradata/CDB001/PDB001/PDB001_users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
44 Full 210.45M DISK 00:01:02 03-MAR-14
BP Key: 44 Status: AVAILABLE Compressed: YES Tag: PDB001_FULL_20140303
Piece Name: /app/oracle/fast_recovery_area/CDB001/E1F26215682E1142E045000000000001/backupset/2014_03_03/o1_mf_nnndf_PDB001_FULL_20140303_9k94y5t2_.bkp
List of Datafiles in backup set 44
Container ID: 3, PDB Name: PDB001
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
7 Full 3170400 03-MAR-14 /app/oracle/oradata/CDB001/PDB001/system01.dbf
8 Full 3170400 03-MAR-14 /app/oracle/oradata/CDB001/PDB001/sysaux01.dbf
9 Full 3170400 03-MAR-14 /app/oracle/oradata/CDB001/PDB001/PDB001_users01.dbf</pre>
<br />
Looking at the location name you can now be able to determine that the o1_mf_nnndf_PDB001_FULL_20140303_9k94y5t2_.bkp backup set is related to PDB001 pluggable database.<br />
<br />
That's all.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-FSNsisqxxt0/UxSWbWTM0CI/AAAAAAAAC7I/iREOb9Zkl2Q/s1600/Screenshot+from+2014-03-03+15:17:58.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-FSNsisqxxt0/UxSWbWTM0CI/AAAAAAAAC7I/iREOb9Zkl2Q/s640/Screenshot+from+2014-03-03+15:17:58.png" /></a></div>
Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com19tag:blogger.com,1999:blog-3005934468887687781.post-17229061462311834222014-02-19T11:38:00.000+01:002014-02-19T11:38:32.884+01:00How to recover a table in a pluggable database from a backupI'm going to test some useful recovery scenarios for the Oracle Database 12c release.<br />
An interesting option introduced with this release is the possibility to restore even a single table, without impacting other objects, tablespace or database when that table is no more in the recycle bin.<br />
<br />
The current release I'm using is Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit based on a Linux platform.<br />
<br />
Let's start with an example.<br />
I'm going to create into a pluggable database a new user (MARCOV) and two tables with few rows.<br />
<br />
Before dropping your tables be sure to have a backup containing the missing tables.<br />
I was not able to find any recommendation on Oracle documentation ("Backup and Recovery User's Guide" and "Backup and Recovery Reference") about having a backup of the container database if you want to restore a table previously created into a pluggable database !<br />
<br />
In the following scenario I had indeed a full backup of the container database and I was able to recover the "lost" table;<br />
then I tried to perform the same steps having only the backup of the pluggable database and it was not possible to complete the recovery task.<br />
<br />
Here is my test case.
I'm currently connected to a CDB named CDB001.<br />
<br />
In this container I've a pluggable database named PDB0101.
The new user MARCOV on PDB0101 is created with few grants and the possibility to run the dbms_flashback package to obtain the current System Change Number (SCN).
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Wed Feb 12 10:15:04 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> select name, open_mode from V$PDBS;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB0101 READ WRITE
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> alter session set container=PDB0101;
Session altered.
SQL> show con_name
CON_NAME
------------------------------
PDB0101
SQL> create user marcov
2 identified by "marcov"
3 default tablespace users
4 temporary tablespace temp
5 profile default
6 account unlock;
User created.
SQL> grant create session, create table to marcov;
Grant succeeded.
SQL> alter user marcov quota 50M on users;
User altered.
SQL> grant execute on dbms_flashback to marcov;
Grant succeeded.</pre>
Once the new user is created, I can connect to the pluggable database with that user, creating one table with one row.<br />
The current SCN after the table has been created is 8009717.
<br />
<pre class="cpp" name="code">SQL> conn marcov/marcov@PDB0101_CDB001
Connected.
SQL> show con_name
CON_NAME
------------------------------
PDB0101
SQL> create table t1 (a number);
Table created.
SQL> insert into t1 values (1);
1 row created.
SQL> commit;
Commit complete.
SQL> select dbms_flashback.get_system_change_number scn from dual;
SCN
----------
8009717</pre>
I want to take a backup of the container database. I'm going to use the 'report schema' and 'list backup' to show you what datafile and backups are available.
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ export NLS_DATE_FORMAT='DD-MM-YYYY HH24:MI:SS'
[oracle@vsi08devpom ~]$ rman target /
Recovery Manager: Release 12.1.0.1.0 - Production on Wed Feb 12 10:39:12 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB001 (DBID=4134963396)
RMAN> report schema;
using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name CDB001
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 790 SYSTEM *** /opt/app/oracle/oradata/CDB001/system01.dbf
3 2070 SYSAUX *** /opt/app/oracle/oradata/CDB001/sysaux01.dbf
4 150 UNDOTBS1 *** /opt/app/oracle/oradata/CDB001/undotbs01.dbf
5 250 PDB$SEED:SYSTEM *** /opt/app/oracle/oradata/CDB001/pdbseed/system01.dbf
6 5 USERS *** /opt/app/oracle/oradata/CDB001/users01.dbf
7 590 PDB$SEED:SYSAUX *** /opt/app/oracle/oradata/CDB001/pdbseed/sysaux01.dbf
8 270 PDB0101:SYSTEM *** /opt/app/oracle/oradata/CDB001/PDB0101/system01.dbf
9 640 PDB0101:SYSAUX *** /opt/app/oracle/oradata/CDB001/PDB0101/sysaux01.dbf
10 5 PDB0101:USERS *** /opt/app/oracle/oradata/CDB001/PDB0101/PDB0101_users01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 60 TEMP 32767 /opt/app/oracle/oradata/CDB001/temp01.dbf
2 20 PDB$SEED:TEMP 32767 /opt/app/oracle/oradata/CDB001/pdbseed/pdbseed_temp01.dbf
3 20 PDB0101:TEMP 32767 /opt/app/oracle/oradata/CDB001/PDB0101/temp01.dbf
RMAN> list backup of database;
specification does not match any backup in the repository</pre>
No backup is available so I need to take at least one backup. I'm going to take a full database backup of the CDB and its PDBs.<br />
<pre class="cpp" name="code">RMAN> backup database plus archivelog;
Starting backup at 12-02-2014 10:39:47
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=274 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=659 RECID=10 STAMP=838910191
input archived log thread=1 sequence=660 RECID=11 STAMP=838910385
input archived log thread=1 sequence=661 RECID=12 STAMP=838911248
input archived log thread=1 sequence=662 RECID=13 STAMP=838911290
input archived log thread=1 sequence=663 RECID=14 STAMP=838936876
input archived log thread=1 sequence=664 RECID=15 STAMP=838954825
input archived log thread=1 sequence=665 RECID=16 STAMP=838969262
input archived log thread=1 sequence=666 RECID=17 STAMP=838990856
input archived log thread=1 sequence=667 RECID=18 STAMP=839010107
input archived log thread=1 sequence=668 RECID=19 STAMP=839025149
input archived log thread=1 sequence=669 RECID=20 STAMP=839052023
input archived log thread=1 sequence=670 RECID=21 STAMP=839066666
input archived log thread=1 sequence=671 RECID=22 STAMP=839084422
input archived log thread=1 sequence=672 RECID=23 STAMP=839106050
input archived log thread=1 sequence=673 RECID=24 STAMP=839134863
input archived log thread=1 sequence=674 RECID=25 STAMP=839159419
input archived log thread=1 sequence=675 RECID=26 STAMP=839159631
input archived log thread=1 sequence=676 RECID=27 STAMP=839160939
input archived log thread=1 sequence=677 RECID=28 STAMP=839160961
input archived log thread=1 sequence=678 RECID=29 STAMP=839162174
input archived log thread=1 sequence=679 RECID=30 STAMP=839162192
input archived log thread=1 sequence=680 RECID=31 STAMP=839196037
input archived log thread=1 sequence=681 RECID=32 STAMP=839199610
input archived log thread=1 sequence=682 RECID=33 STAMP=839232033
input archived log thread=1 sequence=683 RECID=34 STAMP=839275218
input archived log thread=1 sequence=684 RECID=35 STAMP=839289656
input archived log thread=1 sequence=685 RECID=36 STAMP=839322019
input archived log thread=1 sequence=686 RECID=37 STAMP=839327987
channel ORA_DISK_1: starting piece 1 at 12-02-2014 10:39:47
channel ORA_DISK_1: finished piece 1 at 12-02-2014 10:40:22
piece handle=/opt/app/oracle/fast_recovery_area/CDB001/backupset/2014_02_12/o1_mf_annnn_TAG20140212T103947_9hpjc3vp_.bkp tag=TAG20140212T103947 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
Finished backup at 12-02-2014 10:40:22
Starting backup at 12-02-2014 10:40:22
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=/opt/app/oracle/oradata/CDB001/sysaux01.dbf
input datafile file number=00001 name=/opt/app/oracle/oradata/CDB001/system01.dbf
input datafile file number=00004 name=/opt/app/oracle/oradata/CDB001/undotbs01.dbf
input datafile file number=00006 name=/opt/app/oracle/oradata/CDB001/users01.dbf
channel ORA_DISK_1: starting piece 1 at 12-02-2014 10:40:23
channel ORA_DISK_1: finished piece 1 at 12-02-2014 10:42:08
piece handle=/opt/app/oracle/fast_recovery_area/CDB001/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjd76g_.bkp tag=TAG20140212T104022 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:45
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00009 name=/opt/app/oracle/oradata/CDB001/PDB0101/sysaux01.dbf
input datafile file number=00008 name=/opt/app/oracle/oradata/CDB001/PDB0101/system01.dbf
input datafile file number=00010 name=/opt/app/oracle/oradata/CDB001/PDB0101/PDB0101_users01.dbf
channel ORA_DISK_1: starting piece 1 at 12-02-2014 10:42:08
channel ORA_DISK_1: finished piece 1 at 12-02-2014 10:42:53
piece handle=/opt/app/oracle/fast_recovery_area/CDB001/E18E282148FD10A5E0430100007FC94D/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjhjbw_.bkp tag=TAG20140212T104022 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/opt/app/oracle/oradata/CDB001/pdbseed/sysaux01.dbf
input datafile file number=00005 name=/opt/app/oracle/oradata/CDB001/pdbseed/system01.dbf
channel ORA_DISK_1: starting piece 1 at 12-02-2014 10:42:53
channel ORA_DISK_1: finished piece 1 at 12-02-2014 10:43:28
piece handle=/opt/app/oracle/fast_recovery_area/CDB001/E18E1CE36B940C96E0430100007FE168/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjjxhq_.bkp tag=TAG20140212T104022 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
Finished backup at 12-02-2014 10:43:28
Starting backup at 12-02-2014 10:43:28
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=687 RECID=38 STAMP=839328208
channel ORA_DISK_1: starting piece 1 at 12-02-2014 10:43:28
channel ORA_DISK_1: finished piece 1 at 12-02-2014 10:43:29
piece handle=/opt/app/oracle/fast_recovery_area/CDB001/backupset/2014_02_12/o1_mf_annnn_TAG20140212T104328_9hpjl0x9_.bkp tag=TAG20140212T104328 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 12-02-2014 10:43:29
Starting Control File and SPFILE Autobackup at 12-02-2014 10:43:30
piece handle=/opt/app/oracle/fast_recovery_area/CDB001/autobackup/2014_02_12/o1_mf_s_839328210_9hpjl2xk_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 12-02-2014 10:43:33</pre>
Once the backup is completed I know I have a valid copy of MARCOV.T1 table in one RMAN backup set.<br />
Let's check the current SCN after the backup is taken.
<br />
<pre class="cpp" name="code">SQL> show user
USER is "MARCOV"
SQL> select dbms_flashback.get_system_change_number scn from dual;
SCN
----------
8010280</pre>
I want to create another table, T2, on MARCOV schema inside the pluggable database PDB0101.
<br />
<pre class="cpp" name="code">SQL> create table t2 (a number);
Table created.
SQL> insert into t2 values (1);
1 row created.
SQL> commit;
Commit complete.
SQL> select dbms_flashback.get_system_change_number scn from dual;
SCN
----------
8010338</pre>
At SCN number 8010338 I have a valid backup containing the MARCOV.T1 table but not the MARCOV.T2 and still the two available tables on the MARCOV schema.<br />
<br />
I'm dropping "inadvertently" MARCOV.T1 table, but without the PURGE option. Only one table is still owned by MARCOV user querying the USER_TABLES view. Anyway something is present into the so called recyclebin: it's original name is T1.
<br />
<pre class="cpp" name="code">SQL> drop table t1;
Table dropped.
SQL> select table_name from user_tables;
TABLE_NAME
--------------------------------------------------
T2
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
-------------------------------------------------- ------- ----------
T2 TABLE
BIN$8b6luRpCd8ngQwEAAH9AuA==$0 TABLE
SQL> show recyclebin
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
---------------- ------------------------------ ------------ -------------------
T1 BIN$8b6luRpCd8ngQwEAAH9AuA==$0 TABLE 2014-02-12:10:48:38</pre>
Using the flashback table command I can "extract" from the recyclebin the T1 table so that its rows could be selected again.
<br />
<pre class="cpp" name="code">SQL> flashback table "BIN$8b6luRpCd8ngQwEAAH9AuA==$0" to before drop;
Flashback complete.
SQL> select table_name from user_tables;
TABLE_NAME
--------------------------------------------------
T1
T2
SQL> select count(*) from t1;
COUNT(*)
----------
1</pre>
Now I want to finally test the RMAN <i>recover table</i> command so I need to use again the drop command with the purge option to avoid the recyclebin and definitively lose my tables.
<br />
<pre class="cpp" name="code">SQL> drop table t1 purge;
Table dropped.
SQL> drop table t2 purge;
Table dropped.
SQL> show recyclebin</pre>
I've lost both tables and I'm wondering if the <i>recover table</i> command will be able to recover them.<br />
During the recovery process RMAN will create and start a new "temporary" instance: the instance needs a valid location where to write its datafiles taken from the previous backup. I want to create this location just under the default location of the pluggable database PDB0101.
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ mkdir /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE</pre>
As first attempt I want to try a recover of MARCOV.T1 table using a SCN before the available backup was taken.<br />
I'm expecting that the recover operation is going to fail.
<br />
<pre class="cpp" name="code">RMAN> recover table marcov.t1 of pluggable database PDB0101 until scn 8009717 auxiliary destination '/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE';
Starting recover at 12-02-2014 11:07:32
using channel ORA_DISK_1
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified Point-in-Time
List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1
Creating automatic instance, with SID='FBzE'
initialization parameters used for automatic instance:
db_name=CDB001
db_unique_name=FBzE_pitr_PDB0101_CDB001
compatible=12.1.0.0.0
db_block_size=8192
db_files=200
sga_target=1G
processes=80
diagnostic_dest=/opt/app/oracle
db_create_file_dest=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE
log_archive_dest_1='location=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance CDB001
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2296576 bytes
Variable Size 281019648 bytes
Database Buffers 780140544 bytes
Redo Buffers 5480448 bytes
Automatic instance created
contents of Memory Script:
{
# set requested point in time
set until scn 8009717;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET until clause
Starting restore at 12-02-2014 11:07:46
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=11 device type=DISK
Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/12/2014 11:07:48
RMAN-03015: error occurred in stored script Memory Script
RMAN-06026: some targets not found - aborting restore
RMAN-06024: no backup or copy of the control file found to restore</pre>
The recover command failed because no available backup was created before the SCN proposed.
Let's see what happens if I try to recover both tables specifying a SCN after I completed the backup and just after the creation of the second table.
<br />
<pre class="cpp" name="code">RMAN> recover table marcov.t1, marcov.t2 of pluggable database PDB0101 until scn 8010338 auxiliary destination '/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE';
Starting recover at 12-02-2014 11:15:55
current log archived
using channel ORA_DISK_1
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified Point-in-Time
List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1
Creating automatic instance, with SID='aBwj'
initialization parameters used for automatic instance:
db_name=CDB001
db_unique_name=aBwj_pitr_PDB0101_CDB001
compatible=12.1.0.0.0
db_block_size=8192
db_files=200
sga_target=1G
processes=80
diagnostic_dest=/opt/app/oracle
db_create_file_dest=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE
log_archive_dest_1='location=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance CDB001
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2296576 bytes
Variable Size 281019648 bytes
Database Buffers 780140544 bytes
Redo Buffers 5480448 bytes
Automatic instance created
contents of Memory Script:
{
# set requested point in time
set until scn 8010338;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET until clause
Starting restore at 12-02-2014 11:16:08
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=82 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /opt/app/oracle/fast_recovery_area/CDB001/autobackup/2014_02_12/o1_mf_s_839328210_9hpjl2xk_.bkp
channel ORA_AUX_DISK_1: piece handle=/opt/app/oracle/fast_recovery_area/CDB001/autobackup/2014_02_12/o1_mf_s_839328210_9hpjl2xk_.bkp tag=TAG20140212T104330
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/controlfile/o1_mf_9hplh8ry_.ctl
Finished restore at 12-02-2014 11:16:09
sql statement: alter database mount clone database
sql statement: alter system archive log current
contents of Memory Script:
{
# set requested point in time
set until scn 8010338;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile 1 to new;
set newname for clone datafile 4 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 8 to new;
set newname for clone datafile 9 to new;
set newname for clone tempfile 1 to new;
set newname for clone tempfile 3 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 4, 3, 8, 9;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed tempfile 1 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 3 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_temp_%u_.tmp in control file
Starting restore at 12-02-2014 11:16:14
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /opt/app/oracle/fast_recovery_area/CDB001/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjd76g_.bkp
channel ORA_AUX_DISK_1: piece handle=/opt/app/oracle/fast_recovery_area/CDB001/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjd76g_.bkp tag=TAG20140212T104022
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:35
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00008 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00009 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /opt/app/oracle/fast_recovery_area/CDB001/E18E282148FD10A5E0430100007FC94D/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjhjbw_.bkp
channel ORA_AUX_DISK_1: piece handle=/opt/app/oracle/fast_recovery_area/CDB001/E18E282148FD10A5E0430100007FC94D/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjhjbw_.bkp tag=TAG20140212T104022
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 12-02-2014 11:18:25
datafile 1 switched to datafile copy
input datafile copy RECID=8 STAMP=839330305 file name=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_system_9hplhh9p_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=9 STAMP=839330305 file name=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_undotbs1_9hplhhbk_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=10 STAMP=839330305 file name=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_sysaux_9hplhh8t_.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=11 STAMP=839330305 file name=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_system_9hpllgjp_.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=12 STAMP=839330305 file name=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_sysaux_9hpllg7d_.dbf
contents of Memory Script:
{
# set requested point in time
set until scn 8010338;
# online the datafiles restored or switched
sql clone "alter database datafile 1 online";
sql clone "alter database datafile 4 online";
sql clone "alter database datafile 3 online";
sql clone 'PDB0101' "alter database datafile
8 online";
sql clone 'PDB0101' "alter database datafile
9 online";
# recover and open database read only
recover clone database tablespace "SYSTEM", "UNDOTBS1", "SYSAUX", "PDB0101":"SYSTEM", "PDB0101":"SYSAUX";
sql clone 'alter database open read only';
}
executing Memory Script
executing command: SET until clause
sql statement: alter database datafile 1 online
sql statement: alter database datafile 4 online
sql statement: alter database datafile 3 online
sql statement: alter database datafile 8 online
sql statement: alter database datafile 9 online
Starting recover at 12-02-2014 11:18:25
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 687 is already on disk as file /opt/app/oracle/fast_recovery_area/CDB001/archivelog/2014_02_12/o1_mf_1_687_9hpjl0pr_.arc
archived log for thread 1 with sequence 688 is already on disk as file /opt/app/oracle/fast_recovery_area/CDB001/archivelog/2014_02_12/o1_mf_1_688_9hplgw0k_.arc
archived log file name=/opt/app/oracle/fast_recovery_area/CDB001/archivelog/2014_02_12/o1_mf_1_687_9hpjl0pr_.arc thread=1 sequence=687
archived log file name=/opt/app/oracle/fast_recovery_area/CDB001/archivelog/2014_02_12/o1_mf_1_688_9hplgw0k_.arc thread=1 sequence=688
media recovery complete, elapsed time: 00:00:02
Finished recover at 12-02-2014 11:18:29
sql statement: alter database open read only
contents of Memory Script:
{
sql clone 'alter pluggable database PDB0101 open read only';
}
executing Memory Script
sql statement: alter pluggable database PDB0101 open read only
contents of Memory Script:
{
sql clone "create spfile from memory";
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set control_files =
''/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/controlfile/o1_mf_9hplh8ry_.ctl'' comment=
''RMAN set'' scope=spfile";
shutdown clone immediate;
startup clone nomount;
# mount database
sql clone 'alter database mount clone database';
}
executing Memory Script
sql statement: create spfile from memory
database closed
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2296576 bytes
Variable Size 285213952 bytes
Database Buffers 775946240 bytes
Redo Buffers 5480448 bytes
sql statement: alter system set control_files = ''/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/controlfile/o1_mf_9hplh8ry_.ctl'' comment= ''RMAN set'' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2296576 bytes
Variable Size 285213952 bytes
Database Buffers 775946240 bytes
Redo Buffers 5480448 bytes
sql statement: alter database mount clone database
contents of Memory Script:
{
# set requested point in time
set until scn 8010338;
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile 10 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 10;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
Starting restore at 12-02-2014 11:19:08
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=11 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00010 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/ABWJ_PITR_PDB0101_CDB001/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /opt/app/oracle/fast_recovery_area/CDB001/E18E282148FD10A5E0430100007FC94D/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjhjbw_.bkp
channel ORA_AUX_DISK_1: piece handle=/opt/app/oracle/fast_recovery_area/CDB001/E18E282148FD10A5E0430100007FC94D/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjhjbw_.bkp tag=TAG20140212T104022
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 12-02-2014 11:19:09
datafile 10 switched to datafile copy
input datafile copy RECID=14 STAMP=839330350 file name=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/ABWJ_PITR_PDB0101_CDB001/datafile/o1_mf_users_9hplnwvb_.dbf
contents of Memory Script:
{
# set requested point in time
set until scn 8010338;
# online the datafiles restored or switched
sql clone 'PDB0101' "alter database datafile
10 online";
# recover and open resetlogs
recover clone database tablespace "PDB0101":"USERS", "SYSTEM", "UNDOTBS1", "SYSAUX", "PDB0101":"SYSTEM", "PDB0101":"SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script
executing command: SET until clause
sql statement: alter database datafile 10 online
Starting recover at 12-02-2014 11:19:09
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 687 is already on disk as file /opt/app/oracle/fast_recovery_area/CDB001/archivelog/2014_02_12/o1_mf_1_687_9hpjl0pr_.arc
archived log for thread 1 with sequence 688 is already on disk as file /opt/app/oracle/fast_recovery_area/CDB001/archivelog/2014_02_12/o1_mf_1_688_9hplgw0k_.arc
archived log file name=/opt/app/oracle/fast_recovery_area/CDB001/archivelog/2014_02_12/o1_mf_1_687_9hpjl0pr_.arc thread=1 sequence=687
archived log file name=/opt/app/oracle/fast_recovery_area/CDB001/archivelog/2014_02_12/o1_mf_1_688_9hplgw0k_.arc thread=1 sequence=688
media recovery complete, elapsed time: 00:00:00
Finished recover at 12-02-2014 11:19:10
database opened
contents of Memory Script:
{
sql clone 'alter pluggable database PDB0101 open';
}
executing Memory Script
sql statement: alter pluggable database PDB0101 open
contents of Memory Script:
{
# create directory for datapump import
sql 'PDB0101' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE''";
# create directory for datapump export
sql clone 'PDB0101' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE''";
}
executing Memory Script
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE''
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE''
Performing export of tables...
EXPDP> Starting "SYS"."TSPITR_EXP_aBwj_wdxk":
EXPDP> Estimate in progress using BLOCKS method...
EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
EXPDP> Total estimation using BLOCKS method: 128 KB
EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
EXPDP> . . exported "MARCOV"."T1" 5.031 KB 1 rows
EXPDP> . . exported "MARCOV"."T2" 5.031 KB 1 rows
EXPDP> Master table "SYS"."TSPITR_EXP_aBwj_wdxk" successfully loaded/unloaded
EXPDP> ******************************************************************************
EXPDP> Dump file set for SYS.TSPITR_EXP_aBwj_wdxk is:
EXPDP> /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/tspitr_aBwj_36569.dmp
EXPDP> Job "SYS"."TSPITR_EXP_aBwj_wdxk" successfully completed at Wed Feb 12 11:20:04 2014 elapsed 0 00:00:26
Export completed
contents of Memory Script:
{
# shutdown clone before import
shutdown clone abort
}
executing Memory Script
Oracle instance shut down
Performing import of tables...
IMPDP> Master table "SYS"."TSPITR_IMP_aBwj_woyn" successfully loaded/unloaded
IMPDP> Starting "SYS"."TSPITR_IMP_aBwj_woyn":
IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
IMPDP> . . imported "MARCOV"."T1" 5.031 KB 1 rows
IMPDP> . . imported "MARCOV"."T2" 5.031 KB 1 rows
IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
IMPDP> Job "SYS"."TSPITR_IMP_aBwj_woyn" successfully completed at Wed Feb 12 11:21:16 2014 elapsed 0 00:01:00
Import completed
Removing automatic instance
Automatic instance removed
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_temp_9hplmz8c_.tmp deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_temp_9hplmph9_.tmp deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/ABWJ_PITR_PDB0101_CDB001/onlinelog/o1_mf_3_9hplo18l_.log deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/ABWJ_PITR_PDB0101_CDB001/onlinelog/o1_mf_2_9hplo04t_.log deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/ABWJ_PITR_PDB0101_CDB001/onlinelog/o1_mf_1_9hplnz1q_.log deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/ABWJ_PITR_PDB0101_CDB001/datafile/o1_mf_users_9hplnwvb_.dbf deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_sysaux_9hpllg7d_.dbf deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_system_9hpllgjp_.dbf deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_sysaux_9hplhh8t_.dbf deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_undotbs1_9hplhhbk_.dbf deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_system_9hplhh9p_.dbf deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/controlfile/o1_mf_9hplh8ry_.ctl deleted
auxiliary instance file tspitr_aBwj_36569.dmp deleted
Finished recover at 12-02-2014 11:21:17</pre>
The recover command successfully completed its steps.<br />
It was able to create an auxiliary database named aBwj, use it to restore all the backup and the archivelog for the two tables, export and import their rows into the target pluggable database PDB0101. As you can see during the recovery steps a new aBwj instance is created...
<br />
<pre class="cpp" name="code">[root@vsi08devpom ~]# ps -ef|grep smon
oracle 20271 1 0 11:19 ? 00:00:00 ora_smon_aBwj
root 20592 19983 0 11:19 pts/2 00:00:00 grep smon
oracle 29331 1 0 Feb06 ? 00:00:26 ora_smon_CDB001</pre>
... and then removed.
<br />
<pre class="cpp" name="code">[root@vsi08devpom ~]# ps -ef|grep smon
root 20873 19983 0 11:38 pts/2 00:00:00 grep smon
oracle 29331 1 0 Feb06 ? 00:00:26 ora_smon_CDB001</pre>
Inside MARCOV schema of the pluggable database PDB0101 the two tables are available again.
<br />
<pre class="cpp" name="code">SQL> show user
USER is "MARCOV"
SQL> select dbms_flashback.get_system_change_number scn from dual;
SCN
----------
8013207
SQL> select * from t1;
A
----------
1
SQL> select * from t2;
A
----------
1</pre>
Let's drop again MARCOV.T1 table and try its recover at a SCN after the backup but prior the creation of MARCOV.T2 table.<br />
Will be MARCOV.T2 table still available ?
<br />
<pre class="cpp" name="code">SQL> drop table t1 purge;
Table dropped.</pre>
Here is the recover command to a different specific SCN.<br />
Find 8010280 inside this web page to see when this SCN was calculated.
<br />
<pre class="cpp" name="code">RMAN> recover table marcov.t1 of pluggable database PDB0101 until scn 8010280 auxiliary destination '/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE';
Starting recover at 12-02-2014 11:43:54
using channel ORA_DISK_1
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified Point-in-Time
List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1
Creating automatic instance, with SID='plxu'
initialization parameters used for automatic instance:
db_name=CDB001
db_unique_name=plxu_pitr_PDB0101_CDB001
compatible=12.1.0.0.0
db_block_size=8192
db_files=200
sga_target=1G
processes=80
diagnostic_dest=/opt/app/oracle
db_create_file_dest=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE
log_archive_dest_1='location=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance CDB001
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2296576 bytes
Variable Size 281019648 bytes
Database Buffers 780140544 bytes
Redo Buffers 5480448 bytes
Automatic instance created
contents of Memory Script:
{
# set requested point in time
set until scn 8010280;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET until clause
Starting restore at 12-02-2014 11:44:06
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=82 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /opt/app/oracle/fast_recovery_area/CDB001/autobackup/2014_02_12/o1_mf_s_839328210_9hpjl2xk_.bkp
channel ORA_AUX_DISK_1: piece handle=/opt/app/oracle/fast_recovery_area/CDB001/autobackup/2014_02_12/o1_mf_s_839328210_9hpjl2xk_.bkp tag=TAG20140212T104330
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/controlfile/o1_mf_9hpn3pjf_.ctl
Finished restore at 12-02-2014 11:44:07
sql statement: alter database mount clone database
sql statement: alter system archive log current
contents of Memory Script:
{
# set requested point in time
set until scn 8010280;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile 1 to new;
set newname for clone datafile 4 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 8 to new;
set newname for clone datafile 9 to new;
set newname for clone tempfile 1 to new;
set newname for clone tempfile 3 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 4, 3, 8, 9;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed tempfile 1 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 3 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_temp_%u_.tmp in control file
Starting restore at 12-02-2014 11:44:12
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /opt/app/oracle/fast_recovery_area/CDB001/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjd76g_.bkp
channel ORA_AUX_DISK_1: piece handle=/opt/app/oracle/fast_recovery_area/CDB001/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjd76g_.bkp tag=TAG20140212T104022
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:35
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00008 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00009 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /opt/app/oracle/fast_recovery_area/CDB001/E18E282148FD10A5E0430100007FC94D/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjhjbw_.bkp
channel ORA_AUX_DISK_1: piece handle=/opt/app/oracle/fast_recovery_area/CDB001/E18E282148FD10A5E0430100007FC94D/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjhjbw_.bkp tag=TAG20140212T104022
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 12-02-2014 11:46:22
datafile 1 switched to datafile copy
input datafile copy RECID=8 STAMP=839331983 file name=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_system_9hpn3x6z_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=9 STAMP=839331983 file name=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_undotbs1_9hpn3x7s_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=10 STAMP=839331983 file name=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_sysaux_9hpn3x60_.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=11 STAMP=839331983 file name=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_system_9hpn6w4d_.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=12 STAMP=839331983 file name=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_sysaux_9hpn6w3t_.dbf
contents of Memory Script:
{
# set requested point in time
set until scn 8010280;
# online the datafiles restored or switched
sql clone "alter database datafile 1 online";
sql clone "alter database datafile 4 online";
sql clone "alter database datafile 3 online";
sql clone 'PDB0101' "alter database datafile
8 online";
sql clone 'PDB0101' "alter database datafile
9 online";
# recover and open database read only
recover clone database tablespace "SYSTEM", "UNDOTBS1", "SYSAUX", "PDB0101":"SYSTEM", "PDB0101":"SYSAUX";
sql clone 'alter database open read only';
}
executing Memory Script
executing command: SET until clause
sql statement: alter database datafile 1 online
sql statement: alter database datafile 4 online
sql statement: alter database datafile 3 online
sql statement: alter database datafile 8 online
sql statement: alter database datafile 9 online
Starting recover at 12-02-2014 11:46:23
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 687 is already on disk as file /opt/app/oracle/fast_recovery_area/CDB001/archivelog/2014_02_12/o1_mf_1_687_9hpjl0pr_.arc
archived log for thread 1 with sequence 688 is already on disk as file /opt/app/oracle/fast_recovery_area/CDB001/archivelog/2014_02_12/o1_mf_1_688_9hplgw0k_.arc
archived log file name=/opt/app/oracle/fast_recovery_area/CDB001/archivelog/2014_02_12/o1_mf_1_687_9hpjl0pr_.arc thread=1 sequence=687
archived log file name=/opt/app/oracle/fast_recovery_area/CDB001/archivelog/2014_02_12/o1_mf_1_688_9hplgw0k_.arc thread=1 sequence=688
media recovery complete, elapsed time: 00:00:01
Finished recover at 12-02-2014 11:46:25
sql statement: alter database open read only
contents of Memory Script:
{
sql clone 'alter pluggable database PDB0101 open read only';
}
executing Memory Script
sql statement: alter pluggable database PDB0101 open read only
contents of Memory Script:
{
sql clone "create spfile from memory";
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set control_files =
''/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/controlfile/o1_mf_9hpn3pjf_.ctl'' comment=
''RMAN set'' scope=spfile";
shutdown clone immediate;
startup clone nomount;
# mount database
sql clone 'alter database mount clone database';
}
executing Memory Script
sql statement: create spfile from memory
database closed
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2296576 bytes
Variable Size 285213952 bytes
Database Buffers 775946240 bytes
Redo Buffers 5480448 bytes
sql statement: alter system set control_files = ''/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/controlfile/o1_mf_9hpn3pjf_.ctl'' comment= ''RMAN set'' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2296576 bytes
Variable Size 285213952 bytes
Database Buffers 775946240 bytes
Redo Buffers 5480448 bytes
sql statement: alter database mount clone database
contents of Memory Script:
{
# set requested point in time
set until scn 8010280;
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile 10 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 10;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
Starting restore at 12-02-2014 11:46:57
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=11 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00010 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/PLXU_PITR_PDB0101_CDB001/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /opt/app/oracle/fast_recovery_area/CDB001/E18E282148FD10A5E0430100007FC94D/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjhjbw_.bkp
channel ORA_AUX_DISK_1: piece handle=/opt/app/oracle/fast_recovery_area/CDB001/E18E282148FD10A5E0430100007FC94D/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjhjbw_.bkp tag=TAG20140212T104022
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 12-02-2014 11:46:59
datafile 10 switched to datafile copy
input datafile copy RECID=14 STAMP=839332019 file name=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/PLXU_PITR_PDB0101_CDB001/datafile/o1_mf_users_9hpn92hl_.dbf
contents of Memory Script:
{
# set requested point in time
set until scn 8010280;
# online the datafiles restored or switched
sql clone 'PDB0101' "alter database datafile
10 online";
# recover and open resetlogs
recover clone database tablespace "PDB0101":"USERS", "SYSTEM", "UNDOTBS1", "SYSAUX", "PDB0101":"SYSTEM", "PDB0101":"SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script
executing command: SET until clause
sql statement: alter database datafile 10 online
Starting recover at 12-02-2014 11:46:59
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 687 is already on disk as file /opt/app/oracle/fast_recovery_area/CDB001/archivelog/2014_02_12/o1_mf_1_687_9hpjl0pr_.arc
archived log for thread 1 with sequence 688 is already on disk as file /opt/app/oracle/fast_recovery_area/CDB001/archivelog/2014_02_12/o1_mf_1_688_9hplgw0k_.arc
archived log file name=/opt/app/oracle/fast_recovery_area/CDB001/archivelog/2014_02_12/o1_mf_1_687_9hpjl0pr_.arc thread=1 sequence=687
archived log file name=/opt/app/oracle/fast_recovery_area/CDB001/archivelog/2014_02_12/o1_mf_1_688_9hplgw0k_.arc thread=1 sequence=688
media recovery complete, elapsed time: 00:00:00
Finished recover at 12-02-2014 11:47:00
database opened
contents of Memory Script:
{
sql clone 'alter pluggable database PDB0101 open';
}
executing Memory Script
sql statement: alter pluggable database PDB0101 open
contents of Memory Script:
{
# create directory for datapump import
sql 'PDB0101' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE''";
# create directory for datapump export
sql clone 'PDB0101' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE''";
}
executing Memory Script
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE''
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE''
Performing export of tables...
EXPDP> Starting "SYS"."TSPITR_EXP_plxu_rzrl":
EXPDP> Estimate in progress using BLOCKS method...
EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
EXPDP> Total estimation using BLOCKS method: 64 KB
EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
EXPDP> . . exported "MARCOV"."T1" 5.031 KB 1 rows
EXPDP> Master table "SYS"."TSPITR_EXP_plxu_rzrl" successfully loaded/unloaded
EXPDP> ******************************************************************************
EXPDP> Dump file set for SYS.TSPITR_EXP_plxu_rzrl is:
EXPDP> /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/tspitr_plxu_39412.dmp
EXPDP> Job "SYS"."TSPITR_EXP_plxu_rzrl" successfully completed at Wed Feb 12 11:47:49 2014 elapsed 0 00:00:23
Export completed
contents of Memory Script:
{
# shutdown clone before import
shutdown clone abort
}
executing Memory Script
Oracle instance shut down
Performing import of tables...
IMPDP> Master table "SYS"."TSPITR_IMP_plxu_ixEA" successfully loaded/unloaded
IMPDP> Starting "SYS"."TSPITR_IMP_plxu_ixEA":
IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
IMPDP> . . imported "MARCOV"."T1" 5.031 KB 1 rows
IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
IMPDP> Job "SYS"."TSPITR_IMP_plxu_ixEA" successfully completed at Wed Feb 12 11:48:53 2014 elapsed 0 00:00:58
Import completed
Removing automatic instance
Automatic instance removed
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_temp_9hpn88ho_.tmp deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_temp_9hpn82js_.tmp deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/PLXU_PITR_PDB0101_CDB001/onlinelog/o1_mf_3_9hpn96tp_.log deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/PLXU_PITR_PDB0101_CDB001/onlinelog/o1_mf_2_9hpn95pb_.log deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/PLXU_PITR_PDB0101_CDB001/onlinelog/o1_mf_1_9hpn94lp_.log deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/PLXU_PITR_PDB0101_CDB001/datafile/o1_mf_users_9hpn92hl_.dbf deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_sysaux_9hpn6w3t_.dbf deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_system_9hpn6w4d_.dbf deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_sysaux_9hpn3x60_.dbf deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_undotbs1_9hpn3x7s_.dbf deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_system_9hpn3x6z_.dbf deleted
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/controlfile/o1_mf_9hpn3pjf_.ctl deleted
auxiliary instance file tspitr_plxu_39412.dmp deleted
Finished recover at 12-02-2014 11:48:54</pre>
The recover command is completed successfully again.<br />
During its recovery operations RMAN created and removed the auxiliary instance named this time plxu.
<br />
<pre class="cpp" name="code">[root@vsi08devpom ~]# ps -ef|grep smon
oracle 20997 1 0 11:44 ? 00:00:00 ora_smon_plxu
root 21051 19983 0 11:44 pts/2 00:00:00 grep smon
oracle 29331 1 0 Feb06 ? 00:00:26 ora_smon_CDB001</pre>
<br />
<pre class="cpp" name="code">[root@vsi08devpom ~]# ps -ef|grep smon
root 21796 19983 0 11:58 pts/2 00:00:00 grep smon
oracle 29331 1 0 Feb06 ? 00:00:26 ora_smon_CDB001</pre>
Naturally the <i>recover table</i> process is not a flashback of the database so the MARCOV.T2 table is still there and always available to be queried.
<br />
<pre class="cpp" name="code">SQL> select * from t1;
A
----------
1
SQL> select * from t2;
A
----------
1</pre>
Now the interesting scenario... I want to remove the previous full container database backup...
<br />
<pre class="cpp" name="code">RMAN> delete noprompt backup;
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
24 24 1 1 AVAILABLE DISK /opt/app/oracle/fast_recovery_area/CDB001/backupset/2014_02_12/o1_mf_annnn_TAG20140212T103947_9hpjc3vp_.bkp
25 25 1 1 AVAILABLE DISK /opt/app/oracle/fast_recovery_area/CDB001/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjd76g_.bkp
26 26 1 1 AVAILABLE DISK /opt/app/oracle/fast_recovery_area/CDB001/E18E282148FD10A5E0430100007FC94D/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjhjbw_.bkp
27 27 1 1 AVAILABLE DISK /opt/app/oracle/fast_recovery_area/CDB001/E18E1CE36B940C96E0430100007FE168/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjjxhq_.bkp
28 28 1 1 AVAILABLE DISK /opt/app/oracle/fast_recovery_area/CDB001/backupset/2014_02_12/o1_mf_annnn_TAG20140212T104328_9hpjl0x9_.bkp
29 29 1 1 AVAILABLE DISK /opt/app/oracle/fast_recovery_area/CDB001/autobackup/2014_02_12/o1_mf_s_839328210_9hpjl2xk_.bkp
deleted backup piece
backup piece handle=/opt/app/oracle/fast_recovery_area/CDB001/backupset/2014_02_12/o1_mf_annnn_TAG20140212T103947_9hpjc3vp_.bkp RECID=24 STAMP=839327987
deleted backup piece
backup piece handle=/opt/app/oracle/fast_recovery_area/CDB001/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjd76g_.bkp RECID=25 STAMP=839328023
deleted backup piece
backup piece handle=/opt/app/oracle/fast_recovery_area/CDB001/E18E282148FD10A5E0430100007FC94D/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjhjbw_.bkp RECID=26 STAMP=839328128
deleted backup piece
backup piece handle=/opt/app/oracle/fast_recovery_area/CDB001/E18E1CE36B940C96E0430100007FE168/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T104022_9hpjjxhq_.bkp RECID=27 STAMP=839328173
deleted backup piece
backup piece handle=/opt/app/oracle/fast_recovery_area/CDB001/backupset/2014_02_12/o1_mf_annnn_TAG20140212T104328_9hpjl0x9_.bkp RECID=28 STAMP=839328208
deleted backup piece
backup piece handle=/opt/app/oracle/fast_recovery_area/CDB001/autobackup/2014_02_12/o1_mf_s_839328210_9hpjl2xk_.bkp RECID=29 STAMP=839328210
Deleted 6 objects
RMAN> list backup;
specification does not match any backup in the repository</pre>
... and execute a backup of just the pluggable database PDB0101.
<br />
<pre class="cpp" name="code">RMAN> backup pluggable database PDB0101;
Starting backup at 12-02-2014 12:00:29
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00009 name=/opt/app/oracle/oradata/CDB001/PDB0101/sysaux01.dbf
input datafile file number=00008 name=/opt/app/oracle/oradata/CDB001/PDB0101/system01.dbf
input datafile file number=00010 name=/opt/app/oracle/oradata/CDB001/PDB0101/PDB0101_users01.dbf
channel ORA_DISK_1: starting piece 1 at 12-02-2014 12:00:29
channel ORA_DISK_1: finished piece 1 at 12-02-2014 12:01:24
piece handle=/opt/app/oracle/fast_recovery_area/CDB001/E18E282148FD10A5E0430100007FC94D/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T120029_9hpo2fnm_.bkp tag=TAG20140212T120029 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
Finished backup at 12-02-2014 12:01:24
Starting Control File and SPFILE Autobackup at 12-02-2014 12:01:24
piece handle=/opt/app/oracle/fast_recovery_area/CDB001/autobackup/2014_02_12/o1_mf_s_839332884_9hpo458m_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 12-02-2014 12:01:27
RMAN> list backup of pluggable database PDB0101;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
30 Full 718.37M DISK 00:00:49 12-02-2014 12:01:18
BP Key: 30 Status: AVAILABLE Compressed: NO Tag: TAG20140212T120029
Piece Name: /opt/app/oracle/fast_recovery_area/CDB001/E18E282148FD10A5E0430100007FC94D/backupset/2014_02_12/o1_mf_nnndf_TAG20140212T120029_9hpo2fnm_.bkp
List of Datafiles in backup set 30
Container ID: 3, PDB Name: PDB0101
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------- ----
8 Full 8014530 12-02-2014 12:00:29 /opt/app/oracle/oradata/CDB001/PDB0101/system01.dbf
9 Full 8014530 12-02-2014 12:00:29 /opt/app/oracle/oradata/CDB001/PDB0101/sysaux01.dbf
10 Full 8014530 12-02-2014 12:00:29 /opt/app/oracle/oradata/CDB001/PDB0101/PDB0101_users01.dbf</pre>
The current SCN after that backup is 8015786.
<br />
<pre class="cpp" name="code">SQL> select dbms_flashback.get_system_change_number scn from dual;
SCN
----------
8015786</pre>
I'm going to simulate the lost of MARCOV.T2: I'm confident to recover it because I have the full pluggable database backup containing all the information of that table.
<br />
<pre class="cpp" name="code">SQL> drop table t2 purge;
Table dropped.</pre>
By now it's just the time to execute the usual <i>recover table</i> command and wait for the creation of the auxiliary instance.
<br />
<pre class="cpp" name="code">RMAN> recover table marcov.t2 of pluggable database PDB0101 until scn 8015786 auxiliary destination '/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE';
Starting recover at 12-02-2014 12:22:00
current log archived
using channel ORA_DISK_1
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified Point-in-Time
List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1
Creating automatic instance, with SID='pknF'
initialization parameters used for automatic instance:
db_name=CDB001
db_unique_name=pknF_pitr_PDB0101_CDB001
compatible=12.1.0.0.0
db_block_size=8192
db_files=200
sga_target=1G
processes=80
diagnostic_dest=/opt/app/oracle
db_create_file_dest=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE
log_archive_dest_1='location=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance CDB001
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2296576 bytes
Variable Size 281019648 bytes
Database Buffers 780140544 bytes
Redo Buffers 5480448 bytes
Automatic instance created
contents of Memory Script:
{
# set requested point in time
set until scn 8015786;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET until clause
Starting restore at 12-02-2014 12:22:11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=11 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /opt/app/oracle/fast_recovery_area/CDB001/autobackup/2014_02_12/o1_mf_s_839332884_9hpo458m_.bkp
channel ORA_AUX_DISK_1: piece handle=/opt/app/oracle/fast_recovery_area/CDB001/autobackup/2014_02_12/o1_mf_s_839332884_9hpo458m_.bkp tag=TAG20140212T120124
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/controlfile/o1_mf_9hppc4b3_.ctl
Finished restore at 12-02-2014 12:22:13
sql statement: alter database mount clone database
sql statement: alter system archive log current
contents of Memory Script:
{
# set requested point in time
set until scn 8015786;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile 1 to new;
set newname for clone datafile 4 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 8 to new;
set newname for clone datafile 9 to new;
set newname for clone tempfile 1 to new;
set newname for clone tempfile 3 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 4, 3, 8, 9;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed tempfile 1 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 3 to /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/datafile/o1_mf_temp_%u_.tmp in control file
Starting restore at 12-02-2014 12:22:18
using channel ORA_AUX_DISK_1
One or more auxiliary set of datafiles could not be removed
Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
auxiliary instance file /opt/app/oracle/oradata/CDB001/PDB0101/RECOVERY_PURGED_TABLE/CDB001/controlfile/o1_mf_9hppc4b3_.ctl deleted
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/12/2014 12:22:18
RMAN-03015: error occurred in stored script Memory Script
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore</pre>
What's happening ? What's wrong ? Why the auxiliary instance named pknF doesn't start ?
<br />
<pre class="cpp" name="code">[root@vsi08devpom ~]# ps -ef|grep smon
oracle 22255 1 0 12:22 ? 00:00:00 ora_smon_pknF
root 22307 19983 0 12:22 pts/2 00:00:00 grep smon
oracle 29331 1 0 Feb06 ? 00:00:26 ora_smon_CDB001
[root@vsi08devpom ~]# ps -ef|grep smon
root 22309 19983 0 12:22 pts/2 00:00:00 grep smon
oracle 29331 1 0 Feb06 ? 00:00:26 ora_smon_CDB001</pre>
<br />
The problem is that to use the <i>recover table</i> command you need a full backup of the container database: having only a backup of the pluggable database is not sufficient because it doesn't have enough information to build an auxiliary instance (just think about at the "shared" UNDO tablespace not backed up for the pluggable database).<br />
<br />
It's not mentioned (at least I was not able to find this information) into the Oracle documentation that you need a valid backup of the container database if you want to recover a table "lost" in a schema of a pluggable database.<br />
<br />
I'm going to suggest an integration to contributors of the "Backup and Recovery User's Guide" and "Backup and Recovery Reference" so it could be more clear that you cannot recover a table if you have only a backup of the pluggable database.<br />
<br />
That's all.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-9IH-x9sHjvE/UwSJERQx3vI/AAAAAAAAC60/CKkxilC0FQ0/s1600/Screenshot+from+2014-02-19+11:35:33.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-9IH-x9sHjvE/UwSJERQx3vI/AAAAAAAAC60/CKkxilC0FQ0/s1600/Screenshot+from+2014-02-19+11:35:33.png" height="345" width="640" /></a></div>
Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com10tag:blogger.com,1999:blog-3005934468887687781.post-23101371587577595462014-02-18T12:12:00.000+01:002014-02-18T12:12:26.611+01:00How to solve the error 'ERROR: NMO Not Setuid-root (Unix-only)' on Oracle Enterprise Manager Cloud Control while contacting the EM AgentI've just finished to setup at home an Oracle Real Application Clusters virtual environment formed by two nodes.<br />
<br />
I would like to monitor and eventually execute some commands from another machine where I've installed the latest (at the moment of this post of course) available Enterprise Manager Cloud Console 12c that is Oracle Enterprise Manager Cloud Control 12c Release 3 Plug-in Update 1 (12.1.0.3) which contains the original 12c Release 3 (12.1.0.3) software binaries along with a few new plug-ins and updated plug-in versions.<br />
<br />
I would like to compare the easy way to manage a Real Application Clusters from a GUI solution against the classic command line interface (CLI).<br />
<br />
After I successfully deployed the agents from my Enterprise Manager Clod Control machine to the two target RAC nodes whenever I tried to perform some operations they resulted in the following error:<br />
ERROR: NMO not setuid-root (Unix-only)<br />
<br />
The following steps helped me to solve the problem.<br />
<br />
On my nodes (demorac01 and demorac02) I created a local directory where EMCC deployed the agent.
Let's have a look at the content of that directory in the second node:
<br />
<pre class="cpp" name="code">[oracle@demorac02 agent12cr3]$ pwd
/u01/app/oracle/agent12cr3
[oracle@demorac02 agent12cr3]$ ll
total 28
-rw-rw-r-- 1 oracle oinstall 178 Jun 22 2013 agentimage.properties
drwxr-xr-x 6 oracle oinstall 4096 Feb 15 10:36 agent_inst
drwxr-xr-x 3 oracle oinstall 4096 Feb 14 10:34 core
drwxr-xr-x 13 oracle oinstall 4096 Feb 14 23:04 plugins
-rwxr-xr-x 1 oracle oinstall 449 Feb 14 10:32 plugins.txt
-rw-r--r-- 1 oracle oinstall 599 Feb 14 10:38 plugins.txt.status
drwxr-xr-x 5 oracle oinstall 4096 Feb 14 10:36 sbin</pre>
Inside the sbin directory there are other files that according to the Oracle documentations should be owned by root. During my local deploy they were set up to be owned by oracle user instead.
<br />
<pre class="cpp" name="code">[oracle@demorac02 agent12cr3]$ cd sbin
[oracle@demorac02 sbin]$ ll
total 1372
drwxr-xr-x 3 oracle oinstall 4096 Feb 14 10:36 cfgtoollogs
drwxr-xr-x 3 oracle oinstall 4096 Jun 22 2013 install
drwxrwx--- 11 oracle oinstall 4096 Jun 22 2013 inventory
-rwxr-xr-x 1 oracle oinstall 22754 Jun 22 2013 nmb.0
-rwxr-xr-x 1 oracle oinstall 43494 Jun 22 2013 nmgsshe
-rwxr-xr-x 1 oracle oinstall 43494 Jun 22 2013 nmgsshe.0
-rwxr-xr-x 1 oracle oinstall 57835 Jun 22 2013 nmhs.0
-rwxr-xr-x 1 oracle oinstall 40007 Jun 22 2013 nmo.0
-rwxr-xr-x 1 oracle oinstall 585242 Jun 22 2013 nmosudo
-rwxr-xr-x 1 oracle oinstall 585242 Jun 22 2013 nmosudo.0
-rw-r----- 1 oracle oinstall 56 Jan 26 16:41 oraInst.loc</pre>
Before proceding with the solution adopted just note that the agent was running and collecting all the available info from the RAC node as you can see from the command below:
<br />
<pre class="cpp" name="code">[oracle@demorac02 sbin]$ cd /u01/app/oracle/agent12cr3/core/12.1.0.3.0/bin
[oracle@demorac02 bin]$ ./emctl status agent
Oracle Enterprise Manager Cloud Control 12c Release 3
Copyright (c) 1996, 2013 Oracle Corporation. All rights reserved.
---------------------------------------------------------------
Agent Version : 12.1.0.3.0
OMS Version : 12.1.0.3.0
Protocol Version : 12.1.0.1.0
Agent Home : /u01/app/oracle/agent12cr3/agent_inst
Agent Binaries : /u01/app/oracle/agent12cr3/core/12.1.0.3.0
Agent Process ID : 21139
Parent Process ID : 21096
Agent URL : https://192.168.56.102:3872/emd/main/
Repository URL : https://emcc.example.com:4900/empbs/upload
Started at : 2014-02-14 10:39:20
Started by user : oracle
Last Reload : (none)
Last successful upload : 2014-02-15 10:30:47
Last attempted upload : 2014-02-15 10:30:47
Total Megabytes of XML files uploaded so far : 1.3
Number of XML files pending upload : 0
Size of XML files pending upload(MB) : 0
Available disk space on upload filesystem : 29.49%
Collection Status : Collections enabled
Heartbeat Status : Ok
Last attempted heartbeat to OMS : 2014-02-15 10:35:48
Last successful heartbeat to OMS : 2014-02-15 10:35:48
Next scheduled heartbeat to OMS : 2014-02-15 10:36:48
---------------------------------------------------------------
Agent is Running and Ready</pre>
To correct the permissions on the desired files you have to run again the file root.sh located under the software location of the Enterprise Manager Cloud Control.
<br />
<pre class="cpp" name="code">[oracle@demorac02 sbin]$ su -
Password:
[root@demorac02 ~]# cd /u01/app/oracle/agent12cr3/core/12.1.0.3.0/
[root@demorac02 12.1.0.3.0]# ll
total 180
drwxr-xr-x 4 oracle oinstall 4096 Jun 22 2013 archives
drwxr-xr-x 2 oracle oinstall 4096 Feb 14 10:36 bin
drwxr-xr-x 6 oracle oinstall 4096 Feb 14 10:39 cfgtoollogs
drwxr-xr-x 6 oracle oinstall 4096 Jun 22 2013 common
drwxr-xr-x 3 oracle oinstall 4096 Jun 22 2013 diagnostics
-rw-r----- 1 oracle oinstall 430 Apr 7 2008 dummy.ic.linux.txt
-rw-r----- 1 oracle oinstall 412 Apr 7 2008 dummy.ic.txt
drwxrwxr-x 3 oracle oinstall 4096 Jun 22 2013 EMStage
drwxr-xr-x 6 oracle oinstall 4096 Feb 14 10:36 install
drwxr-xr-x 2 oracle oinstall 4096 Jun 22 2013 instantclient
drwxrwx--- 14 oracle oinstall 4096 Jun 22 2013 inventory
drwxr-xr-x 3 oracle oinstall 4096 Jun 22 2013 jdbc
drwxr-xr-x 6 oracle oinstall 4096 Feb 14 10:34 jdk
drwxr-xr-x 2 oracle oinstall 4096 Feb 14 10:34 jlib
drwxr-xr-x 2 oracle oinstall 4096 Jun 22 2013 js
drwxr-xr-x 2 oracle oinstall 4096 Jun 22 2013 jythonLib
drwxr-xr-x 5 oracle oinstall 4096 Jun 22 2013 ldap
drwxr-xr-x 4 oracle oinstall 4096 Jun 22 2013 lib
drwxr-xr-x 3 oracle oinstall 4096 Jun 22 2013 lib32
drwxr-xr-x 4 oracle oinstall 4096 Jun 22 2013 modules
drwxr-xr-x 3 oracle oinstall 4096 Jun 22 2013 network
drwxr-xr-x 3 oracle oinstall 4096 Jun 22 2013 ocm
drwxr-xr-x 10 oracle oinstall 4096 Feb 14 10:35 OPatch
drwxr-xr-x 7 oracle oinstall 4096 Jun 22 2013 opmn
-rw-r----- 1 oracle oinstall 56 Jan 26 16:41 oraInst.loc
drwxr-xr-x 7 oracle oinstall 4096 Feb 14 10:35 oui
drwxr-xr-x 5 oracle oinstall 4096 Feb 14 10:35 perl
drwxr-xr-x 2 oracle oinstall 4096 Jun 22 2013 prereqs
drwxr-xr-x 10 oracle oinstall 4096 Jun 22 2013 rda
drwxr-xr-x 3 oracle oinstall 4096 Jun 22 2013 relnotes
-rwxr-xr-x 1 oracle oinstall 1991 Feb 14 10:35 replacebins.sh
-rwxr-xr-x 1 oracle oinstall 1986 Jun 22 2013 replacebins.sh.ouibak
-rwxr-xr-x 1 oracle oinstall 1968 Jun 20 2012 replacebins.sh.template
-rw-r--r-- 1 oracle oinstall 1968 Jun 20 2012 replacebins.sh.template.ouibak
-rwxr-xr-x 1 oracle oinstall 4079 Feb 14 10:35 root.sh
-rwxr-xr-x 1 oracle oinstall 3933 Jun 22 2013 root.sh.old
-rwxr-x--- 1 oracle oinstall 10 Feb 14 10:34 root.sh.old.1
-rwxr-x--- 1 oracle oinstall 10 Feb 14 10:35 root.sh.ouibak
-rwxr-xr-x 1 oracle oinstall 3874 Feb 14 10:35 root.sh.template
-rw-r--r-- 1 oracle oinstall 3869 Jun 22 2013 root.sh.template.ouibak
drwxr-xr-x 5 oracle oinstall 4096 Jun 22 2013 stage
drwxr-xr-x 6 oracle oinstall 4096 Jun 22 2013 sysman
drwxr-xr-x 3 oracle oinstall 4096 Jun 22 2013 ucp
drwxr-xr-x 5 oracle oinstall 4096 Jun 22 2013 xdk
drwxr-xr-x 2 oracle oinstall 4096 Jun 22 2013 xsds</pre>
That file needs to be run as root user too.
<br />
<pre class="cpp" name="code">[root@demorac02 12.1.0.3.0]# ./root.sh
Finished product-specific root actions.
/etc exist
Creating /etc/oragchomelist file...
Finished product-specific root actions.</pre>
Now if you go again under the previous sbin directory you can see that the owner is changed:
<br />
<pre class="cpp" name="code">[root@demorac02 12.1.0.3.0]# cd /u01/app/oracle/agent12cr3/sbin/
[root@demorac02 sbin]# ll
total 1496
drwxr-xr-x 3 oracle oinstall 4096 Feb 14 10:36 cfgtoollogs
drwxr-xr-x 3 oracle oinstall 4096 Jun 22 2013 install
drwxrwx--- 11 oracle oinstall 4096 Jun 22 2013 inventory
-rws--x--- 1 root oinstall 22754 Feb 15 10:48 nmb
-rwxr-xr-x 1 oracle oinstall 22754 Jun 22 2013 nmb.0
-rwxr-xr-x 1 root oinstall 43494 Feb 15 10:48 nmgsshe
-rwxr-xr-x 1 oracle oinstall 43494 Jun 22 2013 nmgsshe.0
-rws--x--- 1 root oinstall 57835 Feb 15 10:48 nmhs
-rwxr-xr-x 1 oracle oinstall 57835 Jun 22 2013 nmhs.0
-rws--x--- 1 root oinstall 40007 Feb 15 10:48 nmo
-rwxr-xr-x 1 oracle oinstall 40007 Jun 22 2013 nmo.0
-rwxr-xr-x 1 root oinstall 585242 Feb 15 10:48 nmosudo
-rwxr-xr-x 1 oracle oinstall 585242 Jun 22 2013 nmosudo.0
-rw-r----- 1 oracle oinstall 56 Jan 26 16:41 oraInst.loc</pre>
It's time to bounce the agent so the new settings could be used by the Enterprise Manager Clod Control during its operations. You must stop and start the agent as oracle user.
<br />
<pre class="cpp" name="code">[oracle@demorac02 bin]$ id
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),492(vboxsf),54322(dba)
[oracle@demorac02 bin]$ pwd
/u01/app/oracle/agent12cr3/core/12.1.0.3.0/bin
[oracle@demorac02 bin]$ ./emctl stop agent
Oracle Enterprise Manager Cloud Control 12c Release 3
Copyright (c) 1996, 2013 Oracle Corporation. All rights reserved.
Stopping agent ..... stopped.
[oracle@demorac02 bin]$ ./emctl start agent
Oracle Enterprise Manager Cloud Control 12c Release 3
Copyright (c) 1996, 2013 Oracle Corporation. All rights reserved.
Starting agent ............................................................................... started.
[oracle@demorac02 bin]$ ./emctl status agent
Oracle Enterprise Manager Cloud Control 12c Release 3
Copyright (c) 1996, 2013 Oracle Corporation. All rights reserved.
---------------------------------------------------------------
Agent Version : 12.1.0.3.0
OMS Version : 12.1.0.3.0
Protocol Version : 12.1.0.1.0
Agent Home : /u01/app/oracle/agent12cr3/agent_inst
Agent Binaries : /u01/app/oracle/agent12cr3/core/12.1.0.3.0
Agent Process ID : 11011
Parent Process ID : 10961
Agent URL : https://192.168.56.102:3872/emd/main/
Repository URL : https://emcc.example.com:4900/empbs/upload
Started at : 2014-02-15 10:51:36
Started by user : oracle
Last Reload : (none)
Last successful upload : 2014-02-15 10:53:23
Last attempted upload : 2014-02-15 10:53:23
Total Megabytes of XML files uploaded so far : 0.01
Number of XML files pending upload : 0
Size of XML files pending upload(MB) : 0
Available disk space on upload filesystem : 29.48%
Collection Status : Collections enabled
Heartbeat Status : Ok
Last attempted heartbeat to OMS : 2014-02-15 10:55:37
Last successful heartbeat to OMS : 2014-02-15 10:55:37
Next scheduled heartbeat to OMS : 2014-02-15 10:56:38
---------------------------------------------------------------
Agent is Running and Ready</pre>
I have a RAC with two nodes so the same steps need to be executed on the other node, demorac01 in my case.
Here there are the wrong settings before running the root.sh script.
<br />
<pre class="cpp" name="code">[oracle@demorac01 sbin]$ pwd
/u01/app/oracle/agent12cr3/sbin
[oracle@demorac01 sbin]$ ll
total 1372
drwxr-xr-x 3 oracle oinstall 4096 Feb 14 10:21 cfgtoollogs
drwxr-xr-x 3 oracle oinstall 4096 Jun 22 2013 install
drwxrwx--- 11 oracle oinstall 4096 Jun 22 2013 inventory
-rwxr-xr-x 1 oracle oinstall 22754 Jun 22 2013 nmb.0
-rwxr-xr-x 1 oracle oinstall 43494 Jun 22 2013 nmgsshe
-rwxr-xr-x 1 oracle oinstall 43494 Jun 22 2013 nmgsshe.0
-rwxr-xr-x 1 oracle oinstall 57835 Jun 22 2013 nmhs.0
-rwxr-xr-x 1 oracle oinstall 40007 Jun 22 2013 nmo.0
-rwxr-xr-x 1 oracle oinstall 585242 Jun 22 2013 nmosudo
-rwxr-xr-x 1 oracle oinstall 585242 Jun 22 2013 nmosudo.0
-rw-r----- 1 oracle oinstall 56 Jan 26 16:41 oraInst.loc</pre>
Run the root.sh script on demorac01 as root user.
<br />
<pre class="cpp" name="code">[oracle@demorac01 sbin]$ su -
Password:
[root@demorac01 ~]# cd /u01/app/oracle/agent12cr3/core/12.1.0.3.0/
[root@demorac01 12.1.0.3.0]# ./root.sh
Finished product-specific root actions.
/etc exist
Creating /etc/oragchomelist file...
Finished product-specific root actions.</pre>
Let's check the new settings.
<br />
<pre class="cpp" name="code">[root@demorac01 12.1.0.3.0]# cd ../../sbin/
[root@demorac01 sbin]# ll
total 1496
drwxr-xr-x 3 oracle oinstall 4096 Feb 14 10:21 cfgtoollogs
drwxr-xr-x 3 oracle oinstall 4096 Jun 22 2013 install
drwxrwx--- 11 oracle oinstall 4096 Jun 22 2013 inventory
-rws--x--- 1 root oinstall 22754 Feb 15 10:54 nmb
-rwxr-xr-x 1 oracle oinstall 22754 Jun 22 2013 nmb.0
-rwxr-xr-x 1 root oinstall 43494 Feb 15 10:54 nmgsshe
-rwxr-xr-x 1 oracle oinstall 43494 Jun 22 2013 nmgsshe.0
-rws--x--- 1 root oinstall 57835 Feb 15 10:54 nmhs
-rwxr-xr-x 1 oracle oinstall 57835 Jun 22 2013 nmhs.0
-rws--x--- 1 root oinstall 40007 Feb 15 10:54 nmo
-rwxr-xr-x 1 oracle oinstall 40007 Jun 22 2013 nmo.0
-rwxr-xr-x 1 root oinstall 585242 Feb 15 10:54 nmosudo
-rwxr-xr-x 1 oracle oinstall 585242 Jun 22 2013 nmosudo.0
-rw-r----- 1 oracle oinstall 56 Jan 26 16:41 oraInst.loc</pre>
Bounce the agent on demorac01: stop and start it as oracle user.
<br />
<pre class="cpp" name="code">[root@demorac01 sbin]# logout
[oracle@demorac01 sbin]$ cd ../core/12.1.0.3.0/bin/
[oracle@demorac01 bin]$ ./emctl stop agent
Oracle Enterprise Manager Cloud Control 12c Release 3
Copyright (c) 1996, 2013 Oracle Corporation. All rights reserved.
Stopping agent ..... stopped.
[oracle@demorac01 bin]$ ./emctl start agent
Oracle Enterprise Manager Cloud Control 12c Release 3
Copyright (c) 1996, 2013 Oracle Corporation. All rights reserved.
Starting agent .......................................................... started.</pre>
Let's check the agent status.
<br />
<pre class="cpp" name="code">[oracle@demorac01 bin]$ ./emctl status agent
Oracle Enterprise Manager Cloud Control 12c Release 3
Copyright (c) 1996, 2013 Oracle Corporation. All rights reserved.
---------------------------------------------------------------
Agent Version : 12.1.0.3.0
OMS Version : 12.1.0.3.0
Protocol Version : 12.1.0.1.0
Agent Home : /u01/app/oracle/agent12cr3/agent_inst
Agent Binaries : /u01/app/oracle/agent12cr3/core/12.1.0.3.0
Agent Process ID : 13377
Parent Process ID : 13332
Agent URL : https://192.168.56.101:3872/emd/main/
Repository URL : https://emcc.example.com:4900/empbs/upload
Started at : 2014-02-15 10:56:16
Started by user : oracle
Last Reload : (none)
Last successful upload : 2014-02-15 10:57:01
Last attempted upload : 2014-02-15 10:57:01
Total Megabytes of XML files uploaded so far : 0
Number of XML files pending upload : 0
Size of XML files pending upload(MB) : 0
Available disk space on upload filesystem : 21.39%
Collection Status : Collections enabled
Heartbeat Status : Ok
Last attempted heartbeat to OMS : 2014-02-15 10:57:00
Last successful heartbeat to OMS : 2014-02-15 10:57:00
Next scheduled heartbeat to OMS : 2014-02-15 10:58:01
---------------------------------------------------------------
Agent is Running and Ready</pre>
So both agents are now running again on the RAC nodes. Let's verify that I solved my issue directly from the Enterprise Manager Cloud Control: the error "NMO not setuid-root (Unix-only)" was thrown the first time when I tried to start up a pluggable database.<br />
<a href="http://1.bp.blogspot.com/-cVCjmNQlHQw/UwM7wAK2x-I/AAAAAAAAC5c/FdhTWRBVSGs/s1600/Schermata+2014-02-15+alle+10.43.34.png" imageanchor="1"><img border="0" src="http://1.bp.blogspot.com/-cVCjmNQlHQw/UwM7wAK2x-I/AAAAAAAAC5c/FdhTWRBVSGs/s400/Schermata+2014-02-15+alle+10.43.34.png" /></a><br />
<br />
Let's do the same step again. Here is the current situation: a CDB in open mode and the pluggable database PDB001 not open.<br />
<a href="http://4.bp.blogspot.com/-J3QjjKVrUBw/UwM8HKJsgaI/AAAAAAAAC5k/pWcqPESTJew/s1600/Schermata+2014-02-15+alle+10.58.14.png" imageanchor="1"><img border="0" src="http://4.bp.blogspot.com/-J3QjjKVrUBw/UwM8HKJsgaI/AAAAAAAAC5k/pWcqPESTJew/s400/Schermata+2014-02-15+alle+10.58.14.png" /></a><br />
<br />
Click on the target name link named "DEMO.demorac_PDB001". It will open the following screenshot and information: "Database is not open. Regions that fetch real-time data from target database will not be displayed"
<a href="http://1.bp.blogspot.com/-EP1WR-6aQ18/UwM8W_5bt9I/AAAAAAAAC5s/HtCC1Q_ECcc/s1600/Schermata+2014-02-15+alle+10.58.48.png" imageanchor="1"><img border="0" src="http://1.bp.blogspot.com/-EP1WR-6aQ18/UwM8W_5bt9I/AAAAAAAAC5s/HtCC1Q_ECcc/s400/Schermata+2014-02-15+alle+10.58.48.png" /></a><br />
<br />
So I want to open that PDB. Point your mouse over "Oracle Database" menu, then "Control" and finally "Open/Close Pluggable Database".
<a href="http://3.bp.blogspot.com/-AKVAJPPzUdI/UwM8d2QAWXI/AAAAAAAAC50/GbEWGxcHU8o/s1600/Schermata+2014-02-15+alle+11.02.47.png" imageanchor="1"><img border="0" src="http://3.bp.blogspot.com/-AKVAJPPzUdI/UwM8d2QAWXI/AAAAAAAAC50/GbEWGxcHU8o/s400/Schermata+2014-02-15+alle+11.02.47.png" /></a><br />
<br />
Give the credentials to access the remote Oracle database.
<a href="http://2.bp.blogspot.com/-u9aQJ-TzCAo/UwM8iRfJDSI/AAAAAAAAC58/oxBwMavU7mg/s1600/Schermata+2014-02-15+alle+11.03.30.png" imageanchor="1"><img border="0" src="http://2.bp.blogspot.com/-u9aQJ-TzCAo/UwM8iRfJDSI/AAAAAAAAC58/oxBwMavU7mg/s400/Schermata+2014-02-15+alle+11.03.30.png" /></a><br />
<br />
It seems to work because the Enterprise Manager Cloud Console is currently showing a new page.<br />
<a href="http://1.bp.blogspot.com/-mihw12D9_GA/UwM8o-SaXUI/AAAAAAAAC6E/GqUPZBRlHkM/s1600/Schermata+2014-02-15+alle+11.03.47.png" imageanchor="1"><img border="0" src="http://1.bp.blogspot.com/-mihw12D9_GA/UwM8o-SaXUI/AAAAAAAAC6E/GqUPZBRlHkM/s400/Schermata+2014-02-15+alle+11.03.47.png" /></a><br />
<br />
Because I want to open the pluggable database PDB001 on both the available instances I select both instances using the CTRL button, and then clicked on "Open" from the Action menu.<br />
<a href="http://3.bp.blogspot.com/-eYjBgg2jcX8/UwM8tZ3l9-I/AAAAAAAAC6M/a3i7D6QA5QQ/s1600/Schermata+2014-02-15+alle+11.05.50.png" imageanchor="1"><img border="0" src="http://3.bp.blogspot.com/-eYjBgg2jcX8/UwM8tZ3l9-I/AAAAAAAAC6M/a3i7D6QA5QQ/s400/Schermata+2014-02-15+alle+11.05.50.png" /></a><br />
<br />
A new browser page will show the status of the operation in progress.
<a href="http://3.bp.blogspot.com/-Nbuyf8rzFs4/UwM8yugTbuI/AAAAAAAAC6U/ooXdkMYVMcI/s1600/Schermata+2014-02-15+alle+11.06.07.png" imageanchor="1"><img border="0" src="http://3.bp.blogspot.com/-Nbuyf8rzFs4/UwM8yugTbuI/AAAAAAAAC6U/ooXdkMYVMcI/s400/Schermata+2014-02-15+alle+11.06.07.png" /></a><br />
<br />
When the operation terminates successfully the "Open/Close Pluggable Database" page will show that the status of the pluggable database PDB001 is now OPEN.<br />
<a href="http://3.bp.blogspot.com/-sIqE6zPT3_E/UwM82pEljEI/AAAAAAAAC6c/Z8eOWPuAgXk/s1600/Schermata+2014-02-15+alle+11.07.07.png" imageanchor="1"><img border="0" src="http://3.bp.blogspot.com/-sIqE6zPT3_E/UwM82pEljEI/AAAAAAAAC6c/Z8eOWPuAgXk/s400/Schermata+2014-02-15+alle+11.07.07.png" /></a><br />
<br />
Clicking on the target link of the pluggable database named "DEMO.demorac_PDB001" will show new activities are performed and so collected from the agent.<br />
<a href="http://3.bp.blogspot.com/-usRLEdWMceg/UwM86XQ5mRI/AAAAAAAAC6k/ja-bWgLeLCg/s1600/Schermata+2014-02-15+alle+11.08.16.png" imageanchor="1"><img border="0" src="http://3.bp.blogspot.com/-usRLEdWMceg/UwM86XQ5mRI/AAAAAAAAC6k/ja-bWgLeLCg/s400/Schermata+2014-02-15+alle+11.08.16.png" /></a><br />
<br />
That's all.
Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com13tag:blogger.com,1999:blog-3005934468887687781.post-42196855331116975562013-09-26T14:31:00.000+01:002013-09-26T14:31:25.557+01:00Differences in default RMAN configuration settings between 12c and 11gI wanted to write a post on configuring the RMAN environment using the <b>SHOW</b> and <b>CONFIGURE</b> commands in Oracle Database 12c,
but after few commands I decided to investigate about the differences on default RMAN settings between the versions 10g, 11g and 12c.<br />
<br />
Here are part of my results: the second part will be written in the next post.<br />
<br />
Comparing the output of the <b>SHOW ALL</b> command while connected to a container database...
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ export ORACLE_SID=CDB001
[oracle@vsi08devpom admin]$ sqlplus system/oracle@CDB001
SQL*Plus: Release 12.1.0.1.0 Production on Thu Sep 26 09:10:50 2013
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Last Successful login time: Tue Jul 16 2013 13:43:48 +02:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
[oracle@vsi08devpom ~]$ rman target /
Recovery Manager: Release 12.1.0.1.0 - Production on Thu Sep 26 09:12:42 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB001 (DBID=4134963396)
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name CDB001 are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/opt/app/oracle/product/12.1.0/db_1/dbs/snapcf_CDB001.f'; # default</pre>
... with that one executed on a 11g database...
<br />
<pre class="cpp" name="code">[oracle@localhost orcl]$ rman target /
Recovery Manager: Release 11.2.0.2.0 - Production on Wed Sep 25 08:12:17 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1229390655)
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/home/oracle/app/oracle/product/11.2.0/dbhome_2/dbs/snapcf_orcl.f'; # default</pre>
... I can notice there are two main differences.
<br />
<pre class="cpp" name="code">CONFIGURE CONTROLFILE AUTOBACKUP ON; # default
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default</pre>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-q2iihwz5Y68/UkQ1LHOqV8I/AAAAAAAAC4g/EZupKmpK3xk/s1600/Screenshot+from+2013-09-26+15:19:10.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="200" src="http://2.bp.blogspot.com/-q2iihwz5Y68/UkQ1LHOqV8I/AAAAAAAAC4g/EZupKmpK3xk/s400/Screenshot+from+2013-09-26+15:19:10.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
On 12c the <b>CONTROLFILE AUTOBACKUP</b> is by default turned on, so at the end of every RMAN backup or after structural changes for databases in ARCHIVELOG mode (eventually creating a single controlfile autobackup encompassing the latest structural changes performed in a short period of time), RMAN automatically backs up the controlfile.<br />
Since Oracle Database 10g release Oracle recommends you enable the control file autobackup feature, but in 10g and 11g the default option of the CONTROLFILE AUTOBACKUP feature is OFF.<br />
<br />
I've so tried to execute the <b>SHOW ALL</b> command on a 12c Non-Container database and here is the output:
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ export ORACLE_SID=ORCL
[oracle@vsi08devpom admin]$ sqlplus system/oracle@orcl
SQL*Plus: Release 12.1.0.1.0 Production on Thu Sep 26 09:00:16 2013
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Last Successful login time: Thu Aug 08 2013 12:16:46 +02:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL@ORCL> show con_name
CON_NAME
------------------------------
Non Consolidated
[oracle@vsi08devpom ~]$ rman target /
Recovery Manager: Release 12.1.0.1.0 - Production on Thu Sep 26 09:02:14 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1350603571)
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/opt/app/oracle/product/12.1.0/db_1/dbs/snapcf_ORCL.f'; # default</pre>
<br />
I then took a look at the "Backup and Recovery Reference 12c Release 1 (12.1)" guide and it confirms that:<br />
"By default, control file autobackups are turned on for CDBs and turned off for non-CDBs."<br />
<br />
The second difference is the new RMAN OUTPUT TO KEEP FOR integer DAYS command.<br />
<br />
From the same documentation guide "...When you configure output
logging to integer days, any logging entry that is older than integer days is deleted from both the RC_RMAN_OUTPUT and V$RMAN_OUTPUT views."<br />
<br />
According to what I have observed today I can conclude:<br />
on page 88 of the "Backup and Recovery User's Guide 12c Release 1 (12.1) E17630-13", the <b>example 5-1 SHOW ALL Command</b> is the same of the "Backup and Recovery User's Guide 11g Release 2 (11.2) E10642-06" on page 82 and that output is related to a Oracle Database 11g version (the 10g doesn't print the first line "RMAN configuration parameters for database with db_unique_name PROD1 are:").<br />
<br />
I'm going to write a post on the related Oracle forum.<br />
<br />
That's all.Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com5tag:blogger.com,1999:blog-3005934468887687781.post-3109696942552285752013-08-16T01:30:00.000+01:002013-09-24T14:12:19.607+01:00How to create a PDB from a Non-CDB (12c) using Oracle Data PumpBeside the <b>DBMS_PDB</b> package you can use Oracle <b>Data Pump</b> to create a pluggable database from a non-container database: it consists to export the non-CDB and import into an empty and already created pluggable database.<br />
<br />
In my case the non-container database I want to transform into a pluggable database is named ORCL and both the source and the target database are Oracle Database 12c databases.<br />
<br />
Before proceeding you have to create first a new pluggable database.<br />
I used <b>DBCA</b> ("Manage Pluggable Databases" --> "Create a Pluggable Database" and so on...) and selected CDBTEST as container database to host the new pluggable database, named ORCL2 (ORCL was created in <a href="http://dbaworkshop.blogspot.it/2013/08/How-to-create-a-PDB-from-a-Non-CDB-using-DBMS-PDB-package.html" target="_blank">this post</a> using <b>DBMS_PDB</b> package).<br />
<br />
Let me create into the non-container database some tablespaces, users and a table with few rows per user with the following anonymous block.
<br />
<pre class="cpp" name="code">SQL@ORCL> begin
2 for i in 1 .. 10 loop
3 execute immediate 'create tablespace marcov_' || ltrim(to_char(i, '09')) || ' datafile ''/opt/app/oracle/oradata/ORCL/marcov_' || ltrim(to_char(i, '09')) || '.dbf'' size 20M';
4 execute immediate 'create user marcov_' || ltrim(to_char(i, '09')) || ' identified by oracle default tablespace marcov_' || ltrim(to_char(i, '09')) || ' quota unlimited on marcov_' || ltrim(to_char(i, '09')) ;
5 execute immediate 'create table marcov_' || ltrim(to_char(i, '09')) || '.T1 (A NUMBER)';
6 execute immediate 'insert into marcov_' || ltrim(to_char(i, '09')) || '.T1 select level from dual connect by level <= 10';
7 commit;
8 end loop;
9 end;
10 /
PL/SQL procedure successfully completed.</pre>
It's time to start with the export. In the non-container database you need to put all the interested tablespaces in <b>READ ONLY</b> mode.
<br />
<pre class="cpp" name="code">SQL@ORCL> begin
2 for i in 1 .. 10 loop
3 execute immediate 'alter tablespace marcov_' || ltrim(to_char(i, '09')) || ' read only';
4 end loop;
5 end;
6 /
PL/SQL procedure successfully completed.</pre>
I cannot of course modify any data on those tablespaces.
<br />
<pre class="cpp" name="code">SQL@ORCL> insert into marcov_01.t1 values (1);
insert into marcov_01.t1 values (1)
*
ERROR at line 1:
ORA-00372: file 5 cannot be modified at this time
ORA-01110: data file 5: '/opt/app/oracle/oradata/ORCL/marcov_01.dbf'</pre>
Here is the list of the available tablespaces. I forgot to set in <b>READ ONLY</b> mode the <b>USERS</b> tablespace.
<br />
<pre class="cpp" name="code">SQL@ORCL> select TABLESPACE_NAME, STATUS from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
SYSAUX ONLINE
UNDOTBS1 ONLINE
TEMP ONLINE
USERS ONLINE
MARCOV_01 READ ONLY
MARCOV_02 READ ONLY
MARCOV_03 READ ONLY
MARCOV_04 READ ONLY
MARCOV_05 READ ONLY
MARCOV_06 READ ONLY
MARCOV_07 READ ONLY
MARCOV_08 READ ONLY
MARCOV_09 READ ONLY
MARCOV_10 READ ONLY</pre>
All tablespace in the transportable set must be set to <b>READ ONLY</b> mode, including the <b>USERS</b> tablespace. <b>SYS</b> and <b>SYSAUX</b> tablespace are not transportable.
<br />
<pre class="cpp" name="code">SQL@ORCL> alter tablespace users read only;
Tablespace altered.</pre>
Now I can export the non-container database ORCL using the option <b>TRANSPORTABLE=ALWAYS</b> and <b>FULL=Y</b>.
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ expdp system/oracle TRANSPORTABLE=ALWAYS FULL=Y dumpfile=full_orcl.dmp logfile=full_orcl.log
Export: Release 12.1.0.1.0 - Production on Thu Aug 8 12:16:46 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Starting "SYSTEM"."SYS_EXPORT_FULL_01": system/******** TRANSPORTABLE=ALWAYS FULL=Y dumpfile=full_orcl.dmp logfile=full_orcl.log
Estimate in progress using BLOCKS method...
Processing object type DATABASE_EXPORT/PLUGTS_FULL/FULL/PLUGTS_TABLESPACE
Processing object type DATABASE_EXPORT/PLUGTS_FULL/PLUGTS_BLK
Processing object type DATABASE_EXPORT/EARLY_OPTIONS/VIEWS_AS_TABLES/TABLE_DATA
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/TABLE_DATA
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/VIEWS_AS_TABLES/TABLE_DATA
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 1.140 MB
Processing object type DATABASE_EXPORT/PRE_SYSTEM_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/PRE_INSTANCE_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/TABLESPACE
Processing object type DATABASE_EXPORT/PROFILE
Processing object type DATABASE_EXPORT/SYS_USER/USER
Processing object type DATABASE_EXPORT/SCHEMA/USER
Processing object type DATABASE_EXPORT/RADM_FPTM
Processing object type DATABASE_EXPORT/GRANT/SYSTEM_GRANT/PROC_SYSTEM_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/DEFAULT_ROLE
Processing object type DATABASE_EXPORT/SCHEMA/ON_USER_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/TABLESPACE_QUOTA
Processing object type DATABASE_EXPORT/RESOURCE_COST
Processing object type DATABASE_EXPORT/TRUSTED_DB_LINK
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/PRE_SYSTEM_ACTIONS/PROCACT_SYSTEM
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/PROCOBJ
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/POST_SYSTEM_ACTIONS/PROCACT_SYSTEM
Processing object type DATABASE_EXPORT/SCHEMA/PROCACT_SCHEMA
Processing object type DATABASE_EXPORT/EARLY_OPTIONS/VIEWS_AS_TABLES/TABLE
Processing object type DATABASE_EXPORT/EARLY_POST_INSTANCE_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/TABLE
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/VIEWS_AS_TABLES/TABLE
Processing object type DATABASE_EXPORT/NORMAL_POST_INSTANCE_IMPCALLOU/MARKER
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/COMMENT
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/CONSTRAINT/CONSTRAINT
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type DATABASE_EXPORT/STATISTICS/MARKER
Processing object type DATABASE_EXPORT/END_PLUGTS_BLK
Processing object type DATABASE_EXPORT/FINAL_POST_INSTANCE_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/SCHEMA/POST_SCHEMA/PROCACT_SCHEMA
Processing object type DATABASE_EXPORT/AUDIT_UNIFIED/AUDIT_POLICY_ENABLE
Processing object type DATABASE_EXPORT/POST_SYSTEM_IMPCALLOUT/MARKER
. . exported "SYS"."KU$_USER_MAPPING_VIEW" 5.906 KB 28 rows
. . exported "SYS"."DAM_CONFIG_PARAM$" 6.507 KB 14 rows
. . exported "SYS"."TSDP_PARAMETER$" 5.929 KB 1 rows
. . exported "SYS"."TSDP_POLICY$" 5.898 KB 1 rows
. . exported "SYS"."TSDP_SUBPOL$" 6.304 KB 1 rows
. . exported "SYSTEM"."REDO_DB" 23.42 KB 1 rows
. . exported "WMSYS"."WM$ENV_VARS$" 6.062 KB 5 rows
. . exported "WMSYS"."WM$EVENTS_INFO$" 5.796 KB 12 rows
. . exported "WMSYS"."WM$HINT_TABLE$" 9.437 KB 75 rows
. . exported "WMSYS"."WM$NEXTVER_TABLE$" 6.359 KB 1 rows
. . exported "WMSYS"."WM$VERSION_HIERARCHY_TABLE$" 5.960 KB 1 rows
. . exported "WMSYS"."WM$WORKSPACES_TABLE$" 12.08 KB 1 rows
. . exported "WMSYS"."WM$WORKSPACE_PRIV_TABLE$" 6.546 KB 8 rows
. . exported "SYS"."AUD$" 0 KB 0 rows
. . exported "SYS"."DAM_CLEANUP_EVENTS$" 0 KB 0 rows
. . exported "SYS"."DAM_CLEANUP_JOBS$" 0 KB 0 rows
. . exported "SYS"."TSDP_ASSOCIATION$" 0 KB 0 rows
. . exported "SYS"."TSDP_CONDITION$" 0 KB 0 rows
. . exported "SYS"."TSDP_FEATURE_POLICY$" 0 KB 0 rows
. . exported "SYS"."TSDP_PROTECTION$" 0 KB 0 rows
. . exported "SYS"."TSDP_SENSITIVE_DATA$" 0 KB 0 rows
. . exported "SYS"."TSDP_SENSITIVE_TYPE$" 0 KB 0 rows
. . exported "SYS"."TSDP_SOURCE$" 0 KB 0 rows
. . exported "SYSTEM"."REDO_LOG" 0 KB 0 rows
. . exported "WMSYS"."WM$BATCH_COMPRESSIBLE_TABLES$" 0 KB 0 rows
. . exported "WMSYS"."WM$CONSTRAINTS_TABLE$" 0 KB 0 rows
. . exported "WMSYS"."WM$CONS_COLUMNS$" 0 KB 0 rows
. . exported "WMSYS"."WM$LOCKROWS_INFO$" 0 KB 0 rows
. . exported "WMSYS"."WM$MODIFIED_TABLES$" 0 KB 0 rows
. . exported "WMSYS"."WM$MP_GRAPH_WORKSPACES_TABLE$" 0 KB 0 rows
. . exported "WMSYS"."WM$MP_PARENT_WORKSPACES_TABLE$" 0 KB 0 rows
. . exported "WMSYS"."WM$NESTED_COLUMNS_TABLE$" 0 KB 0 rows
. . exported "WMSYS"."WM$REMOVED_WORKSPACES_TABLE$" 0 KB 0 rows
. . exported "WMSYS"."WM$RESOLVE_WORKSPACES_TABLE$" 0 KB 0 rows
. . exported "WMSYS"."WM$RIC_LOCKING_TABLE$" 0 KB 0 rows
. . exported "WMSYS"."WM$RIC_TABLE$" 0 KB 0 rows
. . exported "WMSYS"."WM$RIC_TRIGGERS_TABLE$" 0 KB 0 rows
. . exported "WMSYS"."WM$UDTRIG_DISPATCH_PROCS$" 0 KB 0 rows
. . exported "WMSYS"."WM$UDTRIG_INFO$" 0 KB 0 rows
. . exported "WMSYS"."WM$VERSION_TABLE$" 0 KB 0 rows
. . exported "WMSYS"."WM$VT_ERRORS_TABLE$" 0 KB 0 rows
. . exported "WMSYS"."WM$WORKSPACE_SAVEPOINTS_TABLE$" 0 KB 0 rows
. . exported "SYSTEM"."SCHEDULER_PROGRAM_ARGS" 9.484 KB 12 rows
. . exported "SYS"."AUDTAB$TBS$FOR_EXPORT" 5.937 KB 2 rows
. . exported "SYS"."NACL$_ACE_EXP" 9.914 KB 1 rows
. . exported "SYS"."NACL$_HOST_EXP" 6.898 KB 1 rows
. . exported "WMSYS"."WM$EXP_MAP" 7.703 KB 3 rows
. . exported "SYS"."DBA_SENSITIVE_DATA" 0 KB 0 rows
. . exported "SYS"."DBA_TSDP_POLICY_PROTECTION" 0 KB 0 rows
. . exported "SYS"."FGA_LOG$FOR_EXPORT" 0 KB 0 rows
. . exported "SYS"."NACL$_WALLET_EXP" 0 KB 0 rows
. . exported "SYSTEM"."SCHEDULER_JOB_ARGS" 0 KB 0 rows
Master table "SYSTEM"."SYS_EXPORT_FULL_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_FULL_01 is:
/opt/app/oracle/admin/ORCL/dpdump/full_orcl.dmp
******************************************************************************
Datafiles required for transportable tablespace MARCOV_01:
/opt/app/oracle/oradata/ORCL/marcov_01.dbf
Datafiles required for transportable tablespace MARCOV_02:
/opt/app/oracle/oradata/ORCL/marcov_02.dbf
Datafiles required for transportable tablespace MARCOV_03:
/opt/app/oracle/oradata/ORCL/marcov_03.dbf
Datafiles required for transportable tablespace MARCOV_04:
/opt/app/oracle/oradata/ORCL/marcov_04.dbf
Datafiles required for transportable tablespace MARCOV_05:
/opt/app/oracle/oradata/ORCL/marcov_05.dbf
Datafiles required for transportable tablespace MARCOV_06:
/opt/app/oracle/oradata/ORCL/marcov_06.dbf
Datafiles required for transportable tablespace MARCOV_07:
/opt/app/oracle/oradata/ORCL/marcov_07.dbf
Datafiles required for transportable tablespace MARCOV_08:
/opt/app/oracle/oradata/ORCL/marcov_08.dbf
Datafiles required for transportable tablespace MARCOV_09:
/opt/app/oracle/oradata/ORCL/marcov_09.dbf
Datafiles required for transportable tablespace MARCOV_10:
/opt/app/oracle/oradata/ORCL/marcov_10.dbf
Datafiles required for transportable tablespace USERS:
/opt/app/oracle/oradata/ORCL/users01.dbf
Job "SYSTEM"."SYS_EXPORT_FULL_01" successfully completed at Thu Aug 8 12:19:16 2013 elapsed 0 00:02:26</pre>
At the end of the log file you can see the datafiles I have to transport to the source pluggable database.<br />
In the new pluggable database the <b>DATA_PUMP_DIR</b> directory object is not created automatically, so before proceeding I have to
create a new directory object and granting all the necessary privileges.
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ export ORACLE_SID=CDBTEST
[oracle@vsi08devpom ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Thu Aug 8 12:36:46 2013
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL@CDBTEST> alter session set container=ORCL2;
Session altered.
SQL@ORCL2> create directory ORCL2_DATA_PUMP_DIR as '/opt/app/oracle/admin/CDBTEST/dpdump/';
Directory created.
SQL@ORCL2> grant read,write on directory ORCL2_DATA_PUMP_DIR to system;
Grant succeeded.
SQL@ORCL2> SELECT * FROM DBA_DIRECTORIES WHERE DIRECTORY_NAME = 'ORCL2_DATA_PUMP_DIR';
OWNER DIRECTORY_NAME DIRECTORY_PATH ORIGIN_CON_ID
----- -------------------- ---------------------------------------- -------------
SYS ORCL2_DATA_PUMP_DIR /opt/app/oracle/admin/CDBTEST/dpdump/ 8</pre>
I need to copy the dump file to the directory pointed to by the <b>ORCL2_DATA_PUMP_DIR</b> directory object.<br />
In my case the non-container database and the new pluggable database are on the same machine so I can use a simple <b>cp</b> command.
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ cp /opt/app/oracle/admin/ORCL/dpdump/full_orcl.dmp /opt/app/oracle/admin/CDBTEST/dpdump/</pre>
I need also to copy the datafiles of the transportable tablespaces from the source non-container database to a place accessible to the pluggable database.<br />
The default directory currently contains the following datafiles:
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ORCL2]$ pwd
/opt/app/oracle/oradata/CDBTEST/ORCL2
[oracle@vsi08devpom ORCL2]$ ll
total 922608
-rw-r----- 1 oracle oinstall 5251072 Aug 8 12:37 ORCL2_users01.dbf
-rw-r----- 1 oracle oinstall 665853952 Aug 8 14:45 sysaux01.dbf
-rw-r----- 1 oracle oinstall 272637952 Aug 8 14:45 system01.dbf
-rw-r----- 1 oracle oinstall 20979712 Aug 8 13:22 temp01.dbf</pre>
My transportable tablespaces coming from the non-container database ORCL are now copied into a directory accessible by the pluggable database ORCL2.
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ cp /opt/app/oracle/oradata/ORCL/users01.dbf /opt/app/oracle/oradata/ORCL/marcov_* /opt/app/oracle/oradata/CDBTEST/ORCL2/
[oracle@vsi08devpom ORCL2]$ ll
total 1132868
-rw-r----- 1 oracle oinstall 20979712 Aug 8 14:49 marcov_01.dbf
-rw-r----- 1 oracle oinstall 20979712 Aug 8 14:49 marcov_02.dbf
-rw-r----- 1 oracle oinstall 20979712 Aug 8 14:49 marcov_03.dbf
-rw-r----- 1 oracle oinstall 20979712 Aug 8 14:49 marcov_04.dbf
-rw-r----- 1 oracle oinstall 20979712 Aug 8 14:49 marcov_05.dbf
-rw-r----- 1 oracle oinstall 20979712 Aug 8 14:49 marcov_06.dbf
-rw-r----- 1 oracle oinstall 20979712 Aug 8 14:49 marcov_07.dbf
-rw-r----- 1 oracle oinstall 20979712 Aug 8 14:49 marcov_08.dbf
-rw-r----- 1 oracle oinstall 20979712 Aug 8 14:49 marcov_09.dbf
-rw-r----- 1 oracle oinstall 20979712 Aug 8 14:49 marcov_10.dbf
-rw-r----- 1 oracle oinstall 5251072 Aug 8 12:37 ORCL2_users01.dbf
-rw-r----- 1 oracle oinstall 665853952 Aug 8 14:45 sysaux01.dbf
-rw-r----- 1 oracle oinstall 272637952 Aug 8 14:45 system01.dbf
-rw-r----- 1 oracle oinstall 20979712 Aug 8 13:22 temp01.dbf
-rw-r----- 1 oracle oinstall 5251072 Aug 8 14:49 users01.dbf</pre>
Add an entry to the <b>tnsnames.ora</b> file referencing to the service of the pluggable database.
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ vi /opt/app/oracle/product/12.1.0/db_1/network/admin/tnsnames.ora
ORCL2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vsi08devpom.mydomain.it)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCL2)
)
)</pre>
List all your datafiles in the <b>TRANSPORT_DATAFILES</b> option of the <b>Data Dump Import</b> utility (or use a <b>parameter file</b> if you have many datafiles to specify).
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ impdp system/oracle@orcl2 TRANSPORT_DATAFILES='/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_01.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_02.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_03.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_04.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_05.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_06.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_07.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_08.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_09.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_10.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/users01.dbf' FULL=Y DIRECTORY=ORCL2_DATA_PUMP_DIR dumpfile=full_orcl.dmp
Import: Release 12.1.0.1.0 - Production on Thu Aug 8 15:27:18 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_FULL_01": system/********@orcl2 TRANSPORT_DATAFILES=/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_01.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_02.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_03.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_04.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_05.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_06.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_07.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_08.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_09.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_10.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/users01.dbf FULL=Y DIRECTORY=ORCL2_DATA_PUMP_DIR dumpfile=full_orcl.dmp
Processing object type DATABASE_EXPORT/PRE_SYSTEM_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/PRE_INSTANCE_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/PLUGTS_FULL/PLUGTS_BLK
ORA-39123: Data Pump transportable tablespace job aborted
ORA-29349: tablespace 'USERS' already exists
Job "SYSTEM"."SYS_IMPORT_FULL_01" stopped due to fatal error at Thu Aug 8 15:27:28 2013 elapsed 0 00:00:08</pre>
The new pluggable database ORCL2 has already a tablespace named <b>USERS</b> so the <b>Data Pump Import</b> utility aborted its job with the error <b>"ORA-29349: tablespace 'USERS' already exists"</b>. I decided to rename the already existing tablespace to <b>USERS_ORCL2</b>.
<br />
<pre class="cpp" name="code">SQL@ORCL2> alter tablespace USERS rename to USERS_ORCL2;
Tablespace altered.</pre>
Now I can run the import job again.
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ impdp system/oracle@orcl2 TRANSPORT_DATAFILES='/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_01.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_02.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_03.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_04.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_05.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_06.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_07.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_08.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_09.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_10.dbf','/opt/app/oracle/oradata/CDBTEST/ORCL2/users01.dbf' FULL=Y DIRECTORY=ORCL2_DATA_PUMP_DIR dumpfile=full_orcl.dmp
Import: Release 12.1.0.1.0 - Production on Thu Aug 8 15:30:33 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_FULL_01": system/********@orcl2 TRANSPORT_DATAFILES=/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_01.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_02.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_03.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_04.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_05.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_06.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_07.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_08.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_09.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/marcov_10.dbf,/opt/app/oracle/oradata/CDBTEST/ORCL2/users01.dbf FULL=Y DIRECTORY=ORCL2_DATA_PUMP_DIR dumpfile=full_orcl.dmp
Processing object type DATABASE_EXPORT/PRE_SYSTEM_IMPCALLOUT/MARKER
ORA-39342: Internal error - failed to import internal objects tagged with LABEL_SECURITY due to ORA-00955: name is already used by an existing object.
Processing object type DATABASE_EXPORT/PRE_INSTANCE_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/PLUGTS_FULL/PLUGTS_BLK
Processing object type DATABASE_EXPORT/TABLESPACE
ORA-39083: Object type TABLESPACE:"UNDOTBS1" failed to create with error:
ORA-01516: nonexistent log file, data file, or temporary file "/opt/app/oracle/oradata/ORCL/undotbs01.dbf"
Failing sql is:
ALTER DATABASE DATAFILE '/opt/app/oracle/oradata/ORCL/undotbs01.dbf' RESIZE 241172480
ORA-31684: Object type TABLESPACE:"TEMP" already exists
Processing object type DATABASE_EXPORT/PROFILE
Processing object type DATABASE_EXPORT/SYS_USER/USER
Processing object type DATABASE_EXPORT/SCHEMA/USER
ORA-31684: Object type USER:"OUTLN" already exists
Processing object type DATABASE_EXPORT/RADM_FPTM
Processing object type DATABASE_EXPORT/GRANT/SYSTEM_GRANT/PROC_SYSTEM_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/DEFAULT_ROLE
Processing object type DATABASE_EXPORT/SCHEMA/ON_USER_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/TABLESPACE_QUOTA
Processing object type DATABASE_EXPORT/RESOURCE_COST
Processing object type DATABASE_EXPORT/TRUSTED_DB_LINK
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/PRE_SYSTEM_ACTIONS/PROCACT_SYSTEM
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/PROCOBJ
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/POST_SYSTEM_ACTIONS/PROCACT_SYSTEM
Processing object type DATABASE_EXPORT/SCHEMA/PROCACT_SCHEMA
Processing object type DATABASE_EXPORT/EARLY_OPTIONS/VIEWS_AS_TABLES/TABLE
Processing object type DATABASE_EXPORT/EARLY_OPTIONS/VIEWS_AS_TABLES/TABLE_DATA
. . imported "SYS"."KU$_EXPORT_USER_MAP" 5.906 KB 28 rows
Processing object type DATABASE_EXPORT/EARLY_POST_INSTANCE_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/TABLE
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/TABLE_DATA
. . imported "SYS"."AMGT$DP$DAM_CONFIG_PARAM$" 6.507 KB 14 rows
. . imported "SYS"."DP$TSDP_PARAMETER$" 5.929 KB 1 rows
. . imported "SYS"."DP$TSDP_POLICY$" 5.898 KB 1 rows
. . imported "SYS"."DP$TSDP_SUBPOL$" 6.304 KB 1 rows
. . imported "SYSTEM"."REDO_DB_TMP" 23.42 KB 1 rows
. . imported "WMSYS"."E$ENV_VARS$" 6.062 KB 5 rows
. . imported "WMSYS"."E$EVENTS_INFO$" 5.796 KB 12 rows
. . imported "WMSYS"."E$HINT_TABLE$" 9.437 KB 75 rows
. . imported "WMSYS"."E$NEXTVER_TABLE$" 6.359 KB 1 rows
. . imported "WMSYS"."E$VERSION_HIERARCHY_TABLE$" 5.960 KB 1 rows
. . imported "WMSYS"."E$WORKSPACES_TABLE$" 12.08 KB 1 rows
. . imported "WMSYS"."E$WORKSPACE_PRIV_TABLE$" 6.546 KB 8 rows
. . imported "SYS"."AMGT$DP$AUD$" 0 KB 0 rows
. . imported "SYS"."AMGT$DP$DAM_CLEANUP_EVENTS$" 0 KB 0 rows
. . imported "SYS"."AMGT$DP$DAM_CLEANUP_JOBS$" 0 KB 0 rows
. . imported "SYS"."DP$TSDP_ASSOCIATION$" 0 KB 0 rows
. . imported "SYS"."DP$TSDP_CONDITION$" 0 KB 0 rows
. . imported "SYS"."DP$TSDP_FEATURE_POLICY$" 0 KB 0 rows
. . imported "SYS"."DP$TSDP_PROTECTION$" 0 KB 0 rows
. . imported "SYS"."DP$TSDP_SENSITIVE_DATA$" 0 KB 0 rows
. . imported "SYS"."DP$TSDP_SENSITIVE_TYPE$" 0 KB 0 rows
. . imported "SYS"."DP$TSDP_SOURCE$" 0 KB 0 rows
. . imported "SYSTEM"."REDO_LOG_TMP" 0 KB 0 rows
. . imported "WMSYS"."E$BATCH_COMPRESSIBLE_TABLES$" 0 KB 0 rows
. . imported "WMSYS"."E$CONSTRAINTS_TABLE$" 0 KB 0 rows
. . imported "WMSYS"."E$CONS_COLUMNS$" 0 KB 0 rows
. . imported "WMSYS"."E$LOCKROWS_INFO$" 0 KB 0 rows
. . imported "WMSYS"."E$MODIFIED_TABLES$" 0 KB 0 rows
. . imported "WMSYS"."E$MP_GRAPH_WORKSPACES_TABLE$" 0 KB 0 rows
. . imported "WMSYS"."E$MP_PARENT_WORKSPACES_TABLE$" 0 KB 0 rows
. . imported "WMSYS"."E$NESTED_COLUMNS_TABLE$" 0 KB 0 rows
. . imported "WMSYS"."E$REMOVED_WORKSPACES_TABLE$" 0 KB 0 rows
. . imported "WMSYS"."E$RESOLVE_WORKSPACES_TABLE$" 0 KB 0 rows
. . imported "WMSYS"."E$RIC_LOCKING_TABLE$" 0 KB 0 rows
. . imported "WMSYS"."E$RIC_TABLE$" 0 KB 0 rows
. . imported "WMSYS"."E$RIC_TRIGGERS_TABLE$" 0 KB 0 rows
. . imported "WMSYS"."E$UDTRIG_DISPATCH_PROCS$" 0 KB 0 rows
. . imported "WMSYS"."E$UDTRIG_INFO$" 0 KB 0 rows
. . imported "WMSYS"."E$VERSION_TABLE$" 0 KB 0 rows
. . imported "WMSYS"."E$VT_ERRORS_TABLE$" 0 KB 0 rows
. . imported "WMSYS"."E$WORKSPACE_SAVEPOINTS_TABLE$" 0 KB 0 rows
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/VIEWS_AS_TABLES/TABLE
Processing object type DATABASE_EXPORT/NORMAL_OPTIONS/VIEWS_AS_TABLES/TABLE_DATA
. . imported "SYSTEM"."SCHEDULER_PROGRAM_ARGS_TMP" 9.484 KB 12 rows
. . imported "SYS"."AMGT$DP$AUDTAB$TBS$FOR_EXPORT" 5.937 KB 2 rows
. . imported "SYS"."NACL$_ACE_IMP" 9.914 KB 1 rows
. . imported "SYS"."NACL$_HOST_IMP" 6.898 KB 1 rows
. . imported "WMSYS"."E$EXP_MAP" 7.703 KB 3 rows
. . imported "SYS"."DP$DBA_SENSITIVE_DATA" 0 KB 0 rows
. . imported "SYS"."DP$DBA_TSDP_POLICY_PROTECTION" 0 KB 0 rows
. . imported "SYS"."AMGT$DP$FGA_LOG$FOR_EXPORT" 0 KB 0 rows
. . imported "SYS"."NACL$_WALLET_IMP" 0 KB 0 rows
. . imported "SYSTEM"."SCHEDULER_JOB_ARGS_TMP" 0 KB 0 rows
Processing object type DATABASE_EXPORT/NORMAL_POST_INSTANCE_IMPCALLOU/MARKER
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type DATABASE_EXPORT/STATISTICS/MARKER
Processing object type DATABASE_EXPORT/END_PLUGTS_BLK
Processing object type DATABASE_EXPORT/FINAL_POST_INSTANCE_IMPCALLOUT/MARKER
Processing object type DATABASE_EXPORT/SCHEMA/POST_SCHEMA/PROCACT_SCHEMA
Processing object type DATABASE_EXPORT/AUDIT_UNIFIED/AUDIT_POLICY_ENABLE
Processing object type DATABASE_EXPORT/POST_SYSTEM_IMPCALLOUT/MARKER
Job "SYSTEM"."SYS_IMPORT_FULL_01" completed with 4 error(s) at Thu Aug 8 15:31:59 2013 elapsed 0 00:01:25</pre>
After the import job is completed (the above errors can be ignored in my case) I'm able to use the new pluggable database ORCL2:<br />
it contains all the data previously used in the non-container database ORCL.
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom CDBTEST]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Thu Aug 8 15:50:21 2013
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL@CDBTEST> alter session set container=ORCL2;
Session altered.
SQL@ORCL2> select count(*) from marcov_01.t1;
COUNT(*)
----------
10
SQL@ORCL2> select count(*) from marcov_10.t1;
COUNT(*)
----------
10</pre>
That's all.
Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com9tag:blogger.com,1999:blog-3005934468887687781.post-26060356943350787302013-08-13T11:32:00.001+01:002013-08-13T18:19:45.420+01:00The first bug on Oracle Database 12c: how to create a PDB by cloning a remote existing pluggable databaseIn this post I want to describe how to create a PDB by cloning a remote existing pluggable database: at the end of this process you should have a new PDB (in my case PDB103) contained in a target CDB (CDB001) cloned from a source PDB (PDB003) contained in a remote different CDB (CDBTEST).<br />
In my case both source and target databases are located on the same machine.<br />
<br />
When I took part at the presentation of the new Oracle Database 12c here in Rome I took some pictures, but I was not ready with my phone when an interesting slide was presented.<br />
<br />
While testing the scenario of today I suddenly remembered about that missing pictures: luckily few days later I received from Oracle also the pdf of the event so I'm now able to show you the following screenshot:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-DlPqB-CVJLE/UgoGU0mjBlI/AAAAAAAAC4A/DPONR6y9kNc/s1600/OraclePresentation.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="272" src="http://3.bp.blogspot.com/-DlPqB-CVJLE/UgoGU0mjBlI/AAAAAAAAC4A/DPONR6y9kNc/s400/OraclePresentation.png" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
In 2006 I tested the beta release of Oracle Database 11gR1 because at that time my company needed to test new features for its products.<br />
As you can read from the screenshot many test cases were conducted by Oracle and by beta testers, but a bug is always behind the corner when you consider a complex software solution as the Oracle Database and today I'm not able to close my thread with the usual "That's all" comment.<br />
<br />
Anyway let's start describing the content of my current containers.
My machine has two container databases named CDB001 and CBTEST.
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ ps -ef|grep smon
oracle 4081 1 0 Jul15 ? 00:01:23 ora_smon_CDB001
oracle 16455 1 0 Jul17 ? 00:01:25 ora_smon_CDBTEST
oracle 26501 26466 0 14:08 pts/1 00:00:00 grep smon</pre>
On the target database CDB001 there is only one pluggable database (PDB101)
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ env|grep SID
ORACLE_SID=CDB001
[oracle@vsi08devpom ~]$ sqlplus / as sysdba
SQL@CDB001> select name, open_mode from V$PDBS;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB0101 READ WRITE</pre>
On the source database CDBTEST there are four pluggable databases (PDBTEST1, PDBTEST2, PDBTEST3 and PDB003)
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ env|grep SID
ORACLE_SID=CDBTEST
SQL@CDBTEST> select NAME, OPEN_MODE FROM V$PDBS;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDBTEST1 READ WRITE
PDBTEST2 READ WRITE
PDBTEST3 READ WRITE
PDB003 READ WRITE</pre>
The PDB003 pluggable database contains few rows into MARCOV.T1 table:
<br />
<pre class="cpp" name="code">SQL@CDBTEST> alter session set container=PDB003;
Session altered.
SQL@CDBTEST> select count(*) from marcov.T1;
COUNT(*)
----------
100</pre>
I'm going to create a database link into the CDB001 container database connecting to CDBTEST using the ezconnect method.
<br />
<pre class="cpp" name="code">SQL@CDB001> create database link CDBTEST_AT_VSI08DEVPOM connect to SYSTEM identified by oracle using 'vsi08devpom.mydomain.it:1521/CDBTEST';
Database link created.</pre>
I'm able to successfully test the new database link.
<br />
<pre class="cpp" name="code">SQL@CDB001> select * from cdb_pdbs;
PDB_ID PDB_NAME DBID CON_UID GUID STATUS CREATION_SCN CON_ID
---------- ---------- ---------- ---------- -------------------------------- ------------- ------------ ----------
3 PDB0101 532253118 532253118 E18E282148FD10A5E0430100007FC94D NORMAL 1734497 1
2 PDB$SEED 4063453634 4063453634 E18E1CE36B940C96E0430100007FE168 NORMAL 1720746 1
SQL@CDB001> select * from cdb_pdbs@CDBTEST_AT_VSI08DEVPOM;
PDB_ID PDB_NAME DBID CON_UID GUID STATUS CREATION_SCN CON_ID
---------- ---------- ---------- ---------- -------------------------------- ------------- ------------ ----------
2 PDB$SEED 4063610283 4063610283 E1B2A529DB382EACE0430100007F78B8 NORMAL 217 1
3 PDBTEST1 3064465721 3064465721 E1B436871D9E4110E0430100007F9BBC NORMAL 1547881 1
4 PDBTEST2 2395404598 2395404598 E1B43A36FA0B41A9E0430100007F6671 NORMAL 1548944 1
5 PDBTEST3 2434165039 2434165039 E1B43D98C0DC41F6E0430100007F7CE7 NORMAL 1550036 1
6 PDB003 1448206714 1448206714 E2B9BE56B8B936CEE045000000000001 NORMAL 2744910 1</pre>
Under the directory of the CDB001 container there are the following files and directories:
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom CDB001]$ pwd
/opt/app/oracle/oradata/CDB001
[oracle@vsi08devpom CDB001]$ ll
total 2286044
-rw-r----- 1 oracle oinstall 17973248 Aug 5 14:18 control01.ctl
drwxr-x--- 2 oracle oinstall 4096 Jul 15 15:52 PDB0101
drwxr-x--- 2 oracle oinstall 4096 Jul 15 15:48 pdbseed
-rw-r----- 1 oracle oinstall 52429312 Aug 5 14:00 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Aug 5 14:18 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Aug 5 02:20 redo03.log
-rw-r----- 1 oracle oinstall 1226842112 Aug 5 14:15 sysaux01.dbf
-rw-r----- 1 oracle oinstall 828383232 Aug 5 14:15 system01.dbf
-rw-r----- 1 oracle oinstall 62922752 Aug 5 13:52 temp01.dbf
-rw-r----- 1 oracle oinstall 94380032 Aug 5 14:15 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Aug 5 14:06 users01.dbf</pre>
As usual to clone the remote pluggable database it must be in READ ONLY mode. The current open mode of PDB003 pluggable database is READ WRITE.
<br />
<pre class="cpp" name="code">SQL@CDBTEST> select pdb_name, status from CDB_PDBS;
PDB_NAME STATUS
---------- -------------
PDB$SEED NORMAL
PDBTEST1 NORMAL
PDBTEST2 NORMAL
PDBTEST3 NORMAL
PDB003 NORMAL
SQL@CDBTEST> select name, open_mode from V$PDBS;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDBTEST1 READ WRITE
PDBTEST2 READ WRITE
PDBTEST3 READ WRITE
PDB003 READ WRITE</pre>
I need to close and open it in READ ONLY mode.
<br />
<pre class="cpp" name="code">SQL@CDBTEST> alter pluggable database PDB003 close immediate;
Pluggable database altered.
SQL@CDBTEST> alter pluggable database PDB003 open read only;
Pluggable database altered.</pre>
From the target container database I can now issue the following command to clone the pluggable database PDB003 contained in the remote database container CDBTEST.
<br />
<pre class="cpp" name="code">SQL@CDB001> create pluggable database PDB103 from PDB003@CDBTEST_AT_VSI08DEVPOM file_name_convert=('/opt/app/oracle/oradata/CDBTEST/PDB003','/opt/app/oracle/oradata/CDB001/PDB103');
create pluggable database PDB103 from PDB003@CDBTEST_AT_VSI08DEVPOM file_name_convert=('/opt/app/oracle/oradata/CDBTEST/PDB003','/opt/app/oracle/oradata/CDB001/PDB103');
*
ERROR at line 1:
ORA-17628: Oracle error 19505 returned by remote Oracle server
ORA-19505: failed to identify file ""
</pre>
On the alert log the following error is logged:
<br />
<pre class="cpp" name="code">ORA-17628 signalled during: create pluggable database PDB103 from PDB003@CDBTEST_AT_VSI08DEVPOM file_name_convert=('/opt/app/oracle/oradata/CDBTEST/PDB003','/opt/app/oracle/oradata/CDB001/PDB103')...</pre>
Because the database link can connect to either the root of the remote container database or directly to the remote pluggable database, I decided, after several failed attempts, to create another database link referencing the remote pluggable database:
<br />
<pre class="cpp" name="code">SQL@CDB001> create database link PDB003_AT_CDBTEST connect to SYSTEM identified by oracle using 'vsi08devpom.recupitalia.it:1521/pdb003';
Database link created.
SQL@CDB001> select * from cdb_pdbs@PDB003_AT_CDBTEST;
no rows selected</pre>
But even with the different database link the statement continues to fail:
<br />
<pre class="cpp" name="code">SQL@CDB001> create pluggable database PDB103 from PDB003@PDB003_AT_CDBTEST file_name_convert=('/opt/app/oracle/oradata/CDBTEST/PDB003','/opt/app/oracle/oradata/CDB001/PDB103');
create pluggable database PDB103 from PDB003@PDB003_AT_CDBTEST file_name_convert=('/opt/app/oracle/oradata/CDBTEST/PDB003','/opt/app/oracle/oradata/CDB001/PDB103')
*
ERROR at line 1:
ORA-17628: Oracle error 19505 returned by remote Oracle server
ORA-19505: failed to identify file ""</pre>
Let's try using a different method to connect the two database containers and create another database link using the following CDBTEST tns entry:
<br />
<pre class="cpp" name="code">CDBTEST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vsi08devpom.mydomain.it)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = CDBTEST)
)
)</pre>
Creation and testing of the database link using the CDBTEST tns entry.
<br />
<pre class="cpp" name="code">SQL@CDB001> create database link CDBTEST_TNS_AT_VSI08DEVPOM connect to SYSTEM identified by oracle using 'CDBTEST';
Database link created.
SQL@CDB001> select * from cdb_pdbs@CDBTEST_TNS_AT_VSI08DEVPOM;
PDB_ID PDB_NAME DBID CON_UID GUID STATUS CREATION_SCN CON_ID
---------- ---------- ---------- ---------- -------------------------------- ------------- ------------ ----------
2 PDB$SEED 4063610283 4063610283 E1B2A529DB382EACE0430100007F78B8 NORMAL 217 1
3 PDBTEST1 3064465721 3064465721 E1B436871D9E4110E0430100007F9BBC NORMAL 1547881 1
4 PDBTEST2 2395404598 2395404598 E1B43A36FA0B41A9E0430100007F6671 NORMAL 1548944 1
5 PDBTEST3 2434165039 2434165039 E1B43D98C0DC41F6E0430100007F7CE7 NORMAL 1550036 1
6 PDB003 1448206714 1448206714 E2B9BE56B8B936CEE045000000000001 NORMAL 2744910 1</pre>
The statement using the CDBTEST_TNS_AT_VSI08DEVPOM database link still continues to fail:
<br />
<pre class="cpp" name="code">SQL@CDB001> create pluggable database PDB103 from PDB003@CDBTEST_TNS_AT_VSI08DEVPOM file_name_convert=('/opt/app/oracle/oradata/CDBTEST/PDB003','/opt/app/oracle/oradata/CDB001/PDB103');
create pluggable database PDB103 from PDB003@CDBTEST_TNS_AT_VSI08DEVPOM file_name_convert=('/opt/app/oracle/oradata/CDBTEST/PDB003','/opt/app/oracle/oradata/CDB001/PDB103')
*
ERROR at line 1:
ORA-17628: Oracle error 19505 returned by remote Oracle server
ORA-19505: failed to identify file ""</pre>
Let's create the latest database link connected to the following tns entry:
<br />
<pre class="cpp" name="code">PDB003_CDBTEST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vsi08devpom.mydomain.it)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb003)
)
)</pre>
Creation and testing of the database link using the PDB003_CDBTEST tns entry.
<br />
<pre class="cpp" name="code">SQL@CDB001> create database link PDB003_TNS_AT_VSI08DEVPOM connect to SYSTEM identified by oracle using 'PDB003_CDBTEST';
Database link created.
SQL@CDB001> select * from cdb_pdbs@PDB003_TNS_AT_VSI08DEVPOM;
no rows selected</pre>
The statement continues to fail even using the latest available database link: PDB003_TNS_AT_VSI08DEVPOM
<br />
<pre class="cpp" name="code">SQL@CDB001> create pluggable database PDB103 from PDB003@PDB003_TNS_AT_VSI08DEVPOM file_name_convert=('/opt/app/oracle/oradata/CDBTEST/PDB003','/opt/app/oracle/oradata/CDB001/PDB103');
create pluggable database PDB103 from PDB003@PDB003_TNS_AT_VSI08DEVPOM file_name_convert=('/opt/app/oracle/oradata/CDBTEST/PDB003','/opt/app/oracle/oradata/CDB001/PDB103')
*
ERROR at line 1:
ORA-17628: Oracle error 19505 returned by remote Oracle server
ORA-19505: failed to identify file ""</pre>
The available database links created and used are the following:
<br />
<pre class="cpp" name="code">SQL@CDB001> select DB_LINK, HOST, OWNER from dba_db_links;
DB_LINK HOST OWNER
------------------------------ --------------------------------------------- -----
CDBTEST_AT_VSI08DEVPOM vsi08devpom.mydomain.it:1521/CDBTEST SYS
PDB003_AT_CDBTEST vsi08devpom.mydomain.it:1521/pdb003 SYS
CDBTEST_TNS_AT_VSI08DEVPOM CDBTEST SYS
PDB003_TNS_AT_VSI08DEVPOM PDB003_CDBTEST SYS</pre>
And there is still no way to create a pluggable database to a remote target destination from a local source. You can see on the <b>"SQL Language Reference"</b> which <b>CREATE PLUGGABLE DATABASE</b> syntax is allowed:
<br />
<pre class="cpp" name="code">SQL@CDBTEST> create pluggable database PDB103@CDB001_AT_VSI08DEVPOM from PDB003;
create pluggable database PDB103@CDB001_AT_VSI08DEVPOM from PDB003;
*
ERROR at line 1:
ORA-00922: missing or invalid option</pre>
Even tracing the unix Oracle server process with the <b>strace</b> system util I was not able to get useful information to know how successfully complete the statement and why it's failing.<br />
<br />
The end of the story: after I have contacted My Oracle Support the Oracle engineer confirmed the issue, tracked as <b>bug 15931910</b> and it is still being worked upon by the development team.<br />
Other platforms could be affected by this bug but I have no reason and time to test it.<br />
<br />
So at the moment there is no way to clone a remote pluggable database using a database link, but as a workaround you can follow this post to manually create it to the new target destination
Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com8tag:blogger.com,1999:blog-3005934468887687781.post-49339621719583245542013-08-07T12:30:00.001+01:002013-08-07T12:30:27.344+01:00How to create a PDB from a Non-CDB using DBMS_PDB packageTo test this scenario I have recently created using DBCA a non container database named ORCL. CDB001 and CDBTEST are instead two container databases.
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ ps -ef|grep smon
oracle 4081 1 0 Jul15 ? 00:01:30 ora_smon_CDB001
oracle 11394 1 0 10:20 ? 00:00:00 ora_smon_ORCL
oracle 12586 9609 0 10:46 pts/0 00:00:00 grep smon
oracle 16455 1 0 Jul17 ? 00:01:34 ora_smon_CDBTEST</pre>
I want to consolidate this database plugging it into a container database.<br />
In this scenario I'm going to use the <b>DBMS_PDB</b> package to create the XML file with the metadata of ORCL database.<br />
Before using the <b>DBMS_PDB.DESCRIBE</b> procedure, the ORCL database needs to be in READ ONLY mode.
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ export ORACLE_SID=ORCL
[oracle@vsi08devpom ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Wed Aug 7 10:47:29 2013
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL@ORCL> show con_name;
CON_NAME
------------------------------
Non Consolidated
SQL@ORCL> select name, open_mode from V$DATABASE;
NAME OPEN_MODE
--------- --------------------
ORCL READ WRITE
SQL@ORCL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL@ORCL> startup mount;
ORACLE instance started.
Total System Global Area 471830528 bytes
Fixed Size 2289688 bytes
Variable Size 264245224 bytes
Database Buffers 197132288 bytes
Redo Buffers 8163328 bytes
Database mounted.
SQL@ORCL> alter database open read only;
Database altered.</pre>
<pre class="cpp" name="code">SQL@ORCL> begin
2 dbms_pdb.describe( pdb_descr_file => '/opt/app/oracle/oradata/orcl.xml');
3 end;
4 /
PL/SQL procedure successfully completed.
SQL@ORCL> host ls /opt/app/oracle/oradata/orcl*
/opt/app/oracle/oradata/orcl.xml
SQL@ORCL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL@ORCL> exit
</pre>
Now connect to the container database. In my case I want to plug ORCL database into the CDBTEST container.
It currently contains 4 pluggable databases.
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ export ORACLE_SID=CDBTEST
[oracle@vsi08devpom ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Wed Aug 7 11:07:12 2013
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL@CDBTEST> show con_name;
CON_NAME
------------------------------
CDB$ROOT
SQL@CDBTEST> select name, open_mode from V$PDBS;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDBTEST1 READ WRITE
PDBTEST2 READ WRITE
PDBTEST3 READ WRITE
PDB003 READ ONLY</pre>
Here is the situation of the directories for the CDBTEST container database:
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ cd /opt/app/oracle/oradata/CDBTEST/
[oracle@vsi08devpom CDBTEST]$ ll
total 3459784
-rw-r----- 1 oracle oinstall 17973248 Aug 7 11:13 control01.ctl
drwxr-x--- 2 oracle oinstall 4096 Aug 1 14:54 PDB003
drwxr-x--- 2 oracle oinstall 4096 Jul 17 11:25 pdbseed
drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:16 PDBTEST1
drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:17 PDBTEST2
drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:18 PDBTEST3
-rw-r----- 1 oracle oinstall 52429312 Aug 7 11:12 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Aug 7 00:16 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Aug 7 06:00 redo03.log
-rw-r----- 1 oracle oinstall 1310728192 Aug 7 11:12 sysaux01.dbf
-rw-r----- 1 oracle oinstall 828383232 Aug 7 11:12 system01.dbf
-rw-r----- 1 oracle oinstall 63971328 Aug 7 11:01 temp01.dbf
-rw-r----- 1 oracle oinstall 1205870592 Aug 7 11:12 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Aug 7 06:05 users01.dbf</pre>
Now you can plug the ORCL database into the CDBTEST container database using the usual syntax (have a look at <a href="http://dbaworkshop.blogspot.it/2013/08/How-to-create-a-pluggable-database-by-unplugging-an-existing-PDB-and-plugging-it-into-another-container.html" target="_blank">this post</a>)
<br />
<pre class="cpp" name="code">SQL@CDBTEST> create pluggable database ORCL using '/opt/app/oracle/oradata/orcl.xml' copy file_name_convert=('/opt/app/oracle/oradata/ORCL','/opt/app/oracle/oradata/CDBTEST/ORCL');
Pluggable database created.</pre>
The Oracle software copies under the directory <b>/opt/app/oracle/oradata/CDBTEST/ORCL</b> all the datafiles coming from <b>/opt/app/oracle/oradata/ORCL</b> location.
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom CDBTEST]$ ll
total 3459788
-rw-r----- 1 oracle oinstall 17973248 Aug 7 12:10 control01.ctl
drwxr-x--- 2 oracle oinstall 4096 Aug 7 11:49 ORCL
drwxr-x--- 2 oracle oinstall 4096 Aug 1 14:54 PDB003
drwxr-x--- 2 oracle oinstall 4096 Jul 17 11:25 pdbseed
drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:16 PDBTEST1
drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:17 PDBTEST2
drwxr-x--- 2 oracle oinstall 4096 Jul 17 13:18 PDBTEST3
-rw-r----- 1 oracle oinstall 52429312 Aug 7 12:10 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Aug 7 00:16 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Aug 7 06:00 redo03.log
-rw-r----- 1 oracle oinstall 1310728192 Aug 7 12:10 sysaux01.dbf
-rw-r----- 1 oracle oinstall 828383232 Aug 7 12:07 system01.dbf
-rw-r----- 1 oracle oinstall 63971328 Aug 7 12:03 temp01.dbf
-rw-r----- 1 oracle oinstall 1205870592 Aug 7 12:10 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Aug 7 06:05 users01.dbf</pre>
A new pluggable database is created with a <b>NEW</b> status
<br />
<pre class="cpp" name="code">SQL@CDBTEST> select pdb_id, pdb_name, dbid, status, creation_scn, con_id from CDB_PDBS;
PDB_ID PDB_NAME DBID STATUS CREATION_SCN CON_ID
---------- ---------- ---------- ------------- ------------ ----------
2 PDB$SEED 4063610283 NORMAL 217 1
3 PDBTEST1 3064465721 NORMAL 1547881 1
4 PDBTEST2 2395404598 NORMAL 1548944 1
5 PDBTEST3 2434165039 NORMAL 1550036 1
6 PDB003 1448206714 NORMAL 2744910 1
7 ORCL 1350603571 NEW 3226095 1</pre>
It's still not the time to open the new PDB.<br />
You need <b>first</b> to execute, while connected to the new pluggable database, the script <b>$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql</b>:
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom CDBTEST]$ ll /opt/app/oracle/product/12.1.0/db_1/rdbms/admin/noncdb_to_pdb.sql
-rw-r--r-- 1 oracle oinstall 19191 Apr 15 22:27 /opt/app/oracle/product/12.1.0/db_1/rdbms/admin/noncdb_to_pdb.sql
SQL@CDBTEST> alter session set container=ORCL;
Session altered.
SQL@CDBTEST> @/opt/app/oracle/product/12.1.0/db_1/rdbms/admin/noncdb_to_pdb.sql
SQL@CDBTEST> SET SERVEROUTPUT ON
SQL@CDBTEST> SET FEEDBACK 1
SQL@CDBTEST> SET NUMWIDTH 10
...
...
...
SQL@CDBTEST> -- leave the PDB in the same state it was when we started
SQL@CDBTEST> BEGIN
2 execute immediate '&open_sql &restricted_state';
3 EXCEPTION
4 WHEN OTHERS THEN
5 BEGIN
6 IF (sqlcode <> -900) THEN
7 RAISE;
8 END IF;
9 END;
10 END;
11 /
PL/SQL procedure successfully completed.
SQL@CDBTEST>
SQL@CDBTEST> WHENEVER SQLERROR CONTINUE;
SQL@CDBTEST></pre>
Now you can open the new ORCL pluggable database.
<br />
<pre class="cpp" name="code">SQL@CDBTEST> show con_name;
CON_NAME
------------------------------
ORCL
SQL@CDBTEST> alter database open;
Database altered.
</pre>
The database is so available and ready to be used.
<br />
<pre class="cpp" name="code">SQL@CDBTEST> select pdb_id, pdb_name, dbid, status, creation_scn, con_id from CDB_PDBS;
PDB_ID PDB_NAME DBID STATUS CREATION_SCN CON_ID
---------- ---------- ---------- ------------- ------------ ----------
2 PDB$SEED 4063610283 NORMAL 217 1
3 PDBTEST1 3064465721 NORMAL 1547881 1
4 PDBTEST2 2395404598 NORMAL 1548944 1
5 PDBTEST3 2434165039 NORMAL 1550036 1
6 PDB003 1448206714 NORMAL 2744910 1
7 ORCL 1350603571 NORMAL 3226095 1</pre>
That's all.
Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com3tag:blogger.com,1999:blog-3005934468887687781.post-37607108507710847162013-08-07T08:45:00.000+01:002013-08-07T08:45:11.039+01:00How to unplug a PDB and plug it back into the same CDBYou have just unplugged a PDB and want to know how to eventually plug it back into the same container.<br />
Let's assume I have a pluggable database named PDB003 and I am just able to unplug it using the following commands:
<br />
<pre class="cpp" name="code">SQL> alter pluggable database pdb003 close immediate;
Pluggable database altered.
SQL> alter pluggable database PDB003 unplug into '/app/oracle/oradata/pdb003.xml';
Pluggable database altered.
</pre>
If you query the <b>CDB_PDBS</b> view you can receive useful information about all PDBs contained: id, name, unique identifiers, SCN at the time of creation and the status.<br />
The STATUS column has several values:<br />
<ul>
<li><b>NEW</b>, the pdb has been created but never opened </li>
<li><b>NORMAL</b>, pdb available to be used </li>
<li><b>UNPLUGGED</b>, the pdb has been unplugged </li>
<li><b>NEEDS UPGRADE</b>, the pdb must be upgraded </li>
<li><b>CONVERTING</b>, a non-CDB is going to be converted into a pdb </li>
<li><b>UNUSABLE</b>, the pdb cannot be used (creation in progress) </li>
</ul>
In my case the PDB003 pluggable database is in an <b>UNPLUGGED</b> status as expected:
<br />
<pre class="cpp" name="code">SQL> select * from CDB_PDBS;
PDB_ID PDB_NAME DBID CON_UID GUID STATUS CREATION_SCN CON_ID
---------- ---------- ---------- ---------- -------------------------------- ------------- ------------ ----------
2 PDB$SEED 4063489868 4063489868 E19363E52C005C9AE045000000000001 NORMAL 233 1
3 PDB001 1701599811 1701599811 E1F26215682E1142E045000000000001 NORMAL 1821405 1
4 PDB002 1497027100 1497027100 E1F329ECE0F411E6E045000000000001 NORMAL 1844390 1
5 PDB003 1448206714 1448206714 E2B9BE56B8B936CEE045000000000001 UNPLUGGED 1997215 1</pre>
To plug again the pluggable database PDB003 inside the original container (CDB001) you cannot use a syntax like: <b>ALTER PLUGGABLE DATABASE ... PLUG</b> (it doesn't exist in the "SQL Language Reference" manual a PLUG clause) ...
<br />
<pre class="cpp" name="code">SQL> alter pluggable database PDB003 plug;
alter pluggable database PDB003 plug
*
ERROR at line 1:
ORA-00922: missing or invalid option</pre>
... neither you can simply use <b>CREATE PLUGGABLE DATABASE ... USING ...</b>
<br />
<pre class="cpp" name="code">SQL> create pluggable database PDB003 using '/app/oracle/oradata/pdb003.xml' nocopy tempfile reuse;
create pluggable database PDB003 using '/app/oracle/oradata/pdb003.xml' nocopy tempfile reuse
*
ERROR at line 1:
ORA-65012: Pluggable database PDB003 already exists.</pre>
You need first to drop the pluggable database (<b>DROP PLUGGABLE DATABASE</b> command) and then create it again (<b>CREATE PLUGGABLE DATABASE</b> command).<br />
In this way the pluggable database is plugged again into the same CDB and using the same PDB name.<br />
Have a look at the following commands:
<br />
<pre class="cpp" name="code">SQL> drop pluggable database PDB003;
Pluggable database dropped.
SQL> create pluggable database PDB003 using '/app/oracle/oradata/pdb003.xml' nocopy;
Pluggable database created.
SQL> select PDB_NAME, STATUS from CDB_PDBS;
PDB_NAME STATUS
---------- -------------
PDB$SEED NORMAL
PDB001 NORMAL
PDB002 NORMAL
PDB003 NEW
SQL> alter session set container=PDB003;
Session altered.
SQL> alter database open;
Database altered.
SQL> select count(*) from marcov.T1;
COUNT(*)
----------
100</pre>
Have a look again at the <b>CDB_PDBS</b> view and note the differences compared with the previous results.<br />
All the unique identifiers of PDB003
have been recreated.
<br />
<pre class="cpp" name="code">SQL> select * from CDB_PDBS;
PDB_ID PDB_NAME DBID CON_UID GUID STATUS CREATION_SCN CON_ID
---------- ---------- ---------- ---------- -------------------------------- ------------- ------------ ----------
2 PDB$SEED 4063489868 4063489868 E19363E52C005C9AE045000000000001 NORMAL 233 1
3 PDB001 1701599811 1701599811 E1F26215682E1142E045000000000001 NORMAL 1821405 1
4 PDB002 1497027100 1497027100 E1F329ECE0F411E6E045000000000001 NORMAL 1844390 1
5 PDB003 1448206714 1448206714 E2B9BE56B8B936CEE045000000000001 NORMAL 3110422 1</pre>
<br />
That's all.Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com8tag:blogger.com,1999:blog-3005934468887687781.post-77317627600520711662013-08-01T15:54:00.001+01:002013-09-08T17:42:25.149+01:00How to create a pluggable database by unplugging an existing PDB and plugging it into another containerSo I want to create a new pluggable database into the CDBTEST container located into vsi08devpom machine (@vsi08devpom in this post) and I want the exact copy of PDB003 pluggable database currently contained into CDB001 located into my local machine (@localhost in this post).<br />
<br />
Why not simply unplug it from my local machine and plug it into the target machine ?<br />
<br />
When you want to disconnect a pluggable database from a multitenant container you can unplug it, specifying a file containing its metadata information formatted in XML, used eventually if you want to plug it in another container like we want to do.<br />
<br />
To successfully unplug a pdb it must be put first in <b>MOUNTED</b> mode otherwise the following error is thrown:
<br />
<pre class="cpp" name="code">SQL@localhost> select name, open_mode from V$PDBS;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB001 READ WRITE
PDB002 READ WRITE
PDB003 READ WRITE
SQL@localhost> alter pluggable database PDB003 unplug into '/app/oracle/oradata/pdb003.xml';
alter pluggable database PDB003 unplug into '/app/oracle/oradata/pdb003.xml'
*
ERROR at line 1:
ORA-65025: Pluggable database PDB003 is not closed on all instances.
</pre>
So before proceeding with the unplug operation you have to close the pluggable database
<br />
<pre class="cpp" name="code">SQL@localhost> alter pluggable database pdb003 close immediate;
Pluggable database altered.
SQL@localhost> alter pluggable database PDB003 unplug into '/app/oracle/oradata/pdb003.xml';
Pluggable database altered.
</pre>
Even if the previous operation is not destructive, the container knows that a pluggable database was available, currently the database administrator no longer want to use it, you of course cannot open an unplugged database.
<br />
<pre class="cpp" name="code">SQL@localhost> select name, open_mode from V$PDBS;
NAME OPEN_MODE
------------- ----------
PDB$SEED READ ONLY
PDB001 READ WRITE
PDB002 READ WRITE
PDB003 MOUNTED
SQL@localhost> alter pluggable database pdb003 open;
alter pluggable database pdb003 open
*
ERROR at line 1:
ORA-65086: cannot open/close the pluggable database
</pre>
Where you can have information about the plugged or unplugged status of your pluggable databases ?<br />
Query the <b>CDB_PDBS</b> view: it displays information about the PDBs associated with the CDB, including the status of each PDB.
<br />
<pre class="cpp" name="code">SQL@localhost> select PDB_NAME, STATUS from CDB_PDBS where PDB_NAME = 'PDB003';
PDB_NAME STATUS
---------- -------------
PDB003 UNPLUGGED</pre>
To create a new pluggable database on vsi08devpom machine I have to copy the datafiles of the unplugged database to the target machine.
<br />
<pre class="cpp" name="code">[oracle@localhost PDB003]$ ll
total 921688
-rw-r-----. 1 oracle oinstall 5251072 Aug 1 14:37 PDB001_users01.dbf
-rw-r-----. 1 oracle oinstall 665853952 Aug 1 14:37 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 272637952 Aug 1 14:37 system01.dbf
-rw-r-----. 1 oracle oinstall 20979712 Aug 1 14:30 temp01.dbf
[oracle@localhost PDB003]$ scp -r ../PDB003 vsi08devpom.mydomain.it:/opt/app/oracle/oradata/CDBTEST/PDB003
oracle@vsi08devpom.mydomain.it's password:
temp01.dbf 100% 20MB 620.9KB/s 00:33
system01.dbf 100% 260MB 543.4KB/s 08:10
PDB001_users01.dbf 100% 5128KB 1.0MB/s 00:05
sysaux01.dbf 100% 635MB 545.1KB/s 19:53
[oracle@localhost PDB003]$ scp /app/oracle/oradata/pdb003.xml vsi08devpom.mydomain.it:/opt/app/oracle/oradata
oracle@vsi08devpom.mydomain.it's password:
pdb003.xml 100% 4003 3.9KB/s 00:00 </pre>
Log into the target machine.<br />
My current multitenant container CDBTEST located on vsi08devpom is formed by three pluggable databases:
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom CDBTEST]$ export ORACLE_SID=CDBTEST
[oracle@vsi08devpom CDBTEST]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Thu Aug 1 15:32:55 2013
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL@vsi08devpom> select name, open_mode from V$PDBS;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDBTEST1 READ WRITE
PDBTEST2 READ WRITE
PDBTEST3 READ WRITE
SQL@vsi08devpom> select pdb_name, status from CDB_PDBS;
PDB_NAME STATUS
---------- -------------
PDB$SEED NORMAL
PDBTEST1 NORMAL
PDBTEST2 NORMAL
PDBTEST3 NORMAL</pre>
Now it's time to plug into CDBTEST container on vsi08devpom machine the unplugged database coming from CDB container (running on my local machine).
The source location of the datafiles contained into the XML file is different from the target destination, so I cannot use just the following command, because the error "<b>ORA-27041: unable to open file</b>" is thrown as you can see.
<br />
<pre class="cpp" name="code">SQL@vsi08devpom> create pluggable database PDB003 using '/opt/app/oracle/oradata/pdb003.xml' nocopy tempfile reuse;
create pluggable database PDB003 using '/opt/app/oracle/oradata/pdb003.xml' nocopy tempfile reuse
*
ERROR at line 1:
ORA-19505: failed to identify file
"/app/oracle/oradata/CDB001/PDB003/system01.dbf"
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 9</pre>
I need to appropriately use the <b>SOURCE_FILE_NAME_CONVERT</b> clause in the command:
<br />
<pre class="cpp" name="code">SQL@vsi08devpom> create pluggable database PDB003 using '/opt/app/oracle/oradata/pdb003.xml' source_file_name_convert=('/app/oracle/oradata/CDB001','/opt/app/oracle/oradata/CDBTEST') nocopy tempfile reuse;
Pluggable database created.
</pre>
The new PDB003 pluggable database on vsi08devpom machine has the same DBID of that one...
<br />
<pre class="cpp" name="code">SQL@vsi08devpom> select pdb_name, status, DBID, CON_UID, GUID from CDB_PDBS;
PDB_NAME STATUS DBID CON_UID GUID
---------- ------------- ---------- ---------- --------------------------------
PDB$SEED NORMAL 4063610283 4063610283 E1B2A529DB382EACE0430100007F78B8
PDBTEST1 NORMAL 3064465721 3064465721 E1B436871D9E4110E0430100007F9BBC
PDBTEST2 NORMAL 2395404598 2395404598 E1B43A36FA0B41A9E0430100007F6671
PDBTEST3 NORMAL 2434165039 2434165039 E1B43D98C0DC41F6E0430100007F7CE7
PDB003 NEW 1448206714 1448206714 E2B9BE56B8B936CEE045000000000001
</pre>
... unplugged from my local machine
<br />
<pre class="cpp" name="code">SQL@localhost> select pdb_name, status, DBID, CON_UID, GUID from CDB_PDBS;
PDB_NAME STATUS DBID CON_UID GUID
---------- ------------- ---------- ---------- --------------------------------
PDB$SEED NORMAL 4063489868 4063489868 E19363E52C005C9AE045000000000001
PDB001 NORMAL 1701599811 1701599811 E1F26215682E1142E045000000000001
PDB002 NORMAL 1497027100 1497027100 E1F329ECE0F411E6E045000000000001
PDB003 UNPLUGGED 1448206714 1448206714 E2B9BE56B8B936CEE045000000000001</pre>
The new plugged database is in <b>MOUNTED</b> mode so I need to open it first:
<br />
<pre class="cpp" name="code">SQL@vsi08devpom> select name, open_mode from V$PDBS;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDBTEST1 READ WRITE
PDBTEST2 READ WRITE
PDBTEST3 READ WRITE
PDB003 MOUNTED
SQL@vsi08devpom> alter pluggable database PDB003 open;
Pluggable database altered.</pre>
My data is all there as expected!!!
<br />
<pre class="cpp" name="code">SQL@vsi08devpom> alter session set container=PDB003;
Session altered.
SQL@vsi08devpom> select count(*) from marcov.T1;
COUNT(*)
----------
100</pre>
<br />
That's all.Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com12tag:blogger.com,1999:blog-3005934468887687781.post-21865582518524869342013-07-30T13:05:00.001+01:002013-07-30T13:05:32.217+01:00How to create a pluggable database by cloning an existing local PDBUsing the <b>CREATE PLUGGABLE DATABASE ... FROM</b> command you can clone an existing pluggable database (the source pdb) to create a new pdb (the clone pdb).<br />
The source pdb could be in the current local container or it can be located in a remote container (in a next post): during a clone of a remote pdb you need to use a database link referencing the remote container in the <b>FROM</b> clause.<br />
<br />
Let's start cloning a local pluggable database.
Be sure the current container is the root
<br />
<pre class="cpp" name="code">SQL> show con_name;
CON_NAME
------------------------------
CDB$ROOT</pre>
Here are my current pluggable databases and I want to clone <b>PDB001</b> which contains the user <b>MARCOV</b> and the table <b>T1 </b>(with 100 rows)
<br />
<pre class="cpp" name="code">SQL> select name, open_mode from V$PDBS;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB001 READ WRITE
PDB002 READ WRITE
SQL> alter session set container=PDB001;
Session altered.
SQL> create user marcov identified by marcov quota unlimited on users;
User created.
SQL> grant create session to marcov;
Grant succeeded.
SQL> grant create table to marcov;
Grant succeeded.
SQL> connect marcov/marcov@PDB001
Connected.
SQL> show user
USER is "MARCOV"
SQL> show con_name
CON_NAME
------------------------------
PDB001
SQL> create table T1 (a number);
Table created.
SQL> create table T1 (a number);
Table created.
SQL> insert into T1 select level from dual connect by level < 101;
100 rows created.
SQL> commit;
Commit complete.
SQL> connect / as sysdba
Connected.
SQL> show user
USER is "SYS"
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT</pre>
Here is the content of my <b>tnsnames.ora</b> file
<br />
<pre class="cpp" name="code">CDB001 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.2.15)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = CDB001)
)
)
PDB001 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.2.15)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB001)
)
)</pre>
To clone the source pluggable database PDB001 I need to open it in <b>READ ONLY</b> mode
<br />
<pre class="cpp" name="code">SQL> select name, open_mode from v$pdbs;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB001 READ WRITE
PDB002 READ WRITE
SQL> alter pluggable database PDB001 open read only force;
Pluggable database altered.</pre>
On my file system I have the following directories and files.
<br />
<pre class="cpp" name="code">[oracle@localhost CDB001]$ pwd
/app/oracle/oradata/CDB001
[oracle@localhost CDB001]$ ll
total 2163224
-rw-r-----. 1 oracle oinstall 17973248 Jul 30 13:12 control01.ctl
drwxr-x---. 2 oracle oinstall 4096 Jul 20 15:29 PDB001
drwxr-x---. 2 oracle oinstall 4096 Jul 20 16:22 PDB002
drwxr-x---. 2 oracle oinstall 4096 Jul 15 22:07 pdbseed
-rw-r-----. 1 oracle oinstall 52429312 Jul 30 13:12 redo01.log
-rw-r-----. 1 oracle oinstall 52429312 Jul 29 22:06 redo02.log
-rw-r-----. 1 oracle oinstall 52429312 Jul 30 02:32 redo03.log
-rw-r-----. 1 oracle oinstall 817897472 Jul 30 13:11 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 817897472 Jul 30 13:06 system01.dbf
-rw-r-----. 1 oracle oinstall 76554240 Jul 30 13:11 temp01.dbf
-rw-r-----. 1 oracle oinstall 325066752 Jul 30 13:10 undotbs01.dbf
-rw-r-----. 1 oracle oinstall 5251072 Jul 30 02:37 users01.dbf</pre>
Here is the content of <b>PDB001</b> directory.
<br />
<pre class="cpp" name="code">[oracle@localhost CDB001]$ ll PDB001/
total 922516
-rw-r-----. 1 oracle oinstall 5251072 Jul 30 13:08 PDB001_users01.dbf
-rw-r-----. 1 oracle oinstall 665853952 Jul 30 13:08 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 272637952 Jul 30 13:08 system01.dbf
-rw-r-----. 1 oracle oinstall 20979712 Jul 21 17:51 temp01.dbf</pre>
I'm going to create a new pluggable database called <b>PDB003</b>, cloning <b>PDB001</b>. The command to clone a pluggable database locally is the following:
<br />
<pre class="cpp" name="code">SQL> create pluggable database PDB003 from PDB001 file_name_convert=('/app/oracle/oradata/CDB001/PDB001','/app/oracle/oradata/CDB001/PDB003');
Pluggable database created.</pre>
New files and directories are created. Note also the same name of the datafile <b>PDB001_users01.dbf</b> used as default tablespace for <b>PDB003</b>.
<br />
<pre class="cpp" name="code">[oracle@localhost CDB001]$ ll
total 2163228
-rw-r-----. 1 oracle oinstall 17973248 Jul 30 13:19 control01.ctl
drwxr-x---. 2 oracle oinstall 4096 Jul 20 15:29 PDB001
drwxr-x---. 2 oracle oinstall 4096 Jul 20 16:22 PDB002
drwxr-x---. 2 oracle oinstall 4096 Jul 30 13:17 PDB003
drwxr-x---. 2 oracle oinstall 4096 Jul 15 22:07 pdbseed
-rw-r-----. 1 oracle oinstall 52429312 Jul 30 13:18 redo01.log
-rw-r-----. 1 oracle oinstall 52429312 Jul 29 22:06 redo02.log
-rw-r-----. 1 oracle oinstall 52429312 Jul 30 02:32 redo03.log
-rw-r-----. 1 oracle oinstall 817897472 Jul 30 13:18 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 817897472 Jul 30 13:17 system01.dbf
-rw-r-----. 1 oracle oinstall 76554240 Jul 30 13:18 temp01.dbf
-rw-r-----. 1 oracle oinstall 325066752 Jul 30 13:16 undotbs01.dbf
-rw-r-----. 1 oracle oinstall 5251072 Jul 30 02:37 users01.dbf
[oracle@localhost CDB001]$ ll PDB003
total 921688
-rw-r-----. 1 oracle oinstall 5251072 Jul 30 13:18 PDB001_users01.dbf
-rw-r-----. 1 oracle oinstall 665853952 Jul 30 13:18 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 272637952 Jul 30 13:18 system01.dbf
-rw-r-----. 1 oracle oinstall 20979712 Jul 30 13:17 temp01.dbf</pre>
After the command is sucessfully completed the status and the open mode of the new pluggable database are <b>NEW</b> and <b>MOUNTED</b>.
<br />
<pre class="cpp" name="code">SQL> select PDB_NAME, STATUS from CDB_PDBS;
PDB_NAME STATUS
---------- -------------
PDB$SEED NORMAL
PDB001 NORMAL
PDB002 NORMAL
PDB003 NEW
SQL> select name, open_mode from V$PDBS;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB001 READ ONLY
PDB002 READ WRITE
PDB003 MOUNTED</pre>
A new service is created too.
<br />
<pre class="cpp" name="code">SQL> select name, pdb from V$SERVICES order by creation_date;
NAME PDB
-------------------- ------------------------------
CDB001XDB CDB$ROOT
SYS$BACKGROUND CDB$ROOT
CDB001 CDB$ROOT
SYS$USERS CDB$ROOT
pdb001 PDB001
pdb002 PDB002
pdb003 PDB003</pre>
You can now open both pluggable databases with one simply command (have a look at <a href="http://dbaworkshop.blogspot.it/2013/07/How-to-change-the-open-mode-of-all-pluggable-databases.html" target="_blank">this post</a> for more information about the syntax and examples)
<br />
<pre class="cpp" name="code">SQL> alter pluggable database PDB001,PDB003 open READ WRITE FORCE;
Pluggable database altered.
SQL> select name, open_mode from V$PDBS;
NAME OPEN_MODE
-------------------- ----------
PDB$SEED READ ONLY
PDB001 READ WRITE
PDB002 READ WRITE
PDB003 READ WRITE
SQL> select PDB_NAME, STATUS from CDB_PDBS;
PDB_NAME STATUS
---------- -------------
PDB$SEED NORMAL
PDB001 NORMAL
PDB002 NORMAL
PDB003 NORMAL</pre>
Add the following entry on the tnsnames.ora file.
<br />
<pre class="cpp" name="code">PDB003 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.2.15)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB003)
)
)</pre>
Let's see my data on <b>PDB003</b> and on <b>PDB001</b>
<br />
<pre class="cpp" name="code">SQL> connect marcov/marcov@PDB003
Connected.
SQL> show con_name
CON_NAME
------------------------------
PDB003
SQL> select count(*) from marcov.T1;
COUNT(*)
----------
100
SQL> connect marcov/marcov@PDB001
Connected.
SQL> show con_name
CON_NAME
------------------------------
PDB001
SQL> select count(*) from marcov.T1;
COUNT(*)
----------
100</pre>
It is not possible to create a new pdb cloning a local or a remote <b>seed</b>: to create a new pdb from the seed you have to follow <a href="http://dbaworkshop.blogspot.it/2013/07/How-to-create-a-pluggable-database-PDB-in-a-multitenant-container-database-CDB-using-the-files-of-the-seed.html" target="_blank">this post</a>.
If you try to clone from the seed template you will receive the <b>ORA-65000</b> error, described below:
<br />
<pre class="cpp" name="code">SQL> create pluggable database PDB004 from PDB$SEED file_name_convert=('/app/oracle/oradata/CDB001/pdbseed','/app/oracle/oradata/CDB001/PDB004');
create pluggable database PDB004 from PDB$SEED file_name_convert=('/app/oracle/oradata/CDB001/pdbseed','/app/oracle/oradata/CDB001/PDB004')
*
ERROR at line 1:
ORA-65000: missing or invalid pluggable database name
[oracle@localhost pdbseed]$ oerr ora 65000
65000, 00000, "missing or invalid pluggable database name"
// *Cause: A valid pluggable database name was not present where required
// by the syntax of a CREATE PLUGGABLE DATABASE, ALTER PLUGGABLE
// DATABASE or DROP PLUGGABLE DATABASE statement.
// *Action: Reissue the statement with a valid pluggable database name.</pre>
<br />
That's all.
Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com140tag:blogger.com,1999:blog-3005934468887687781.post-25856015814895198722013-07-30T10:47:00.000+01:002013-07-30T10:47:49.973+01:00How to change the open mode of all pluggable databasesWhen you need to modify the open mode of all your PDBs at the same time (look at <a href="http://dbaworkshop.blogspot.it/2013/07/How-to-change-the-open-mode-of-listed-PDBs.htm" target="_blank">this post</a> if you want to change the open mode of only a specific pluggable database) you can use <b>ALTER PLUGGABLE DATABASE</b> command and the <b>ALL</b> option.<br />
As usual you have to ensure that the current container is the root.
<br />
<pre class="cpp" name="code">SQL> SELECT SYS_CONTEXT ('USERENV', 'CON_NAME') FROM DUAL;
SYS_CONTEXT('USERENV','CON_NAME')
--------------------------------------------------------------------------------
CDB$ROOT</pre>
The following statement for example changes the open mode of all your pluggable databases at the same time.
<br />
<pre class="cpp" name="code">SQL>ALTER PLUGGABLE DATABASE ALL CLOSE IMMEDIATE;
Pluggable database altered.
SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
NAME OPEN_MODE CON_ID
------------------------------ ---------- ----------
PDB$SEED READ ONLY 2
PDB001 MOUNTED 3
PDB002 MOUNTED 4</pre>
When you need to change the open mode of all pluggable database except for listed ones you can include also the <b>EXCEPT</b> option as in the following example:
<br />
<pre class="cpp" name="code">SQL> ALTER PLUGGABLE DATABASE ALL EXCEPT PDB001 OPEN READ WRITE;
Pluggable database altered.
SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
NAME OPEN_MODE CON_ID
------------------------------ ---------- ----------
PDB$SEED READ ONLY 2
PDB001 MOUNTED 3
PDB002 READ WRITE 4</pre>
To open all my pluggable databases I can simply execute the following command. It doesn't take care that PDB002 is already open in <b>READ WRITE</b> mode:
any error is returned because the pluggable databases are in different open mode.
<br />
<pre class="cpp" name="code">SQL> ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE;
Pluggable database altered.
SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
NAME OPEN_MODE CON_ID
------------------------------ ---------- ----------
PDB$SEED READ ONLY 2
PDB001 READ WRITE 3
PDB002 READ WRITE 4</pre>
However, if any of your pluggable databases are in <b>READ ONLY</b> mode, then the statement returns the error "<b>ORA-65019: pluggable database PDB001 already open</b>" as you can see:
<br />
<pre class="cpp" name="code">SQL> ALTER PLUGGABLE DATABASE ALL CLOSE IMMEDIATE;
Pluggable database altered.
SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
NAME OPEN_MODE CON_ID
------------------------------ ---------- ----------
PDB$SEED READ ONLY 2
PDB001 MOUNTED 3
PDB002 MOUNTED 4
SQL> ALTER PLUGGABLE DATABASE PDB001 OPEN READ ONLY;
Pluggable database altered.
SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
NAME OPEN_MODE CON_ID
------------------------------ ---------- ----------
PDB$SEED READ ONLY 2
PDB001 READ ONLY 3
PDB002 MOUNTED 4
SQL> ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE;
ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE
*
ERROR at line 1:
ORA-65019: pluggable database PDB001 already open</pre>
Even if the statement fails for pluggable database PDB001 it was able to open PDB002 as requested:
<br />
<pre class="cpp" name="code">SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
NAME OPEN_MODE CON_ID
------------------------------ ---------- ----------
PDB$SEED READ ONLY 2
PDB001 READ ONLY 3
PDB002 READ WRITE 4</pre>
To avoid the error ORA-65019 you can include the <b>FORCE</b> option in your command:
<br />
<pre class="cpp" name="code">SQL> ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE FORCE;
Pluggable database altered.
SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
NAME OPEN_MODE CON_ID
------------------------------ ---------- ----------
PDB$SEED READ ONLY 2
PDB001 READ WRITE 3
PDB002 READ WRITE 4</pre>
To shutdown all your pluggable databases except one you can use the following command:
<br />
<pre class="cpp" name="code">SQL> alter pluggable database all except PDB002 close immediate;
Pluggable database altered.
SQL> select name, open_mode from V$PDBS;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB001 MOUNTED
PDB002 READ WRITE</pre>
To list some of your pluggable databases you can use the comma as in the following example where I need to open all my pluggable databases (PDB001 and PDB002) except those listed (just PDB001 and PDB002!!). Nothing happens of course.
<br />
<pre class="cpp" name="code">SQL> alter pluggable database all except PDB002,PDB001 open;
Pluggable database altered.
SQL> select name, open_mode from V$PDBS;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB001 MOUNTED
PDB002 READ WRITE</pre>
That's all.Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com127tag:blogger.com,1999:blog-3005934468887687781.post-59923766708984357362013-07-29T10:59:00.000+01:002013-07-29T10:59:03.364+01:00Pluggable database: limitations of the open mode of the CDB imposed on the open mode of PDBsThe open mode of the container database imposes limitations on the open mode of PDBs.<br />
For
example, the root must be open before any PDBs can be open. Therefore, you
might need to change the open mode of the root before changing the open mode of
a PDB. Let's start.<br />
<br />
Verify you are connected to the root container.
<br />
<pre class="cpp" name="code">SQL> SELECT SYS_CONTEXT ('USERENV', 'CON_NAME') FROM DUAL;
SYS_CONTEXT('USERENV','CON_NAME')
--------------------------------------------------------------------------------
CDB$ROOT</pre>
Verify the open mode from the <b>V$DATABASE</b> view.
<br />
<pre class="cpp" name="code">SQL> select name, con_id, open_mode from v$database;
NAME CON_ID OPEN_MODE
--------- ---------- --------------------
CDB001 0 READ WRITE</pre>
I've two pluggable databases in the current container: I want to close the pluggable database called PDB001.
<br />
<pre class="cpp" name="code">SQL> alter pluggable database PDB001 close immediate;
Pluggable database altered.</pre>
Verify the open mode from the <b>V$PDBS</b> view.<br />
One of my pluggable databases (PDB002) is available in <b>READ WRITE</b> mode, the second (PDB001) is in <b>MOUNTED</b> mode. The seed (PDB$SEED) is a template that you can use to create new PDBs and is always in <b>READ ONLY</b> mode.
<br />
<pre class="cpp" name="code">SQL> select name, con_id, open_mode from v$pdbs;
NAME CON_ID OPEN_MODE
------------------------------ ---------- ----------
PDB$SEED 2 READ ONLY
PDB001 3 MOUNTED
PDB002 4 READ WRITE</pre>
What does it happen to pluggable databases when you shutdown the root container and open it again in <b>MOUNT</b> mode ?
<br />
<pre class="cpp" name="code">SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 626327552 bytes
Fixed Size 2291472 bytes
Variable Size 473958640 bytes
Database Buffers 146800640 bytes
Redo Buffers 3276800 bytes
Database mounted.</pre>
The root container is in <b>MOUNTED</b> mode as expected.
<br />
<pre class="cpp" name="code">SQL> select name, con_id, open_mode from v$database;
NAME CON_ID OPEN_MODE
--------- ---------- --------------------
CDB001 0 MOUNTED
SQL> SELECT SYS_CONTEXT ('USERENV', 'CON_NAME') FROM DUAL;
SYS_CONTEXT('USERENV','CON_NAME')
--------------------------------------------------------------------------------
CDB$ROOT</pre>
The three pluggable databases are all in MOUNTED mode too.<br />
<pre class="cpp" name="code">SQL> select name, con_id, open_mode from v$pdbs;
NAME CON_ID OPEN_MODE
------------------------------ ---------- ----------
PDB$SEED 2 MOUNTED
PDB001 3 MOUNTED
PDB002 4 MOUNTED</pre>
You cannot open a pluggable database if the container is not open.
<br />
<pre class="cpp" name="code">SQL> alter pluggable database PDB001 open read write;
alter pluggable database PDB001 open read write
*
ERROR at line 1:
ORA-01109: database not open</pre>
Open first the CDB instance containing the root, the seed and its pluggable databases.
<br />
<pre class="cpp" name="code">SQL> alter database open;
Database altered.
SQL> select name, con_id, open_mode from v$database;
NAME CON_ID OPEN_MODE
--------- ---------- --------------------
CDB001 0 READ WRITE</pre>
The seed database is now put in <b>READ ONLY</b> mode; the other two pluggable databases are still in <b>MOUNTED</b> mode.
So they don't start automatically and you have to take care of this.<br />
<pre class="cpp" name="code">SQL> select name, con_id, open_mode from v$pdbs;
NAME CON_ID OPEN_MODE
------------------------------ ---------- ----------
PDB$SEED 2 READ ONLY
PDB001 3 MOUNTED
PDB002 4 MOUNTED</pre>
You can now open pluggable databases as you want. I'm going to open a pluggable database, PDB001, in <b>READ ONLY</b> mode and then PDB002 in <b>READ WRITE</b> mode.
<br />
<pre class="cpp" name="code">SQL> alter pluggable database pdb001 open read only;
Pluggable database altered.
SQL> alter pluggable database pdb002 open;
Pluggable database altered.
SQL> select name, con_id, open_mode from v$pdbs;
NAME CON_ID OPEN_MODE
------------------------------ ---------- ----------
PDB$SEED 2 READ ONLY
PDB001 3 READ ONLY
PDB002 4 READ WRITE</pre>
As you can see I didn't specify to open the pluggable database PDB002 in <b>READ WRITE</b> mode: as usual when you don't specify a valid option the
<b>READ WRITE</b> is the default mode.<br />
<br />
To open also the PDB001 pluggable database in <b>READ WRITE</b> mode you can use the following command and the <b>FORCE</b> option.
<br />
<pre class="cpp" name="code">SQL> alter pluggable database PDB001 open read write force;
Pluggable database altered.
SQL> select name, con_id, open_mode from v$pdbs;
NAME CON_ID OPEN_MODE
------------------------------ ---------- ----------
PDB$SEED 2 READ ONLY
PDB001 3 READ WRITE
PDB002 4 READ WRITE</pre>
<br />
That's all.Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com11tag:blogger.com,1999:blog-3005934468887687781.post-19707210767024683672013-07-28T14:27:00.000+01:002013-07-28T14:27:05.751+01:00How to change the open mode of listed PDBsThe clauses of the <b>ALTER PLUGGABLE DATABASE</b> statement that modify the mode of a PDB are:<br />
- <b>OPEN READ WRITE [RESTRICTED] [FORCE]</b>: it opens the PDB in read/write mode;<br />
- <b>OPEN READ ONLY [RESTRICTED] [FORCE]</b>: it opens the PDB in read-only mode;<br />
- <b>OPEN UPGRADE [RESTRICTED]</b>: it opens the PDB in migrate mode;<br />
- <b>CLOSE [IMMEDIATE]</b>: it places the PDB in mounted mode and it is the PDB equivalent of the SQL*Plus
SHUTDOWN command;<br />
<br />
When using the <b>RESTRICTED</b> option, only users with RESTRICTED SESSION privilege can log into the PDB: all
other sessions connected to the PDB without RESTRICTED SESSION privilege are terminated and their transactions
rolled back.<br />
When <b>FORCE</b> is specified, the statement opens a PDB that is currently closed and changes the open mode as specified.<br />
<br />
To modify the open mode of one or more PDBs you have to ensure that the current container is the root:
<br />
<pre class="cpp" name="code">SQL> SELECT SYS_CONTEXT ('USERENV', 'CON_NAME') FROM DUAL;
SYS_CONTEXT('USERENV','CON_NAME')
--------------------------------------------------------------------------------
CDB$ROOT</pre>
Let's get information about current pluggable databases querying the <b>V$PDBS</b> view:
<br />
<pre class="cpp" name="code">SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
NAME OPEN_MODE CON_ID
------------------------------ ---------- ----------
PDB$SEED READ ONLY 2
PDB001 READ WRITE 3
PDB002 READ WRITE 4</pre>
I want to "shutdown" the pluggable database identified as PDB001: all current connected sessions will be terminated and their transaction rolled back.<br />
You need to use the alter pluggable database command:
<br />
<pre class="cpp" name="code">SQL> alter pluggable database pdb001 close immediate;
Pluggable database altered.</pre>
The specified pluggable database is put in <b>MOUNTED</b> mode:
<br />
<pre class="cpp" name="code">SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
NAME OPEN_MODE CON_ID
------------------------------ ---------- ----------
PDB$SEED READ ONLY 2
PDB001 MOUNTED 3
PDB002 READ WRITE 4</pre>
If you want to open the pluggable database PDB001 in <b>READ ONLY</b> mode you can use again the <b>alter pluggable database</b> command:
<br />
<pre class="cpp" name="code">SQL> alter pluggable database pdb001 open read only;
Pluggable database altered.</pre>
It's now open in READ ONLY mode.
<br />
<pre class="cpp" name="code">SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
NAME OPEN_MODE CON_ID
------------------------------ ---------- ----------
PDB$SEED READ ONLY 2
PDB001 READ ONLY 3
PDB002 READ WRITE 4</pre>
What does it happen when you try to open it in <b>READ WRITE</b> mode ?
<br />
<pre class="cpp" name="code">SQL> alter pluggable database pdb001 open read write;
alter pluggable database pdb001 open read write
*
ERROR at line 1:
ORA-65019: pluggable database PDB001 already open</pre>
Oracle throws the following exception:
<br />
<pre class="cpp" name="code">[oracle@localhost trace]$ oerr ora 65019
65019, 00000, "pluggable database %s already open"
// *Cause: An attempt was made to open a pluggable database that was already
// opened.
// *Action: Check V$PLUGGABLE_DATABASE.STATE.</pre>
If you want to open in <b>READ WRITE</b> mode your pluggable database, currently in <b>READ ONLY</b> mode, you have to add the <b>FORCE</b> option to the previous command:
<br />
<pre class="cpp" name="code">SQL> alter pluggable database pdb001 open read write force;
Pluggable database altered.</pre>
The pluggable database is now open in <b>READ WRITE</b> mode again:
<br />
<pre class="cpp" name="code">SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
NAME OPEN_MODE CON_ID
------------------------------ ---------- ----------
PDB$SEED READ ONLY 2
PDB001 READ WRITE 3
PDB002 READ WRITE 4</pre>
<br />
In the next post I will decribe the limitations of the open mode of the root imposed on the open mode of PDBs.<br />
<br />
That's all.Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com12tag:blogger.com,1999:blog-3005934468887687781.post-72734467393461121482013-07-21T19:32:00.000+01:002013-07-21T19:33:38.364+01:00How to create a pluggable database PDB in a multitenant container database CDB using the files of the seed PDB$SEEDThe new architecture provided by Oracle Database 12c enables an Oracle database to function as a multitenant container database (CDB):<br />
it can include zero, one, or many pluggable databases (PDBs), that is a portable collection of schemas, schema objects and nonschema objects.<br />
<br />
A multitenant container database (CDB) is formed by the following components:<br />
- <b>the root container</b> (and exactly one root) named <b>CDB$ROOT</b> that stores Oracle-supplied metadata and common users (a database user known in every container);<br />
- <b>the seed template</b> (and exactly one seed) named <b>PDB$SEED</b> used, if you want, to create new PDBs. It's not possible to add objects to or modify objects in the seed: it works only in READ ONLY mode;<br />
- <b>pluggable databases</b> (zero, one, or many PDBs) named as you prefer that are your "old idea of databases" before Oracle Database 12c. A pluggable database contains the data and code required by your software application and is fully backward compatible with Oracle Database releases before Oracle Database 12c.<br />
<br />
The options for creating a pluggable database (the so called PDB) fall into two main categories: <b>copying</b> and <b>plugging in</b> as you will see in this post and in the next posts.<br />
<br />
Talking about copying, you have two options to copy a pluggable database:<br />
<ul>
<li>create a pluggable database (PDB) in a multitenant container database (CDB) using the files of the seed (PDB$SEED);</li>
<li>create it by cloning a source PDB and plugging the clone into the CDB (bear in mind that the source PDB can be in the local CDB or in a remote CDB). </li>
</ul>
<br />
Today I'm going to describe how to copy a pluggable database using the files of the seed from the SQL*Plus command line.<br />
<br />
If you want to see how to create a pluggable database copying the files of the seed using DBCA you can simply watch the following <a href="https://www.youtube.com/watch?v=POUt3gj3Tm0" target="_blank">video</a> (I will create a post about it using screenshot as soon as possible).<br />
<br />
To create a new pluggable database copying the files of the seed you have to ensure that the current container is the root:
<br />
<pre class="cpp" name="code">SQL> SELECT SYS_CONTEXT ('USERENV', 'CON_NAME') FROM DUAL;
SYS_CONTEXT('USERENV','CON_NAME')
--------------------------------------------------------------------------------
CDB$ROOT</pre>
and your multitenant container database CDB must be also in read/write mode. My CDB is called CDB001:
<br />
<pre class="cpp" name="code">SQL> select NAME, CDB, CON_ID, OPEN_MODE from V$DATABASE;
NAME CDB CON_ID OPEN_MODE
--------- --- ---------- --------------------
CDB001 YES 0 READ WRITE</pre>
Your script must include the <b>CREATE PLUGGABLE DATABASE</b> statement and eventually some other clauses, such as the following I used in my script:<br />
- <b>STORAGE</b>: specify the limit of the amount of storage the PDB can use. Omitting this clause is equivalent to specify an unlimited amount;<br />
- <b>DEFAULT TABLESPACE</b>: specify a default permanent tablespace for non-SYSTEM users. When you omit this clause the SYSTEM tablespace will be used as default permanent tablespace for non-SYSTEM users and this is not recommended;<br />
- <b>FILE_NAME_CONVERT</b>: specify the target locations of the data files whereas the source files are those associated with the seed. This parameter is required when Oracle Managed Files is not enabled and the PDB_FILE_NAME_CONVERT initialization parameter is not set<br />
- other clauses you can use are: <b>ROLES, TEMPFILE REUSE </b>and<b> PATH_PREFIX</b>.
<br />
<pre class="cpp" name="code">SQL> CREATE PLUGGABLE DATABASE PDB002
2 ADMIN USER PDB002_ADMIN IDENTIFIED BY oracle
3 storage (maxsize 5G MAX_SHARED_TEMP_SIZE 500M)
4 DEFAULT TABLESPACE "USERS" DATAFILE '/app/oracle/oradata/CDB001/PDB002/PDB002_users01.dbf' SIZE 5M REUSE AUTOEXTEND ON
5 file_name_convert=('/app/oracle/oradata/CDB001/pdbseed/system01.dbf','/app/oracle/oradata/CDB001/PDB002/system01.dbf','/app/oracle/oradata/CDB001/pdbseed/sysaux01.dbf','/app/oracle/oradata/CDB001/PDB002/sysaux01.dbf','/app/oracle/oradata/CDB001/pdbseed/temp01.dbf','/app/oracle/oradata/CDB001/PDB002/temp01.dbf');
Pluggable database created.</pre>
From the alert log (vi /app/oracle/diag/rdbms/cdb001/CDB001/trace/alert_CDB001.log):
<br />
<pre class="cpp" name="code">Sat Jul 20 16:21:48 2013
CREATE PLUGGABLE DATABASE PDB002 ADMIN USER PDB002_ADMIN IDENTIFIED BY * storage (maxsize 5G MAX_SHARED_TEMP_SIZE 500M) DEFAULT TABLESPACE "USERS" DATAFILE '/app/oracle/oradata/CDB001/PDB002/PDB002_users01.dbf' SIZE 5M REUSE AUTOEXTEND ON file_name_convert=('/app/oracle/oradata/CDB001/pdbseed/system01.dbf','/app/oracle/oradata/CDB001/PDB002/system01.dbf','/app/oracle/oradata/CDB001/pdbseed/sysaux01.dbf','/app/oracle/oradata/CDB001/PDB002/sysaux01.dbf','/app/oracle/oradata/CDB001/pdbseed/temp01.dbf','/app/oracle/oradata/CDB001/PDB002/temp01.dbf')
Sat Jul 20 16:22:35 2013
****************************************************************
Pluggable Database PDB002 with pdb id - 4 is created as UNUSABLE.
If any errors are encountered before the pdb is marked as NEW,
then the pdb must be dropped
****************************************************************
Deleting old file#2 from file$
Deleting old file#4 from file$
Adding new file#10 to file$(old file#2)
Adding new file#11 to file$(old file#4)
Successfully created internal service pdb002 at open
CREATE TABLESPACE USERS DATAFILE '/app/oracle/oradata/CDB001/PDB002/PDB002_users01.dbf' SIZE 5M REUSE AUTOEXTEND ON SEGMENT SPACE MANAGEMENT AUTO
Completed: CREATE TABLESPACE USERS DATAFILE '/app/oracle/oradata/CDB001/PDB002/PDB002_users01.dbf' SIZE 5M REUSE AUTOEXTEND ON SEGMENT SPACE MANAGEMENT AUTO
Sat Jul 20 16:22:49 2013
ALTER SYSTEM: Flushing buffer cache inst=0 container=4 local
****************************************************************
Post plug operations are now complete.
Pluggable database PDB002 with pdb id - 4 is now marked as NEW.
****************************************************************
Completed: CREATE PLUGGABLE DATABASE PDB002 ADMIN USER PDB002_ADMIN IDENTIFIED BY * storage (maxsize 5G MAX_SHARED_TEMP_SIZE 500M) DEFAULT TABLESPACE "USERS" DATAFILE '/app/oracle/oradata/CDB001/PDB002/PDB002_users01.dbf' SIZE 5M REUSE AUTOEXTEND ON file_name_convert=('/app/oracle/oradata/CDB001/pdbseed/system01.dbf','/app/oracle/oradata/CDB001/PDB002/system01.dbf','/app/oracle/oradata/CDB001/pdbseed/sysaux01.dbf','/app/oracle/oradata/CDB001/PDB002/sysaux01.dbf','/app/oracle/oradata/CDB001/pdbseed/temp01.dbf','/app/oracle/oradata/CDB001/PDB002/temp01.dbf')</pre>
As you can see when you create a pluggable database from the SQL*Plus command line it is open in <b>MOUNTED</b> mode. This is a different behaviour compared with the same operation performed by DBCA: in the final step DBCA is able to open the new pluggable database in <b>READ WRITE</b> mode.
<br />
<pre class="cpp" name="code">SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
NAME OPEN_MODE CON_ID
------------------------------ ---------- ----------
PDB$SEED READ ONLY 2
PDB001 READ WRITE 3
PDB002 MOUNTED 4</pre>
To open your new pluggable database in <b>READ WRITE</b> mode execute the following <b>alter pluggable database</b> command:
<br />
<pre class="cpp" name="code">SQL> alter pluggable database pdb002 open read write;
Pluggable database altered.</pre>
Now query again the <b>V$PDBS</b> view: your pluggable database is now available to the application.
<br />
<pre class="cpp" name="code">SQL> select NAME, OPEN_MODE, CON_ID from V$PDBS;
NAME OPEN_MODE CON_ID
------------------------------ ---------- ----------
PDB$SEED READ ONLY 2
PDB001 READ WRITE 3
PDB002 READ WRITE 4</pre>
That's all.
Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com24tag:blogger.com,1999:blog-3005934468887687781.post-68416035687122872932013-07-17T14:04:00.001+01:002013-07-17T14:04:17.427+01:00Installing Oracle Database 12c as Container Database with three Pluggable DatabasesHere is a video recorded during the creation of the first database. Go on if you want to see all the screenshots.<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/ZdhTnArFhwM?feature=player_embedded' frameborder='0'></iframe></div>
<br />
So we have already installed the software of the Oracle Database 12c release 1 (<a href="http://dbaworkshop.blogspot.it/2013/07/Software-only-installation-of-Oracle-Database-12c-release-1.html" target="_blank">have a look at this post</a>) and now we want to create a database using dbca.<br />
So let's run dbca from the oracle user.<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ dbca &</pre>
<br />
<br />
Select the operation you want to perform using dbca. Because I've already created an Oracle Database all the options are available. Anyway I want to create another database so I'm going to select Create Database.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-UZv0pM2M2m0/UeaLITi_jrI/AAAAAAAACts/9Z1areiovMs/s1600/dbca_12c_01.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="459" src="http://1.bp.blogspot.com/-UZv0pM2M2m0/UeaLITi_jrI/AAAAAAAACts/9Z1areiovMs/s640/dbca_12c_01.png" width="640" /></a></div>
During the Creation Mode screen you have two options:<br />
1. you can create a database with default configuration. It's possible to create it as Container Database and create also one Pluggable Database.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-hAzdZW83yMo/UeaLIb9gyOI/AAAAAAAACtk/STgtTfsrxTo/s1600/dbca_12c_02a.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://4.bp.blogspot.com/-hAzdZW83yMo/UeaLIb9gyOI/AAAAAAAACtk/STgtTfsrxTo/s640/dbca_12c_02a.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-BC_GPKuLe1w/UeaLJODjyMI/AAAAAAAACuY/EiJOBO-OOb4/s1600/dbca_12c_03a.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://1.bp.blogspot.com/-BC_GPKuLe1w/UeaLJODjyMI/AAAAAAAACuY/EiJOBO-OOb4/s640/dbca_12c_03a.png" width="640" /></a></div>
<a href="http://4.bp.blogspot.com/-hACAsem1lQg/UeaLJZRsmkI/AAAAAAAACt8/RtPZcE47bfQ/s1600/dbca_12c_03b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"></a><a href="http://2.bp.blogspot.com/-a5uhyJjuvT0/UeaLJk7wa4I/AAAAAAAACuA/R-75IqEM6VQ/s1600/dbca_12c_04a.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://2.bp.blogspot.com/-a5uhyJjuvT0/UeaLJk7wa4I/AAAAAAAACuA/R-75IqEM6VQ/s640/dbca_12c_04a.png" width="640" /></a> <br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
I'm not going to click the finish button right now. I want to use the second option to create a database.<br />
<br />
2.
So choose Advanced Mode in which you configure your own database
structure. This option enables you to perform more complex
installations, such as creating individual passwords for different
accounts, creating specific types of starter databases (for example, for
transaction processing or data warehouse systems), using different
language groups, specifying email notifications, and so on.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-c5PcXW4t17o/UeaLIhDbpuI/AAAAAAAACto/gjtYja64Tg0/s1600/dbca_12c_02b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://1.bp.blogspot.com/-c5PcXW4t17o/UeaLIhDbpuI/AAAAAAAACto/gjtYja64Tg0/s640/dbca_12c_02b.png" width="640" /></a></div>
<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-hACAsem1lQg/UeaLJZRsmkI/AAAAAAAACt8/RtPZcE47bfQ/s1600/dbca_12c_03b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="457" src="http://4.bp.blogspot.com/-hACAsem1lQg/UeaLJZRsmkI/AAAAAAAACt8/RtPZcE47bfQ/s640/dbca_12c_03b.png" width="640" /></a></div>
<br />
During the Advanced Mode screens you can choose to create the database as Container Database.<br />
Select
the Create as Container database option to create the database as a
multitenant container database (CDB) that can support one pluggable
database (PDB). If you want Oracle Universal Installer to create a PDB
when it creates the CDB, specify the PDB name in the Pluggable Database
Name field. The PDB name must be unique. If you need to create more than
one PDB you have to provide a PDB Name Prefix.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-pYxPhcsGI3g/UeaLKIbpgaI/AAAAAAAACuM/7AIMJMKyB_U/s1600/dbca_12c_04b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://1.bp.blogspot.com/-pYxPhcsGI3g/UeaLKIbpgaI/AAAAAAAACuM/7AIMJMKyB_U/s640/dbca_12c_04b.png" width="640" /></a></div>
<br />
The
next Advanced Mode screen asks you how you want to manage your database:
configuring the EM Database Express or registering it with EM Cloud
Control.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-6Z-jod5czGA/UeaLKQDTikI/AAAAAAAACuQ/HvAJd6wWtdU/s1600/dbca_12c_05b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://3.bp.blogspot.com/-6Z-jod5czGA/UeaLKQDTikI/AAAAAAAACuQ/HvAJd6wWtdU/s640/dbca_12c_05b.png" width="640" /></a></div>
<br />
<br />
The next screen asks you to specify passwords for SYS, SYSTEM and PDBADMIN or use the same password for all accounts.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-g1lZq9UeZ3w/UeaLK6GzTAI/AAAAAAAACu4/PBgxX4DJFTQ/s1600/dbca_12c_06b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://4.bp.blogspot.com/-g1lZq9UeZ3w/UeaLK6GzTAI/AAAAAAAACu4/PBgxX4DJFTQ/s640/dbca_12c_06b.png" width="640" /></a></div>
<br />
<br />
The next screen asks you to select a listener or create a new one.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-OpLwI8cahL8/UeaLLAIkX9I/AAAAAAAACug/25z52hh9CEk/s1600/dbca_12c_07b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://4.bp.blogspot.com/-OpLwI8cahL8/UeaLLAIkX9I/AAAAAAAACug/25z52hh9CEk/s640/dbca_12c_07b.png" width="640" /></a></div>
<br />
The
next screen asks you to specify the storage locations for database
files (storage type: File System or Automatic Storage Management) and
for recovery related files (you can specify a Fast Recovery Area and
enable archiving)<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-djiiDN7o4hE/UeaLLas2FqI/AAAAAAAACuo/IEMvqvqokN4/s1600/dbca_12c_08b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://2.bp.blogspot.com/-djiiDN7o4hE/UeaLLas2FqI/AAAAAAAACuo/IEMvqvqokN4/s640/dbca_12c_08b.png" width="640" /></a></div>
<br />
<br />
The next screen shows you the several database components you are going to configure like Oracle Database Vault or Label Security.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-J7pqKWt4L4U/UeaLLkWIFgI/AAAAAAAACuw/2k4H0MqoqrQ/s1600/dbca_12c_09b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://2.bp.blogspot.com/-J7pqKWt4L4U/UeaLLkWIFgI/AAAAAAAACuw/2k4H0MqoqrQ/s640/dbca_12c_09b.png" width="640" /></a></div>
The next screen asks you to configure Database Vault and Label Security (I didn't select them during this installation).<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-folTm3TGBS8/UeaLMC6sPJI/AAAAAAAACvY/sM3ClvHSiU0/s1600/dbca_12c_10b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://1.bp.blogspot.com/-folTm3TGBS8/UeaLMC6sPJI/AAAAAAAACvY/sM3ClvHSiU0/s640/dbca_12c_10b.png" width="640" /></a></div>
<br />
<br />
The
next screen let you specify settings about memory, default database
block size and the maximum number of operating system user processes
simultaneously connected to the database, character sets and the
connection mode (dedicated server mode or shared server mode).Select the
Enable Automatic Memory Management option to allow the database to
automatically distribute memory between SGA and PGA. If you do not
select this option, then the SGA and PGA must be sized manually.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-es4ShOJgSBU/UeaLMXHxpmI/AAAAAAAACvA/3CYp_4YSIdY/s1600/dbca_12c_11b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://2.bp.blogspot.com/-es4ShOJgSBU/UeaLMXHxpmI/AAAAAAAACvA/3CYp_4YSIdY/s640/dbca_12c_11b.png" width="640" /></a></div>
<br />
The
next screen asks you to select the Creation Options for the database
(create, save as database template, generate database creation scripts).<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-16JrSSL19mU/UeaLMrUgxsI/AAAAAAAACvI/9eslAysYMUQ/s1600/dbca_12c_12b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://3.bp.blogspot.com/-16JrSSL19mU/UeaLMrUgxsI/AAAAAAAACvI/9eslAysYMUQ/s640/dbca_12c_12b.png" width="640" /></a></div>
The pre requisite checks are all satisfied.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-FqGFcpJJJF0/UeaLMxW0RaI/AAAAAAAACvQ/1-vm7TAh6KU/s1600/dbca_12c_13b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://3.bp.blogspot.com/-FqGFcpJJJF0/UeaLMxW0RaI/AAAAAAAACvQ/1-vm7TAh6KU/s640/dbca_12c_13b.png" width="640" /></a></div>
Creation of the database configuration summary.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-7bWGMHbqFXA/UeaLNYfUyaI/AAAAAAAACvg/n71mKZf8r9I/s1600/dbca_12c_14b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://1.bp.blogspot.com/-7bWGMHbqFXA/UeaLNYfUyaI/AAAAAAAACvg/n71mKZf8r9I/s640/dbca_12c_14b.png" width="640" /></a></div>
Database configuration summary created. So click finish button to begin the installation process. <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-oN0AkDKvjOE/UeaLNmu0PLI/AAAAAAAACvo/sz9d0gHGrCc/s1600/dbca_12c_15b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://1.bp.blogspot.com/-oN0AkDKvjOE/UeaLNmu0PLI/AAAAAAAACvo/sz9d0gHGrCc/s640/dbca_12c_15b.png" width="640" /></a></div>
The database creation is in progress... still 36%.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-XSVkKtGdRC8/UeaLN5ZVo7I/AAAAAAAACvw/lF0bzjoz3Zc/s1600/dbca_12c_16b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="460" src="http://3.bp.blogspot.com/-XSVkKtGdRC8/UeaLN5ZVo7I/AAAAAAAACvw/lF0bzjoz3Zc/s640/dbca_12c_16b.png" width="640" /></a></div>
The database is finally created as well as the EM Database Express. In my case I was running another EM Database Express so the next available port was used (5501 instead of the "already in use" 5500). If you want to change the port number of your EM Database Express <a href="http://dbaworkshop.blogspot.it/2013/07/How-to-configure-the-HTTPS-Port-for-EM-Database-Express-12c.html" target="_blank">have a look at this post</a>.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-TEYX-OUiEO8/UeaLOYc5KoI/AAAAAAAACv4/s8fdaClYs5Y/s1600/dbca_12c_17b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://1.bp.blogspot.com/-TEYX-OUiEO8/UeaLOYc5KoI/AAAAAAAACv4/s8fdaClYs5Y/s640/dbca_12c_17b.png" width="640" /></a></div>
<br />
Some screenshots from the EM Database Express.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-E9ixD1xBuNA/UeaLO96oQGI/AAAAAAAACwM/aCwL5HuD-G8/s1600/dbca_12c_19b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="450" src="http://3.bp.blogspot.com/-E9ixD1xBuNA/UeaLO96oQGI/AAAAAAAACwM/aCwL5HuD-G8/s640/dbca_12c_19b.png" width="640" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-2fHsAWpYH2g/UeaLOd5PYRI/AAAAAAAACwI/Z4adON3k6lk/s1600/dbca_12c_18b.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="252" src="http://4.bp.blogspot.com/-2fHsAWpYH2g/UeaLOd5PYRI/AAAAAAAACwI/Z4adON3k6lk/s640/dbca_12c_18b.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-2fHsAWpYH2g/UeaLOd5PYRI/AAAAAAAACwI/Z4adON3k6lk/s1600/dbca_12c_18b.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<br />
That's all.<br />
<br />
<br />Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com5tag:blogger.com,1999:blog-3005934468887687781.post-18622376616677887092013-07-16T20:14:00.000+01:002013-07-16T20:14:33.051+01:00How to configure the HTTPS Port for EM Database Express 12c<b>Configuring the HTTPS Port for EM Database Express 12c</b><br />
<br />
If you used dbca to configure your database and enabled to configure also the EM Express you can find the EM Express URL provided by DBCA in the latest GUI screen.<br />
If you forget the URL you can use the following SQL statement to find the port for EM Express:
<br />
<pre class="cpp" name="code">[oracle@vsi08devpom ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Tue Jul 16 13:31:31 2013
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> select dbms_xdb_config.gethttpsport() from dual;
DBMS_XDB_CONFIG.GETHTTPSPORT()
------------------------------
5500</pre>
In your web browser enter the EM Express URL in this format to go to the login page: https://hostname:portnumber/em/<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-PJtm85J0wwY/UeWYzf_QbsI/AAAAAAAACs8/8t5VcDRIrMk/s1600/EM_Database_Express_12c_Login_5500.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="190" src="http://4.bp.blogspot.com/-PJtm85J0wwY/UeWYzf_QbsI/AAAAAAAACs8/8t5VcDRIrMk/s640/EM_Database_Express_12c_Login_5500.png" width="640" /></a></div>
When EM Express prompts you for your username and password, log in as a user with DBA privilege (such as SYSTEM or SYS). <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-jeIhxbv7pQY/UeWY0nbZ6FI/AAAAAAAACtY/pUs1XyubO5o/s1600/EM_Database_Express_12c_Welcome_5500_01.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="372" src="http://1.bp.blogspot.com/-jeIhxbv7pQY/UeWY0nbZ6FI/AAAAAAAACtY/pUs1XyubO5o/s640/EM_Database_Express_12c_Welcome_5500_01.png" width="640" /></a></div>
<br />
If you want to change the default HTTPS Port for EM Express, that is 5500, you can proceed following these steps (as seen on Oracle documentation):<br />
<br />
1. Configure and start the Oracle Net Listener (the listener). You can use lsnrctl to start, stop, and view the status of the listener<br />
<br />
2. If the listener is running on a nonstandard port (for example, not 1521), then the init.ora file for the database you want to manage using EM Express must contain a local_listener entry so that the HTTPS port can register with the correct listener. The local_listener entry references a TNSNAMES entry that points to the correct listener. For example:
<br />
<pre class="cpp" name="code">local_listener=inst1</pre>
where inst1 is a TNSNAMES entry defined in tnsnames.ora that points to the listener. For example:
<br />
<pre class="cpp" name="code">inst1= (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host_name)(PORT=1234))
(CONNECT_DATA=(SERVICE_NAME=service_name)(SERVER=DEDICATED)))</pre>
In this example, 1234 is the nonstandard port on which the listener has been configured to listen.<br />
<br />
3. Enable the TCP dispatcher by adding the following entry to the init.ora file for the database you want to manage using EM Express:
<br />
<pre class="cpp" name="code">dispatchers="(PROTOCOL=TCP)(SERVICE=<sid>XDB)"</sid></pre>
In my case, because the database SID is CDB001 I have:
<br />
<pre class="cpp" name="code">SQL> show parameter dispatchers
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dispatchers string (PROTOCOL=TCP) (SERVICE=CDB001
XDB)
max_dispatchers integer</pre>
<br />
4. Restart the database so that the changes made in the init.ora file take effect.<br />
<br />
5. Use the PL/SQL procedure DBMS_XDB_CONFIG.SETHTTPSPORT to set the HTTPS port for EM Express. This will update the HTTPS port in the xdbconfig.xml file in the Oracle XML DB Repository. You must connect as SYS / AS SYSDBA to run the procedure.
In my case I'm going to change the default port 5500 to 5555:
<br />
<pre class="cpp" name="code">SQL> exec DBMS_XDB_CONFIG.SETHTTPSPORT(5555);
PL/SQL procedure successfully completed.</pre>
<br />
6. To access EM Express, enter a URL in the following format in a Web browser: https://hostname:portnumber/em/<br />
<br />
Have a look at the following picture:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-k65KB6sjegU/UeWYzbe7gUI/AAAAAAAACtM/AFhIdh5PV_E/s1600/EM_Database_Express_12c_LOGIN.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="200" src="http://3.bp.blogspot.com/-k65KB6sjegU/UeWYzbe7gUI/AAAAAAAACtM/AFhIdh5PV_E/s640/EM_Database_Express_12c_LOGIN.png" width="640" /></a></div>
<br />
When prompted for your username and password, log in as a user with DBA privilege (such as SYSTEM).<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-mKXz3jyJJqE/UeWYzsKqo9I/AAAAAAAACtE/P1H41ywy-No/s1600/EM_Database_Express_12c_Welcome.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="374" src="http://2.bp.blogspot.com/-mKXz3jyJJqE/UeWYzsKqo9I/AAAAAAAACtE/P1H41ywy-No/s640/EM_Database_Express_12c_Welcome.png" width="640" /></a></div>
<br />
Simply executes the same procedure to set again the default port number to 5500.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-h0B-lNR6g0s/UeWY0dzx0mI/AAAAAAAACtU/cWzA4fHGHLA/s1600/EM_Database_Express_12c_Welcome_5500.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="372" src="http://4.bp.blogspot.com/-h0B-lNR6g0s/UeWY0dzx0mI/AAAAAAAACtU/cWzA4fHGHLA/s640/EM_Database_Express_12c_Welcome_5500.png" width="640" /></a></div>
<br />
<br />
That's all.<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-PJtm85J0wwY/UeWYzf_QbsI/AAAAAAAACs0/4z3zeGd-qfY/s1600/EM_Database_Express_12c_Login_5500.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a><a href="http://3.bp.blogspot.com/-k65KB6sjegU/UeWYzbe7gUI/AAAAAAAACtA/L5xl6inseU0/s1600/EM_Database_Express_12c_LOGIN.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div>
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-mKXz3jyJJqE/UeWYzsKqo9I/AAAAAAAACs4/gM37eLgP0PU/s1600/EM_Database_Express_12c_Welcome.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-h0B-lNR6g0s/UeWY0dzx0mI/AAAAAAAACtI/TKorC4p890c/s1600/EM_Database_Express_12c_Welcome_5500.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-jeIhxbv7pQY/UeWY0nbZ6FI/AAAAAAAACtQ/HXuJwWNb3qk/s1600/EM_Database_Express_12c_Welcome_5500_01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com10tag:blogger.com,1999:blog-3005934468887687781.post-60976743966830480762013-07-14T20:03:00.000+01:002013-07-14T20:03:24.603+01:00How to install Oracle Instant Client 12c and Oracle SQL Plus on UbuntuSo you want to use your Ubuntu distribution and connect to an Oracle database.<br />
Here you can find the steps to install and configure the Oracle Instant Client on Ubuntu 12.04.<br />
<br />
First of all you need to go to the following link
<a href="http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html" target="_blank">http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html</a>
and choose the Instant Client for your platform (in my case it is "Instant Client for Linux x86").<br />
<br />
On the next web page select "Accept License Agreement" so you can download some rpm packets of the latest available Instant Client version (today is <b><b>Version 12.1.0.1.0</b></b>).<br />
<br />
Click on <b>oracle-instantclient12.1-basic-12.1.0.1.0-1.i386.rpm</b> (Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications), <b>oracle-instantclient12.1-sqlplus-12.1.0.1.0-1.i386.rpm</b> (Instant Client Package - SQL*Plus: Additional libraries and executable for running SQL*Plus with Instant Client)
and <b>oracle-instantclient12.1-devel-12.1.0.1.0-1.i386.rpm</b> (Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client).<br />
<br />
To be available to download those rpm packets you have also to sign in into the Oracle website.<br />
<br />
Next step is to install alien on your distribution.<br />
From the man page "alien is a program that converts between Red Hat rpm, Debian deb, Stampede slp, Slackware tgz, and Solaris pkg file formats. If you want to use a package from another linux distribution than the one you have installed on your system, you can use alien to convert it to your preferred package format and install it."<br />
<br />
<pre class="cpp" name="code">ubuntu@ubuntu-VirtualBox:~$ sudo apt-get install alien
</pre>
Then go to your download directory and list the available rpm packets.
<br />
<pre class="cpp" name="code">ubuntu@ubuntu-VirtualBox:~$ cd Downloads/
ubuntu@ubuntu-VirtualBox:~/Downloads$ ls
oracle-instantclient12.1-basic-12.1.0.1.0-1.i386.rpm
oracle-instantclient12.1-devel-12.1.0.1.0-1.i386.rpm
oracle-instantclient12.1-sqlplus-12.1.0.1.0-1.i386.rpm</pre>
Let's install all of them using alien command:
<br />
<pre class="cpp" name="code">ubuntu@ubuntu-VirtualBox:~/Downloads$ sudo alien -i oracle-instantclient12.1-sqlplus-12.1.0.1.0-1.i386.rpm
dpkg --no-force-overwrite -i oracle-instantclient12.1-sqlplus_12.1.0.1.0-2_i386.deb
Selecting previously unselected package oracle-instantclient12.1-sqlplus.
(Reading database ... 142987 files and directories currently installed.)
Unpacking oracle-instantclient12.1-sqlplus (from oracle-instantclient12.1-sqlplus_12.1.0.1.0-2_i386.deb) ...
Setting up oracle-instantclient12.1-sqlplus (12.1.0.1.0-2) ...
</pre>
Now it's time for the Instant Client Basic Package:
<br />
<pre class="cpp" name="code">ubuntu@ubuntu-VirtualBox:~/Downloads$ sudo alien -i oracle-instantclient12.1-basic-12.1.0.1.0-1.i386.rpm
dpkg --no-force-overwrite -i oracle-instantclient12.1-basic_12.1.0.1.0-2_i386.deb
Selecting previously unselected package oracle-instantclient12.1-basic.
(Reading database ... 143000 files and directories currently installed.)
Unpacking oracle-instantclient12.1-basic (from oracle-instantclient12.1-basic_12.1.0.1.0-2_i386.deb) ...
Setting up oracle-instantclient12.1-basic (12.1.0.1.0-2) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place</pre>
And finally it's time for Instant Client SDK Package:
<br />
<pre class="cpp" name="code">ubuntu@ubuntu-VirtualBox:~/Downloads$ sudo alien -i oracle-instantclient12.1-devel-12.1.0.1.0-1.i386.rpm
dpkg --no-force-overwrite -i oracle-instantclient12.1-devel_12.1.0.1.0-2_i386.deb
Selecting previously unselected package oracle-instantclient12.1-devel.
(Reading database ... 143016 files and directories currently installed.)
Unpacking oracle-instantclient12.1-devel (from oracle-instantclient12.1-devel_12.1.0.1.0-2_i386.deb) ...
Setting up oracle-instantclient12.1-devel (12.1.0.1.0-2) ...</pre>
Let's try to issue the sqlplus command
<br />
<pre class="cpp" name="code">ubuntu@ubuntu-VirtualBox:~$ sqlplus / as sysdba
sqlplus: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
</pre>
Ops.. it fails because of a missing shared object file: libaio.so.1
So install libaio1 using the usual apt-get command.
<br />
<pre class="cpp" name="code">ubuntu@ubuntu-VirtualBox:~$ sudo apt-get install libaio1
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
libaio1
0 upgraded, 1 newly installed, 0 to remove and 608 not upgraded.
Need to get 6,648 B of archives.
After this operation, 53.2 kB of additional disk space will be used.
Get:1 http://it.archive.ubuntu.com/ubuntu/ precise/main libaio1 i386 0.3.109-2ubuntu1 [6,648 B]
Fetched 6,648 B in 0s (12.5 kB/s)
Selecting previously unselected package libaio1.
(Reading database ... 143067 files and directories currently installed.)
Unpacking libaio1 (from .../libaio1_0.3.109-2ubuntu1_i386.deb) ...
Setting up libaio1 (0.3.109-2ubuntu1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place</pre>
Let's try to run sqlplus again.
<br />
<pre class="cpp" name="code">ubuntu@ubuntu-VirtualBox:~/Downloads$ sqlplus / as sysdba
sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory</pre>
sqlplus complains about missing libraries. You can solve creating/editing the oracle.conf file issuing the following command and simply adding a line (the path where were installed all the libraries of the Instant Client packages: /usr/lib/oracle/12.1/client/lib):
<br />
<pre class="cpp" name="code">ubuntu@ubuntu-VirtualBox:~/Downloads$sudo vi /etc/ld.so.conf.d/oracle.conf
/usr/lib/oracle/12.1/client/lib
</pre>
Now update the information of all the shared libraries on your system.
<br />
<pre class="cpp" name="code">ubuntu@ubuntu-VirtualBox:~/Downloads$sudo ldconfig</pre>
Run sqlplus again... and as you can see it works...
<br />
<pre class="cpp" name="code">ubuntu@ubuntu-VirtualBox:~$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Sun Jul 14 20:01:37 2013
Copyright (c) 1982, 2013, Oracle. All rights reserved.
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
</pre>
... even if there's no database to connect to...<br />
On the next post a new Oracle Database 12c will be finally available.<br />
<br />
That's all.Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com10tag:blogger.com,1999:blog-3005934468887687781.post-45842186582649999912013-07-12T17:56:00.000+01:002013-07-12T17:56:37.088+01:00Oracle Database 12c: pictures from Rome<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Few pictures taken during the Oracle Database 12c presentation in Rome.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-Ff9jwNotpJI/UeAybhHCJuI/AAAAAAAACqc/p9C6hw0rDkg/s1600/2013-07-11+09.12.18.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="640" src="http://3.bp.blogspot.com/-Ff9jwNotpJI/UeAybhHCJuI/AAAAAAAACqc/p9C6hw0rDkg/s640/2013-07-11+09.12.18.jpg" width="425" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-SmayUaaBCnA/UeAyYYOxRrI/AAAAAAAACqU/DRZ0-QZ1QFY/s1600/2013-07-11+09.44.55.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://3.bp.blogspot.com/-SmayUaaBCnA/UeAyYYOxRrI/AAAAAAAACqU/DRZ0-QZ1QFY/s640/2013-07-11+09.44.55.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-FjqZtgAvjGc/UeAyWMwRW_I/AAAAAAAACqM/JDbypx-2ufY/s1600/2013-07-11+10.53.16.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://4.bp.blogspot.com/-FjqZtgAvjGc/UeAyWMwRW_I/AAAAAAAACqM/JDbypx-2ufY/s640/2013-07-11+10.53.16.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-iJASs2Lfjho/UeAybiPcErI/AAAAAAAACqg/6iRymDTz7KE/s1600/2013-07-11+11.00.43.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://4.bp.blogspot.com/-iJASs2Lfjho/UeAybiPcErI/AAAAAAAACqg/6iRymDTz7KE/s640/2013-07-11+11.00.43.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-oPi7u_ERoqU/UeAyh8pCZuI/AAAAAAAACq8/gn9kSNTNgak/s1600/2013-07-11+11.02.45.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://4.bp.blogspot.com/-oPi7u_ERoqU/UeAyh8pCZuI/AAAAAAAACq8/gn9kSNTNgak/s640/2013-07-11+11.02.45.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-LcS3Ba6EV_o/UeAygVdb8ZI/AAAAAAAACqs/5zwh6swLbkw/s1600/2013-07-11+11.12.35.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://4.bp.blogspot.com/-LcS3Ba6EV_o/UeAygVdb8ZI/AAAAAAAACqs/5zwh6swLbkw/s640/2013-07-11+11.12.35.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-59bgFmeVgoI/UeAyg1xvzLI/AAAAAAAACqw/kwq2O4MdF4w/s1600/2013-07-11+11.47.39.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://2.bp.blogspot.com/-59bgFmeVgoI/UeAyg1xvzLI/AAAAAAAACqw/kwq2O4MdF4w/s640/2013-07-11+11.47.39.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-zSO5dsveqeM/UeAy3l3kNPI/AAAAAAAACrU/6jpV3am05QA/s1600/2013-07-11+11.55.28.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://3.bp.blogspot.com/-zSO5dsveqeM/UeAy3l3kNPI/AAAAAAAACrU/6jpV3am05QA/s640/2013-07-11+11.55.28.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-bOujgQOk2TM/UeAyw6Va4xI/AAAAAAAACrE/lR0QQWF0d08/s1600/2013-07-11+11.57.39.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://1.bp.blogspot.com/-bOujgQOk2TM/UeAyw6Va4xI/AAAAAAAACrE/lR0QQWF0d08/s640/2013-07-11+11.57.39.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-m273GsECUwk/UeAyy4ar6VI/AAAAAAAACrM/OnrC0gTMQ58/s1600/2013-07-11+11.58.14.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://4.bp.blogspot.com/-m273GsECUwk/UeAyy4ar6VI/AAAAAAAACrM/OnrC0gTMQ58/s640/2013-07-11+11.58.14.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-MQNkrqMXbrc/UeAzZqxIAAI/AAAAAAAACrs/YAxfO5xqWas/s1600/2013-07-11+12.00.16.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://1.bp.blogspot.com/-MQNkrqMXbrc/UeAzZqxIAAI/AAAAAAAACrs/YAxfO5xqWas/s640/2013-07-11+12.00.16.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-4YvoA0-1umE/UeAzWg6yoPI/AAAAAAAACrc/wZyieGyVjuU/s1600/2013-07-11+12.01.02.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://3.bp.blogspot.com/-4YvoA0-1umE/UeAzWg6yoPI/AAAAAAAACrc/wZyieGyVjuU/s640/2013-07-11+12.01.02.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-_2fCVQ4WjaM/UeAzYue0QwI/AAAAAAAACrk/mZv2OO9ijU0/s1600/2013-07-11+12.01.49.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://3.bp.blogspot.com/-_2fCVQ4WjaM/UeAzYue0QwI/AAAAAAAACrk/mZv2OO9ijU0/s640/2013-07-11+12.01.49.jpg" width="640" /></a><a href="http://1.bp.blogspot.com/-9-WhLjpwIyE/UeAzcneHREI/AAAAAAAACr0/WI2FgnyI51M/s1600/2013-07-11+12.06.25.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://1.bp.blogspot.com/-9-WhLjpwIyE/UeAzcneHREI/AAAAAAAACr0/WI2FgnyI51M/s640/2013-07-11+12.06.25.jpg" width="640" /></a></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-LAKt55Hyu4Y/UeAztb0pO8I/AAAAAAAACsA/BY_0KFjZQqw/s1600/2013-07-11+12.35.17.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://1.bp.blogspot.com/-LAKt55Hyu4Y/UeAztb0pO8I/AAAAAAAACsA/BY_0KFjZQqw/s640/2013-07-11+12.35.17.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-H9U3eDGoQFw/UeAztO1u-PI/AAAAAAAACr8/TKtOiTVXo2E/s1600/2013-07-11+12.35.23.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://1.bp.blogspot.com/-H9U3eDGoQFw/UeAztO1u-PI/AAAAAAAACr8/TKtOiTVXo2E/s640/2013-07-11+12.35.23.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-1Kh2eNSNcFc/UeAzuMTGHFI/AAAAAAAACsM/3rtKlA6L4mc/s1600/2013-07-11+12.35.54.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="480" src="http://2.bp.blogspot.com/-1Kh2eNSNcFc/UeAzuMTGHFI/AAAAAAAACsM/3rtKlA6L4mc/s640/2013-07-11+12.35.54.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="http://1.bp.blogspot.com/-HJdi3kAFnpg/UeAzzlTO8LI/AAAAAAAACsc/KMGr5HNEn7Y/s1600/2013-07-11+12.36.02.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="http://1.bp.blogspot.com/-HJdi3kAFnpg/UeAzzlTO8LI/AAAAAAAACsc/KMGr5HNEn7Y/s640/2013-07-11+12.36.02.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="http://1.bp.blogspot.com/-KnLXI6cgt4I/UeAzy5CGcqI/AAAAAAAACsU/5AoYV4_yRlw/s1600/2013-07-11+12.38.24.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="http://1.bp.blogspot.com/-KnLXI6cgt4I/UeAzy5CGcqI/AAAAAAAACsU/5AoYV4_yRlw/s640/2013-07-11+12.38.24.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="http://4.bp.blogspot.com/-2XOyAgKjaaQ/UeAz6UdYTFI/AAAAAAAACsk/qHr1j07kJpI/s1600/2013-07-11+13.17.00.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="http://4.bp.blogspot.com/-2XOyAgKjaaQ/UeAz6UdYTFI/AAAAAAAACsk/qHr1j07kJpI/s640/2013-07-11+13.17.00.jpg" width="640" /></a></div>
<br />Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com2tag:blogger.com,1999:blog-3005934468887687781.post-91629832116386473152013-07-10T12:48:00.000+01:002013-07-10T12:48:00.089+01:00Software only installation of Oracle Database 12c release 1In this post I'm going to install only the software of the Oracle Database 12c release 1.<br />
<br />
Download from Oracle website and extract it into the home directory of the oracle user.
<br />
<pre class="cpp" name="code">[oracle@localhost ~]$ pwd
/home/oracle
[oracle@localhost ~]$ cd database/
[oracle@localhost database]$ ./runInstaller &</pre>
The GUI of the installer is similar to the previous version.<br />
<br />
On the first step "Configure Security Update" you have to specify your email to be informed on security issue;<br />
on next step "Software Updates" it asks to download any PSU available;<br />
on next step "Installation Option" it asks what kind of installation you want to perform. I'm going to choose "Install database software only";<br />
on next step "Grid Installation Options" it asks if you want to install a single instance, a RAC or a RAC One Node database installation. I'm selecting "Single instance database installation";<br />
on next step "Product Languages" choose the one you need or leave the English default language like I do;<br />
on next step "Database Edition" I'm going to choose "Enterprise Edition" instead of "Standard Edition" or "Standard Edition One";<br />
<br />
Before proceeding on next step execute the following commands:
<br />
<pre class="cpp" name="code">[root@localhost /]# mkdir -p /app/oracle
[root@localhost /]# chonw oracle.oinstall /app/oracle
[root@localhost /]# chown oracle.oinstall /app/oracle</pre>
on next step "Installation Location" I'm going to use "/app/oracle/" as Oracle base and "/app/oracle/product/12.1.0/dbhome_1" as software location;<br />
<br />
Before proceeding on next step execute the following commands:
<br />
<pre class="cpp" name="code">[root@localhost /]# mkdir -p /app/oraInventory
[root@localhost /]# chown oracle.oinstall /app/oraInventory</pre>
on next step "Create Inventory" I'm going to use "/app/oraInventory" as Inventory Directory and oinstall as oraInventory Group Name;<br />
<br />
on next step "Operating Sytem Groups" I selected dba group;<br />
on the next step "Summary" I first saved the response file and the clicked the Install button.<br />
<br />
When asked execute the suggested scripts as root user:
/app/oraInventory/orainstRoot.sh
and /app/oracle/product/12.1.0/dbhome_1/root.sh
<br />
<pre class="cpp" name="code">[root@localhost /]# /app/oraInventory/orainstRoot.sh
Changing permissions of /app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /app/oraInventory to oinstall.
The execution of the script is complete.
[root@localhost /]# /app/oracle/product/12.1.0/dbhome_1/root.sh
Performing root user operation for Oracle 12c
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /app/oracle/product/12.1.0/dbhome_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.</pre>
The installation of Oracle Database was successful.<br />
<br />
That's all.
Marco V.http://www.blogger.com/profile/01205506217107591086noreply@blogger.com7