Thursday, June 18, 2015

Few ORA- error while "alter table ....move"

[oracle@vmxdb01 ~]$ grep ORA- move_table.log |sort|uniq
ORA-00997: illegal use of LONG datatype
ORA-01735: invalid ALTER TABLE option
ORA-14512: cannot perform operation on a clustered object
ORA-25191: cannot reference overflow table of an index-organized table


ORA-00997: illegal use of LONG datatype
SQL> alter table SYS.WRI$_SQLSET_WORKSPACE_PLANS move;
SQL> alter table SYS.WRI$_SQLSET_PLAN_LINES move;
SQL> alter table SYS.WRI$_ADV_SQLT_PLANS move;
SQL> alter table SYS.SQLOBJ$PLAN move;

To fix:
In this example, all tables are actually empty.
For application tables, suggest to use copy or expdp/impdp.

ORA-01735: invalid ALTER TABLE option
SQL> alter table XDB.SYS_NT/ZrP7FfoSKngQ7ap6Ar7bw== move;

To fix:
SQL> alter table XDB."SYS_NT/ZrP7FfoSKngQ7ap6Ar7bw==" move;
Table altered.

ORA-14512: cannot perform operation on a clustered object
SQL> alter table SYS.SMON_SCN_TIME move;

To fix:
SQL> select cluster_owner,cluster_name from dba_tables
  2  where owner='SYS' and table_name='SMON_SCN_TIME';

CLUSTER_OWNER                  CLUSTER_NAME
------------------------------ ------------------------------
SYS                            SMON_SCN_TO_TIME_AUX

SQL> select owner,table_name from dba_tables
  2  where cluster_name='SMON_SCN_TO_TIME_AUX' and cluster_owner='SYS';

OWNER                          TABLE_NAME
------------------------------ ------------------------------
SYS                            SMON_SCN_TIME

Expdp/impdp to create the object if not sys internal objects.

ORA-25191: cannot reference overflow table of an index-organized table
SQL> alter table SYS.SYS_IOT_OVER_18291 move;
SQL> alter table SYS.SYS_IOT_OVER_17517 move;
SQL> alter table SYS.SYS_IOT_OVER_7687 move;
…

To fix:
SQL> select owner,table_name,iot_name from dba_tables where owner='SYS' and table_name='SYS_IOT_OVER_7687';

OWNER                          TABLE_NAME
------------------------------ ------------------------------
IOT_NAME
--------------------------------------------------------------------------------
SYS                            SYS_IOT_OVER_7687
RECENT_RESOURCE_INCARNATIONS$


SQL> alter table RECENT_RESOURCE_INCARNATIONS$ move tablespace sysaux overflow tablespace sysaux;

Table altered.

SQL> select owner,table_name,iot_name from dba_tables where owner='SYS' and table_name='SYS_IOT_OVER_18291';

OWNER                          TABLE_NAME
------------------------------ ------------------------------
IOT_NAME
--------------------------------------------------------------------------------
SYS                            SYS_IOT_OVER_18291
AQ$_SYS$SERVICE_METRICS_TAB_G

SQL> alter table AQ$_SYS$SERVICE_METRICS_TAB_G move tablespace sysaux overflow tablespace sysaux;
alter table AQ$_SYS$SERVICE_METRICS_TAB_G move tablespace sysaux overflow tablespace sysaux
            *
ERROR at line 1:
ORA-24005: Inappropriate utilities used to perform DDL on AQ table
SYS.AQ$_SYS$SERVICE_METRICS_TAB_G
SQL> DECLARE
  2    po dbms_aqadm.aq$_purge_options_t;
  3  BEGIN
  4    po.block := FALSE;
  5    DBMS_AQADM.PURGE_QUEUE_TABLE(
  6      queue_table => 'AQ$_SYS$SERVICE_METRICS_TAB_G',
  7      purge_condition => NULL,
    purge_options => po);
  8    9  END;
 10  /
