Tuesday, February 28, 2017

Create plugable Database

Below is the command to create a plugable database. Another way is to create through dbca.

CREATE PLUGGABLE DATABASE orclpdb ADMIN USER pdbadm IDENTIFIED BY password
  STORAGE (MAXSIZE 2G)
  DEFAULT TABLESPACE testpdb
    DATAFILE '/disk1/oracle/dbs/orclpdb/sales01.dbf' SIZE 250M AUTOEXTEND ON
  PATH_PREFIX = '/disk1/oracle/dbs/orclpdb/'
  FILE_NAME_CONVERT = ('/disk1/oracle/dbs/pdbseed/', '/disk1/oracle/dbs/orclpdb/');

How to drop Plugable database

Below is the command to drop a plugable database

DROP PLUGGABLE DATABASE ORCLPDB INCLUDING DATAFILES;

Wednesday, January 25, 2017

Move a tablespace from ASM to filesystem

Move a tablespace to ASM from filesystem

Follow the below step to move tablespace to ASM from filesystem
Steps are as below.

1. Offilne the tablespace
2. Copy using RMAN
3. Rename datafile
4. Make it online, recover if required
5. Delete the old datafile

SQL> set line 300
SQL> set pages 300
SQL> col FILE_NAME for a100
SQL> SELECT FILE_NAME , tablespace_name FROM DBA_DATA_FILES;

FILE_NAME                                                                                            TABLESPACE_NAME
---------------------------------------------------------------------------------------------------- ------------------------------
/u01/app/oracle/product/12.1.0.2/orcltst/dbs/ORA_TEST                                                ORA_TEST

SQL>  ALTER TABLESPACE ORA_TEST  offline;

Tablespace altered.

SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
localhost:/db/home/oracle > rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Wed Jan 25 09:48:59 2017

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCLTST (DBID=3881831134)

RMAN> copy datafile '/u01/app/oracle/product/12.1.0.2/orcltst/dbs/ORA_TEST' to  '+ORCLTST';

Starting backup at 25-JAN-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00022 name=/u01/app/oracle/product/12.1.0.2/orcltst/dbs/ORA_TEST
output file name=+ORCLTST/ORCLTST/DATAFILE/ora_test.463.934210303 tag=TAG20170125T095142 RECID=4 STAMP=934192303
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 25-JAN-17

Starting Control File and SPFILE Autobackup at 25-JAN-17
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of Control File and SPFILE Autobackup command on ORA_DISK_1 channel at 01/25/2017 09:51:45
ORA-07217: sltln: environment variable cannot be evaluated.

RMAN>

SQL> alter database rename file '/u01/app/oracle/product/12.1.0.2/orcltst/dbs/ORA_TEST' to '+ORCLTST/ORCLTST/DATAFILE/ora_test.463.934210303';

Database altered.

SQL> col FILE_NAME for a100
SQL> set line 300
SQL> set pages 300
SQL> SELECT FILE_NAME , tablespace_name FROM DBA_DATA_FILES;

FILE_NAME                                                                                            TABLESPACE_NAME
---------------------------------------------------------------------------------------------------- ------------------------------
+ORCLTST/ORCLTST/DATAFILE/ora_test.463.934210303                                                      ORA_TEST

22 rows selected.

SQL> select * from gv$recover_file;

   INST_ID      FILE# ONLINE  ONLINE_ ERROR                                                                CHANGE# TIME          CON_ID
---------- ---------- ------- ------- ----------------------------------------------------------------- ---------- --------- ----------
         2         22 OFFLINE OFFLINE OFFLINE NORMAL                                                             0                    0
         1         22 OFFLINE OFFLINE OFFLINE NORMAL                                                             0                    0

8 rows selected.

SQL> alter tablespace ORA_TEST  online;

Tablespace altered.

SQL>  select * from gv$recover_file;

no rows selected

SQL> select count(*) from ;


  COUNT(*)
----------
         1

SQL> alter system switch all logfile;

System altered.

SQL> SELECT FILE_NAME , tablespace_name FROM DBA_DATA_FILES;

FILE_NAME                                                                                            TABLESPACE_NAME
---------------------------------------------------------------------------------------------------- ------------------------------
+ORCLTST/ORCLTST/DATAFILE/ora_test.463.934210303                                                      ORA_TEST

SQL>

Thursday, December 15, 2016

Srvctl is not able to start database (ORA-12547: TNS:lost contact)

Srvctl is not able to start database

[oracle@orcldb-n2 ~]$ srvctl start database -d orcl
PRCR-1079 : Failed to start resource ora.orcl.db
ORA-12547: TNS:lost contact
CRS-5017: The resource action "ora.orcl.db start" encountered the following error:
ORA-12547: TNS:lost contact
. For details refer to "(:CLSN00107:)" in "/u01/app/oracle/diag/crs/orcldb-n1/crs/trace/crsd_oraagent_oracle.trc".

CRS-2674: Start of 'ora.orcl.db' on 'orcldb-n1' failed
ORA-12547: TNS:lost contact
CRS-5017: The resource action "ora.orcl.db start" encountered the following error:
ORA-12547: TNS:lost contact
. For details refer to "(:CLSN00107:)" in "/u01/app/oracle/diag/crs/orcldb-n2/crs/trace/crsd_oraagent_oracle.trc".

CRS-2674: Start of 'ora.orcl.db' on 'orcldb-n2' failed
ORA-12547: TNS:lost contact
CRS-2632: There are no more servers to try to place resource 'ora.orcl.db' on that would satisfy its placement policy
ORA-12547: TNS:lost contact
[oracle@orcldb-n2 ~]$


Below document can help you. It can happen if the it is a cloned env.

Local SQL*Plus Connection and DBCA Fails With: ORA-12547: TNS:Lost Contact (Doc ID 422173.1)

1. Check kernel parameters settings
2. Check permission of permissions on the ORACLE executable, and config.o
[oracle@orcldb-n2 orcl]$ ls -lrt $ORACLE_HOME/rdbms/lib/config.o
-rw-r--r-- 1 oracle dba 1328 Dec 14 13:06 /u01/app/oracle/product/12.1.0.2/orcl/rdbms/lib/config.o
[oracle@orcldb-n2 orcl]$ ls -lrt $ORACLE_HOME/bin/oracle
-rwsr-s--x 1 oracle dba 324021455 Dec 14 13:06 /u01/app/oracle/product/12.1.0.2/orcl/bin/oracle
[oracle@orcldb-n2 orcl]$
3. Do relink all  on the database nodes
[oracle@orcldb-n2 orcl]$ relink all
writing relink log to: /u01/app/oracle/product/12.1.0.2/orcl/install/relink.log
[oracle@orcldb-n2 orcl]$ 

Search This Blog