DECLARE
*
ERROR at line 1:
ORA-24019: identifier for QUEUE_TABLE too long, should not be greater than 24
characters
ORA-06512: at "SYS.DBMS_AQADM", line 1668
ORA-06512: at line 5
SQL> DECLARE
  2    po dbms_aqadm.aq$_purge_options_t;
  3  BEGIN
  4    po.block := FALSE;
  5    DBMS_AQADM.PURGE_QUEUE_TABLE(
  6      queue_table => 'SYS$SERVICE_METRICS_TAB',
  7      purge_condition => NULL,
  8      purge_options => po);
  9  END;
 10  /

PL/SQL procedure successfully completed.



Wednesday, June 17, 2015

Clone Oracle Home (using 12c as example)

Copy Oracle Home

root@solaris112:/u01/app/oracle/product/12.1.0# cp -rp dbhome_1 dbhome_2

Run the Clone Script:

oracle@solaris112:/u01/app/oracle/product/12.1.0/dbhome_2/bin$ $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/clone/bin/clone.pl ORACLE_BASE="/u01/app/oracle" ORACLE_HOME="/u01/app/oracle/product/12.1.0/dbhome_2" OSDBA_GROUP=dba ORACLE_HOME_NAME=Cloned_Home
./runInstaller -clone -waitForCompletion  "ORACLE_BASE=/u01/app/oracle" "ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_2" "oracle_install_OSDBA=dba" "ORACLE_HOME_NAME=Cloned_Home" -silent -paramFile /u01/app/oracle/product/12.1.0/dbhome_2/clone/clone_oraparam.ini
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 500 MB.   Actual 3923 MB    Passed
Checking swap space: must be greater than 500 MB.   Actual 4101 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2015-06-18_05-05-46AM. Please wait ...You can find the log of this install session at:
 /u01/app/oraInventory/logs/cloneActions2015-06-18_05-05-46AM.log
..................................................   5% Done.
..................................................   10% Done.
..................................................   15% Done.
..................................................   20% Done.
..................................................   25% Done.
..................................................   30% Done.
..................................................   35% Done.
..................................................   40% Done.
..................................................   45% Done.
..................................................   50% Done.
..................................................   55% Done.
..................................................   60% Done.
..................................................   65% Done.
..................................................   70% Done.
..................................................   75% Done.
..................................................   80% Done.
..................................................   85% Done.
..........
Copy files in progress.

Copy files successful.

Link binaries in progress.

Link binaries successful.

Setup files in progress.

Setup files successful.

Setup Inventory in progress.

Setup Inventory successful.

Finish Setup successful.
The cloning of Cloned_Home was successful.
Please check '/u01/app/oraInventory/logs/cloneActions2015-06-18_05-05-46AM.log' for more details.

Setup Oracle Base in progress.

Setup Oracle Base successful.
..................................................   95% Done.

As a root user, execute the following script(s):
        1. /u01/app/oracle/product/12.1.0/dbhome_2/root.sh



..................................................   100% Done.

oracle@solaris112:/u01/app/oracle/product/12.1.0/dbhome_2/bin$ sudo /u01/app/oracle/product/12.1.0/dbhome_2/root.sh
Check /u01/app/oracle/product/12.1.0/dbhome_2/install/root_solaris112_2015-06-18_05-11-44.log for the output of root script

Post Verification:

oracle@solaris112:/u01/app/oracle/product/12.1.0/dbhome_2/bin$ $ORACLE_HOME/OPatch/opatch lsinventory
Oracle Interim Patch Installer version 12.1.0.1.3
Copyright (c) 2015, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/oracle/product/12.1.0/dbhome_2
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/oracle/product/12.1.0/dbhome_2/oraInst.loc
OPatch version    : 12.1.0.1.3
OUI version       : 12.1.0.2.0
Log file location : /u01/app/oracle/product/12.1.0/dbhome_2/cfgtoollogs/opatch/opatch2015-06-18_05-22-39AM_1.log

Lsinventory Output file location : /u01/app/oracle/product/12.1.0/dbhome_2/cfgtoollogs/opatch/lsinv/lsinventory2015-06-18_05-22-39AM.txt

--------------------------------------------------------------------------------
Installed Top-level Products (1):

Oracle Database 12c                                                  12.1.0.2.0
There are 1 products installed in this Oracle Home.


There are no Interim patches installed in this Oracle Home.


--------------------------------------------------------------------------------

OPatch succeeded.



oracle@solaris112:/u01/app/oracle/product/12.1.0/dbhome_2/bin$ grep dbhome_1 *|awk -F":" '{print $1}'|uniq
aqxmlctl.ouibak
aqxmlctl.ouibak.1
bndlchk.ouibak
bndlchk.ouibak.1
chopt.ini.ouibak
chopt.ini.ouibak.1
chopt.ouibak
chopt.ouibak.1
chopt.pl.ouibak
chopt.pl.ouibak.1
dbca.ouibak
dbca.ouibak.1
dbua.ouibak
dbua.ouibak.1
diagsetup.ouibak
diagsetup.ouibak.1
dropjava.ouibak
dropjava.ouibak.1
emca.ouibak
emca.ouibak.1
eusm.ouibak
eusm.ouibak.1
extusrupgrade.ouibak
extusrupgrade.ouibak.1
kfod.ouibak
kfod.ouibak.1
ldifmigrator.ouibak
ldifmigrator.ouibak.1
loadjava.ouibak
loadjava.ouibak.1
netca_deinst.sh.ouibak
netca_deinst.sh.ouibak.1
netca.ouibak
netca.ouibak.1
netmgr.ouibak
netmgr.ouibak.1
odisrvreg.ouibak
odisrvreg.ouibak.1
oidca.ouibak
oidca.ouibak.1
oidprovtool.ouibak
oidprovtool.ouibak.1
ojvmjava.ouibak
ojvmjava.ouibak.1
ojvmtc.ouibak
ojvmtc.ouibak.1
olsadmintool.ouibak
olsadmintool.ouibak.1
olsoidsync.ouibak
olsoidsync.ouibak.1
onsctl.ouibak
onsctl.ouibak.1
platform_common.ouibak
platform_common.ouibak.1
rconfig.ouibak
rconfig.ouibak.1
schemasync.ouibak
schemasync.ouibak.1
srvctl.ouibak
srvctl.ouibak.1
trcasst.ouibak
trcasst.ouibak.1
trcsess.ouibak
trcsess.ouibak.1
umu.ouibak
umu.ouibak.1

oracle@solaris112:/u01/app/oracle/product/12.1.0/dbhome_2/bin$ grep dbhome_2 *|awk -F":" '{print $1}'|uniq
aqxmlctl
bndlchk
chopt
chopt.ini
chopt.pl
dbca
dbua
diagsetup
dropjava
emca
eusm
extusrupgrade
kfod
lbuilder
ldifmigrator
loadjava
netca
netca_deinst.sh
netmgr
odisrvreg
oidca
oidprovtool
ojvmjava
ojvmtc
olsadmintool
olsoidsync
onsctl
platform_common
rconfig
schemasync
srvctl
trcasst
trcsess
umu


Appendix: Clone Parameters

oracle@solaris112:/u01/app/oracle/product/12.1.0/dbhome_2/bin$ $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/clone/bin/clone.pl
./runInstaller -clone -waitForCompletion  -silent -paramFile /u01/app/oracle/product/12.1.0/dbhome_2/clone/bin/../../clone/clone_oraparam.ini
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 500 MB.   Actual 3934 MB    Passed
Checking swap space: must be greater than 500 MB.   Actual 4112 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2015-06-18_05-00-31AM. Please wait ...[INS-21001] ORACLE_HOME was not specified for clone.
Usage:
runInstaller  [-options] [()*]

Where options include:
  -clusterware oracle.crs,
        Version of Cluster ready services installed.

  -crsLocation
        Used only for cluster installs, specifies the path to the crs home location. Specifying this overrides CRS information obtained from central inventory.

  -invPtrLoc
        Unix only. To point to a different inventory location. The orainst.loc file contains:
inventory_loc=
inst_group=<>

  -jreLoc
        Path where Java Runtime Environment is installed. OUI cannot be run without it.

  -logLevel
        To filter log messages that have a lesser priority level than . Valid options are: severe, warning, info, config, fine, finer, finest, basic, general, detailed, trace. The use of basic, general, detailed, trace is deprecated.

  -paramFile
        Specify location of oraparam.ini file to be used by OUI.

  -responseFile
        Specifies the response file and path to use.

  -attachHome
        For attaching homes to the OUI inventory.

  -cfs
        Indicates that the Oracle home specified is on cluster file system (shared). This is mandatory when '-local' is specified so that Oracle Universal Installer can register the home appropriately into the inventory.

  -clone
        For making an Oracle Home copy match its current environment.

  -debug
        For getting the debug information from OUI.

  -detachHome
        For detaching homes from the OUI inventory without deleting inventory directory inside Oracle home.

  -enableRollingUpgrade
        Used in cluster environment, to enable upgrade of a product on a subset of nodes (on which the product was installed).

  -executeSysPrereqs
        Execute system pre-requisite checks and exit.

  -force
        Allowing silent mode installation into a non-empty directory.

  -help
        Displays above usage.

  -ignoreSysPrereqs
        For ignoring the results of the system pre-requisite checks.

  -local
        Performs the operation on the local node irrespective of the cluster nodes specified.

  -printdiskusage
        Log debug information for disk usage.

  -printmemory
        Log debug information for memory usage.

  -printtime
        Log debug information for time usage.

  -relink
        For performing relink actions on the oracle home
         Usage: -relink -maketargetsxml [-makedepsxml ] [name=value]

  -silent
        For silent mode operations, the inputs can be a response file or a list of command line variable value pairs.

  -waitforcompletion
        Installer will wait for completion instead of spawning the java engine and exiting.

  -suppressPreCopyScript
        Suppress the execution of precopy script.

  -acceptUntrustedCertificates
        Accept untrusted certificates from a secure site.

  -suppressPostCopyScript
        Suppress the execution of postcopy script.

  -noconfig
        Do not execute config tools.

  -noconsole
        For suppressing display of messages to console. Console is not allocated.

  -formCluster
        To install the Oracle clusterware in order to form the cluster.

  -remotecp
        Unix specific option. Used only for cluster installs, specifies the path to the remote copy program on the local cluster node.

  -remoteshell
        Unix specific option. Used only for cluster installs, specifies the path to the remote shell program on the local cluster node.

  -executePrereqs
        To execute only the prerequisite checks.

  -ignorePrereq
        To ignore running the prerequisite checks.

  -ignoreInternalDriverError
        To ignore any internal driver errors.

  -downloadUpdates
        To download updates only.

  -showProgress
        To show the installation progress on the console. This option is supported only in case of silent installation.

  -promptForPassword
        To provide the passwords on the console during silent installation of Oracle Database.

  -deinstall
        To Uninstall the specified home
        Usage:-home
              -help: To see detailed usage Information

Command Line Variables Usage
  Command line variables are specified using ; for example:
    [ session: | compName: | compName:version: ]variableName=" valueOfVariable"]

   Session/Installer variables are specified using:
          [session:]varName=value
    Ex 1: session:ORACLE_HOME_NAME="OraHome"
    Ex 2: ORACLE_HOME_NAME="OraHome"
    The lookup order is session:varName then just varName. The session prefix is used to avoid ambiguity.

   Component variables are specified using:
          [compInternalName:[Version:]]varName
    Ex 1: oracle.comp1:1.0.1:varName="VarValue"
    Ex 2: oracle.comp1:varName="VarValue"
    The lookup order is compInternalName:Version:varName, then compInternalName:varName, then just varName.


Tuesday, June 16, 2015

Recover database after lost redo+control files (with database clean shutdown)

oracle@solaris112:/u01/app/oracle/oradata/orcl2$ rm redo0*
oracle@solaris112:/u01/app/oracle/oradata/orcl2$ rm control01.ctl
oracle@solaris112:/u01/app/oracle/oradata/orcl2$ rm "/u01/app/oracle/fast_recovery_area/orcl2/control02.ctl"

oracle@solaris112:/u01/app/oracle/oradata/orcl2$ ls -ltr
total 5650988
-rw-r-----   1 oracle   oinstall 62922752 Jun 17 07:24 temp01.dbf
-rw-r-----   1 oracle   oinstall 817897472 Jun 17 07:25 system01.dbf
-rw-r-----   1 oracle   oinstall 639639552 Jun 17 07:25 sysaux01.dbf
-rw-r-----   1 oracle   oinstall 83894272 Jun 17 07:25 undotbs01.dbf
-rw-r-----   1 oracle   oinstall 1340874752 Jun 17 07:25 example01.dbf
-rw-r-----   1 oracle   oinstall 5251072 Jun 17 07:25 users01.dbf
oracle@solaris112:/u01/app/oracle/oradata/orcl2$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed Jun 17 07:30:20 2015

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area 1258291200 bytes
Fixed Size                  3003176 bytes
Variable Size             838864088 bytes
Database Buffers          402653184 bytes
Redo Buffers               13770752 bytes
SQL> set echo on
SQL> @/tmp/recreate_control.sql
SQL> CREATE CONTROLFILE REUSE DATABASE "ORCL2" RESETLOGS  NOARCHIVELOG
  2      MAXLOGFILES 16
  3      MAXLOGMEMBERS 3
  4      MAXDATAFILES 100
  5      MAXINSTANCES 8
  6      MAXLOGHISTORY 292
  7  LOGFILE
  8    GROUP 1 '/u01/app/oracle/oradata/orcl2/redo01.log'  SIZE 50M BLOCKSIZE 512,
  9    GROUP 2 '/u01/app/oracle/oradata/orcl2/redo02.log'  SIZE 50M BLOCKSIZE 512,
 10    GROUP 3 '/u01/app/oracle/oradata/orcl2/redo03.log'  SIZE 50M BLOCKSIZE 512
 11  -- STANDBY LOGFILE
 12  DATAFILE
 13    '/u01/app/oracle/oradata/orcl2/system01.dbf',
 14    '/u01/app/oracle/oradata/orcl2/sysaux01.dbf',
 15    '/u01/app/oracle/oradata/orcl2/undotbs01.dbf',
 16    '/u01/app/oracle/oradata/orcl2/example01.dbf',
 17    '/u01/app/oracle/oradata/orcl2/users01.dbf'
 18  CHARACTER SET WE8MSWIN1252
 19  ;

Control file created.

SQL>
SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-01100: database already mounted


SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
oracle@solaris112:/u01/app/oracle/oradata/orcl2$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Wed Jun 17 07:32:31 2015

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

connected to target database: ORCL2 (DBID=846932035, not open)

RMAN> alter database open resetlogs;

using target database control file instead of recovery catalog
Statement processed

RMAN> exit
Recovery Manager complete.

racle@solaris112:/u01/app/oracle/oradata/orcl2$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed Jun 17 07:33:19 2015

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

Recover lost of redo log scenarios with database clean shutdown

oracle@solaris112:/u01/app/oracle/oradata/orcl2$ rm redo0*
oracle@solaris112:/u01/app/oracle/oradata/orcl2$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed Jun 17 07:21:29 2015

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 1258291200 bytes
Fixed Size                  3003176 bytes
Variable Size             838864088 bytes
Database Buffers          402653184 bytes
Redo Buffers               13770752 bytes
Database mounted.
ORA-03113: end-of-file on communication channel
Process ID: 2365
Session ID: 1 Serial number: 24573

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
oracle@solaris112:/u01/app/oracle/oradata/orcl2$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed Jun 17 07:22:14 2015

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup mount
ORACLE instance started.

Total System Global Area 1258291200 bytes
Fixed Size                  3003176 bytes
Variable Size             838864088 bytes
Database Buffers          402653184 bytes
Redo Buffers               13770752 bytes
Database mounted.
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01139: RESETLOGS option only valid after an incomplete database recovery


SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-00264: no recovery required


SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01139: RESETLOGS option only valid after an incomplete database recovery


SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
oracle@solaris112:/u01/app/oracle/oradata/orcl2$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Wed Jun 17 07:23:13 2015

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

connected to target database: ORCL2 (DBID=846932035, not open)

RMAN> recover database;

Starting recover at 17-JUN-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=21 device type=DISK

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 17-JUN-15

RMAN> alter database open resetlogs;

Statement processed