Visit Counter

Friday, December 30, 2016

RESIZE Datafiles and Tempfile IN ORACLE 12c




SQL> alter database datafile '/ora/app/oracle/oradata/inforln/undotbs01.dbf' resize 10G;

Database altered.




SQL> alter database tempfile '/ora/app/oracle/oradata/inforln/temp01.dbf' resize 10G;

Database altered.





SQL> alter database datafile '/ora/app/oracle/oradata/inforln/system01.dbf' resize 5G;

Database altered.

RESIZE REDOLOG FILE IN ORACLE 12c




SQL>  select group#,sequence#,bytes,archived,status from v$log;

    GROUP#  SEQUENCE#   BYTES ARC STATUS
---------- ---------- ---------- --- ----------------
1   16 52428800 NO  CURRENT
2   14 52428800 YES INACTIVE
3   15 52428800 YES INACTIVE

SQL> alter database add logfile group 4 '/ora/app/oracle/oradata/inforln/redo04.log' size 6G;

Database altered.

SQL> alter database add logfile group 5 '/ora/app/oracle/oradata/inforln/redo05.log' size 6G;

Database altered.

SQL> alter database add logfile group 6 '/ora/app/oracle/oradata/inforln/redo06.log' size 6G;

Database altered.

SQL> select group#,sequence#,bytes,archived,status from v$log;

    GROUP#  SEQUENCE#   BYTES ARC STATUS
---------- ---------- ---------- --- ----------------
1   16 52428800 NO  CURRENT
2   14 52428800 YES INACTIVE
3   15 52428800 YES INACTIVE
4    0 6442450944 YES UNUSED
5    0 6442450944 YES UNUSED
6    0 6442450944 YES UNUSED

6 rows selected.



SQL> alter database drop logfile group 2;




Database altered.

SQL> select group#,sequence#,bytes,archived,status from v$log;

    GROUP#  SEQUENCE#   BYTES ARC STATUS
---------- ---------- ---------- --- ----------------
1   16 52428800 NO  CURRENT
3   15 52428800 YES INACTIVE
4    0 6442450944 YES UNUSED
5    0 6442450944 YES UNUSED
6    0 6442450944 YES UNUSED

SQL> alter database add logfile group 2 '/ora/app/oracle/oradata/inforln/redo02.log' size 6G;
alter database add logfile group 2 '/ora/app/oracle/oradata/inforln/redo02.log' size 6G
*
ERROR at line 1:
ORA-00301: error in adding log file
'/ora/app/oracle/oradata/inforln/redo02.log' - file cannot be created
ORA-27038: created file already exists
Additional information: 1


$ rename the redo file

$ mv redo02.log redo02.old.log


SQL> alter database add logfile group 2 '/ora/app/oracle/oradata/inforln/redo02.log' size 6G;

Database altered.

SQL> select group#,sequence#,bytes,archived,status from v$log;

    GROUP#  SEQUENCE#   BYTES ARC STATUS
---------- ---------- ---------- --- ----------------
1   16 52428800 NO  CURRENT
2    0 6442450944 YES UNUSED
3   15 52428800 YES INACTIVE
4    0 6442450944 YES UNUSED
5    0 6442450944 YES UNUSED
6    0 6442450944 YES UNUSED

6 rows selected.



SQL> alter database drop logfile group 3;

Database altered.


$ rename the redo file

$ mv redo03.log redo03.old.log

SQL> alter database add logfile group 3 '/ora/app/oracle/oradata/inforln/redo03.log' size 6G;

Database altered.

SQL> select group#,sequence#,bytes,archived,status from v$log;

    GROUP#  SEQUENCE#   BYTES ARC STATUS
---------- ---------- ---------- --- ----------------
1   16 52428800 NO  CURRENT
2    0 6442450944 YES UNUSED
3    0 6442450944 YES UNUSED
4    0 6442450944 YES UNUSED
5    0 6442450944 YES UNUSED
6    0 6442450944 YES UNUSED

6 rows selected.



SQL> alter system switch logfile;

System altered.

SQL> select group#,sequence#,bytes,archived,status from v$log;

    GROUP#  SEQUENCE#   BYTES ARC STATUS
---------- ---------- ---------- --- ----------------
1   16 52428800 YES ACTIVE
2   17 6442450944 NO  CURRENT
3    0 6442450944 YES UNUSED
4    0 6442450944 YES UNUSED
5    0 6442450944 YES UNUSED
6    0 6442450944 YES UNUSED

6 rows selected.




SQL> alter database drop logfile group 1;
alter database drop logfile group 1
*
ERROR at line 1:
ORA-01624: log 1 needed for crash recovery of instance inforln (thread 1)
ORA-00312: online log 1 thread 1: '/ora/app/oracle/oradata/inforln/redo01.log'


SQL> alter system checkpoint global;

System altered.

SQL>  select group#,sequence#,bytes,archived,status from v$log;

    GROUP#  SEQUENCE#   BYTES ARC STATUS
---------- ---------- ---------- --- ----------------
1   16 52428800 YES INACTIVE
2   17 6442450944 NO  CURRENT
3    0 6442450944 YES UNUSED
4    0 6442450944 YES UNUSED
5    0 6442450944 YES UNUSED
6    0 6442450944 YES UNUSED

6 rows selected.

SQL> alter database drop logfile group 1;

Database altered.

$ rename the redo file

$ mv redo01.log redo01.old.log

SQL> alter database add logfile group 1 '/ora/app/oracle/oradata/inforln/redo01.log' size 6G;

Database altered.

SQL> select group#,sequence#,bytes,archived,status from v$log;

    GROUP#  SEQUENCE#   BYTES ARC STATUS
---------- ---------- ---------- --- ----------------
1    0 6442450944 YES UNUSED
2   17 6442450944 NO  CURRENT
3    0 6442450944 YES UNUSED
4    0 6442450944 YES UNUSED
5    0 6442450944 YES UNUSED
6    0 6442450944 YES UNUSED

6 rows selected.

SQL>

Wednesday, December 28, 2016

ORA-00845: MEMORY_TARGET not supported on this system


While converting Non-RAC to RAC database getting below error.




[oracle@rac01 bin]$ ./rconfig contorac.xml
Converting Database "oratech" to Cluster Database. Target Oracle Home: /ora/orac                         le/product/12.1.0/dbhome_1. Database Role: PRIMARY.
Setting Data Files and Control Files
Adding Trace files
Adding Database Instances
Adding Redo Logs
Enabling threads for all Database Instances
Setting TEMP tablespace
Adding UNDO tablespaces
Setting Fast Recovery Area
Updating Oratab
Creating Password file(s)
Configuring related CRS resources
Starting Cluster Database
<?xml version="1.0" ?>
<RConfig version="1.1" >
<ConvertToRAC>
    <Convert>
      <Response>
        <Result code="1" >
          Got Exception
        </Result>
       <ErrorDetails>
             oracle.sysman.assistants.rconfig.engine.CRSStartupException: PRCR-1079 : Failed to start resource ora.oratech.db
CRS-5017: The resource action "ora.oratech.db start" encountered the following error:
ORA-00845: MEMORY_TARGET not supported on this system
. For details refer to "(:CLSN00107:)" in "/ora/grid/log/rac02/agent/crsd/oraagent_oracle/oraagent_oracle.log".

CRS-2674: Start of 'ora.oratech.db' on 'rac02' failed
CRS-2632: There are no more servers to try to place resource 'ora.oratech.db' on that would satisfy its placement policy
Operation Failed. Refer logs at /ora/oracle/oracle12/cfgtoollogs/rconfig/rconfig_12_28_16_18_43_14.log for more details.


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

Solution:





[oracle@rac01 bin]$ df -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        20G   18G  994M  95% /
tmpfs           2.0G  1.1G  901M  55% /dev/shm
/dev/sda2        96G   27G   66G  29% /ora
/dev/sda3        20G   60M   19G   1% /tmp


# umount tmpfs
# mount -t tmpfs shmfs -o size=4G /dev/shm


# /etc/fstab

# Created by anaconda on Tue Dec 20 17:07:44 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=db2938b3-db31-4abf-ac1e-9e6869f825c9 /                       ext4    defaults        1 1
UUID=ce2cece9-fa18-458c-a384-3fec9b507b2e /ora                    ext4    defaults        1 2
UUID=99e7a8dc-a14a-4a85-ad67-b2459043af3d /tmp                    ext4    defaults        1 2
UUID=c8915969-3315-4ba1-a941-0cc32240707d swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   size=4G        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0


#reboot


Monday, December 26, 2016

Convert non-RAC database to RAC database using rconfig



In $ORACLE_HOME/assistants/rconfig/sampleXMLs directory, there are two templates ConvertToRAC_AdminManaged.xml and ConvertToRAC_PolicyManaged.xml that are used to convert a single instance database to RAC admin managed or policy managed database respectively.
In this article we will convert the single instance database to an admin managed RAC database.

Source Server:

$ORACLE_HOME/assistants/rconfig/sampleXMLs


Change the following parameters according to your environment


Convert verify="ONLY">
<SourceDBHome>/ora/oracle/oracle12/product/12.1.0/dbhome_12</n:SourceDBHome>
<TargetDBHome>/ora/oracle/product/12.1.0/dbhome_1</n:TargetDBHome>
 <SourceDBInfo SID="oratech">
 <Password>afi123</n:Password>
 <Node name="rac01"/>
 <Node name="rac02"/>
 <InstancePrefix>oratech</n:InstancePrefix>
  <SharedStorage type="ASM">
  <TargetFlashRecoveryArea>+DATA</n:TargetFlashRecoveryArea>


[oracle@rac01 bin]$ cat contorac.xml

<?xml version="1.0" encoding="UTF-8"?>
<n:RConfig xmlns:n="http://www.oracle.com/rconfig"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.oracle.com/rconfig rconfig.xsd">
    <n:ConvertToRAC>
<!-- Verify does a precheck to ensure all pre-requisites are met, before the conversion is attempted. Allowable values are: YES|NO|ONLY -->
        <n:Convert verify="ONLY">
<!--Specify current OracleHome of non-rac database for SourceDBHome -->
              <n:SourceDBHome>/ora/oracle/oracle12/product/12.1.0/dbhome_12</n:SourceDBHome>
<!--Specify OracleHome where the rac database should be configured. It can be same as SourceDBHome -->
              <n:TargetDBHome>/ora/oracle/product/12.1.0/dbhome_1</n:TargetDBHome>
<!--Specify SID of non-rac database and credential. User with sysdba role is required to perform conversion -->
              <n:SourceDBInfo SID="oratech">
                <n:Credentials>
                  <n:User>sys</n:User>
                  <n:Password>xyz</n:Password>
                  <n:Role>sysdba</n:Role>
                </n:Credentials>
<!--Specify Windows Secure Oracle Home Credentials if the Oracle Home was installed with Secure User option  -->
<!--
                <n:Credentials>
                  <n:User>UserDomain\SecureHomeUserName</n:User>
                  <n:Password>oracle</n:Password>
                  <n:Role>windows_svc</n:Role>
                </n:Credentials>
-->
              </n:SourceDBInfo>
<!--Specify the list of nodes that should have rac instances running for the Admin Managed Cluster Database. LocalNode should be the first node in this nodelist. -->
              <n:NodeList>
                <n:Node name="rac01"/>
                <n:Node name="rac02"/>
              </n:NodeList>
<!--Specify RacOneNode along with servicename to convert database to RACOne Node -->
              <!--n:RacOneNode  servicename="salesrac1service"/-->
<!--Instance Prefix tag is optional starting with 11.2. If left empty, it is derived from db_unique_name.-->
              <n:InstancePrefix>oratech</n:InstancePrefix>
<!-- Listener details are no longer needed starting 11.2. Database is registered with default listener and SCAN listener running from Oracle Grid Infrastructure home. -->
<!--Specify the type of storage to be used by rac database. Allowable values are CFS|ASM. The non-rac database should have same storage type. ASM credentials are no needed for conversion. -->
              <n:SharedStorage type="ASM">
<!--Specify Database Area Location to be configured for rac database.If this field is left empty, current storage will be used for rac database. For CFS, this field will have directory path. -->
                <n:TargetDatabaseArea>+DATA</n:TargetDatabaseArea>
<!--Specify Fast Recovery Area to be configured for rac database. If this field is left empty, current recovery area of non-rac database will be configured for rac database. If current database is not using recovery Area, the resulting rac database will not have a recovery area. -->
                <n:TargetFlashRecoveryArea>+DATA</n:TargetFlashRecoveryArea>
              </n:SharedStorage>
        </n:Convert>
    </n:ConvertToRAC>
</n:RConfig>
[oracle@rac01 bin]$




[oracle@rac01 bin]$ ps -eaf|grep smon

oracle    3858  2537  0 13:47 pts/13   00:00:00 grep smon
oracle    4695     1  0 Dec21 ?        00:00:38 ora_smon_orasoft1
oracle   16287     1  0 Dec21 ?        00:00:14 asm_smon_+ASM1
oracle   17562     1  0 Dec22 ?        00:00:16 ora_smon_test

[oracle@rac01 bin]$ pwd




[oracle@rac01 bin]$ ./rconfig /ora/oracle/oracle12/product/12.1.0/dbhome_12/assistants/contorac.xml
<?xml version="1.0" ?>
<RConfig>
      <Response>
        <Result code="1" >
          Got Exception
        </Result>
       <ErrorDetails>
Error oracle.sysman.assistants.rconfig.parser.ParserException:File Not Found
       </ErrorDetails>
      </Response>
</RConfig>


I got above error while run the contorac.xml file then I copy the controrac.xml under bin directory and then run the rconfig contorac.xml

$ cd /ora/oracle/oracle12/product/12.1.0/dbhome_12/assistants/rconfig/sampleXMLs

$ cp contrac.xml /ora/oracle/oracle12/product/12.1.0/dbhome_12/bin



[oracle@rac01 bin]$ ./rconfig contorac.xml
<?xml version="1.0" ?>
<RConfig version="1.1" >
<ConvertToRAC>
    <Convert>
      <Response>
        <Result code="0" >
          Operation Succeeded
        </Result>
      </Response>
      <ReturnValue type="object">
There is no return value for this step     </ReturnValue>
    </Convert>
  </ConvertToRAC></RConfig>

[oracle@rac01 bin]$

















• Logs to monitor
– Single instance database alert log file.
– RAC database alert log file.
– /u01/app/oracle/cfgtoollogs/rconfig [records entire operation step-by-step]
– For RMAN log and SQL log, check the respective directories under /u01/app/oracle/cfgtoollogs/rconfig/db





Sunday, December 25, 2016

Cross Platform Transportable Tablespace Migration in Oracle 11g


Transportable Technologies

Transportable Database 

As explained in "Overview of Cross-Platform Data Transport Using Image Copies", you can use the RMAN CONVERT DATABASE command to automate the copying of an entire database from one platform to another. You convert the database data files on either the source or destination platforms.
Before converting the database, see the list of CONVERT DATABASE command prerequisites described in Oracle Database Backup and Recovery Reference. Confirm that you meet all these prerequisites before attempting the procedure in this section.
One prerequisite is that both the source and destination platform must share the same endian format. For example, you can transport a database from Microsoft Windows to Linux for x86 (both little-endian), or from HP-UX to AIX (both big-endian), but not from HP-UX to Linux for x86 (big-endian to little-endian).

Transportable Tablespace

Transportable Tablespaces is a feature designed to move a subnet of one database into another, eve among platform that differ in endian format. The cross-platform capability of transportable tablespace can be used to migrate all user data within a database to new platform with a different endian format
leveraging transportable table spaces in this manner permits a minimal downtime migration to a new platform by a avoiding the time consuming method of unloading all user data from source database and loading it into the target database.


Source Server:
------------------

Solaris 11 - Sparc 64-bit
Database 11.2.0.4


SQL> select d.platform_name,endian_format from v$transportable_platform tp, v$database d WHERE tp.platform_name=d.platform_name;

PLATFORM_NAME
--------------------------------------------------------------------------------
ENDIAN_FORMAT
--------------
Solaris[tm] OE (64-bit) Big


SQL>



Target Server
----------------
Oracle Linux 6 32-bit (x86_64)
Database 11.2.0.4




SQL> select d.platform_name,endian_format from v$transportable_platform tp, v$database d WHERE tp.platform_name=d.platform_name;

PLATFORM_NAME
--------------------------------------------------------------------------------
ENDIAN_FORMAT
--------------
Linux x86 64-bit Little


SQL>



Source Database

We plan to move to three tablespaces EMP,EMP1,USERS

SQL> select name from v$tablespace;

NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
USERS
TEMP
EMP
EMP1

7 rows selected.

SQL>



SQL> execute DBMS_TTS.TRANSPORT_SET_CHECK('USERS,EMP,EMP1',TRUE);

PL/SQL procedure successfully completed.

SQL> SELECT * FROM TRANSPORT_SET_VIOLATIONS;

no rows selected

SQL>


Generate a Transportable tablespace set

SQL> create directory dump_dir as '/ora/export';
SQL>grant read,write on directory dump_dir to system
SQL>alter tablespace users read only;
SQL>alter tablespace emp1 read only;
SQL>alter tablespace emp read only;



Invoke the data pump export utility on the host system an specify which tablespaces are in the trasnportable set.





oracle@afi-ssaerp:~/app/oracle/product/11.2.0/dbhome1104/bin$ ./expdp system/afi123 DUMPFILE=expdat.dmp DIRECTORY=dump_dir TRANSPORT_TABLESPACES=users,emp,emp1 logfile=expdat.log

Export: Release 11.2.0.4.0 - Production on Mon Dec 26 14:08:03 2016

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01":  system/******** DUMPFILE=expdat.dmp DIRECTORY=dump_dir TRANSPORT_TABLESPACES=users,emp,emp1 logfile=expdat.log
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/INDEX/INDEX
Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT
Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/REF_CONSTRAINT
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Master table "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_TRANSPORTABLE_01 is:
  /ora/export/expdat.dmp
******************************************************************************
Datafiles required for transportable tablespace EMP:
  /ora/app/1104/oracle/oradata/oratest/emp.pdf
Datafiles required for transportable tablespace EMP1:
  /ora/app/1104/oracle/oradata/oratest/emp1.pdf
Datafiles required for transportable tablespace USERS:
  /ora/app/1104/oracle/oradata/oratest/users01.dbf
Job "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at Mon Dec 26 14:08:55 2016 elapsed 0 00:00:50

oracle@afi-ssaerp:~/app/oracle/product/11.2.0/dbhome1104/bin$


collect the required  users,roles,grants,profile to create again in the target database.



oracle@afi-ssaerp:~/app/oracle/product/11.2.0/dbhome1104/bin$ ./expdp system/afi123 DUMPFILE=exp_meta_dmp.dmp DIRECTORY=dump_dir full=y include=USER,ROLE,ROLE_GRANT,PROFILE content=METADATA_ONLY

Export: Release 11.2.0.4.0 - Production on Mon Dec 26 14:14:37 2016

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_EXPORT_FULL_01":  system/******** DUMPFILE=exp_meta_dmp.dmp DIRECTORY=dump_dir full=y include=USER,ROLE,ROLE_GRANT,PROFILE content=METADATA_ONLY
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/ROLE
Processing object type DATABASE_EXPORT/SCHEMA/ROLE_GRANT
Master table "SYSTEM"."SYS_EXPORT_FULL_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_FULL_01 is:
  /ora/export/exp_meta_dmp.dmp
Job "SYSTEM"."SYS_EXPORT_FULL_01" successfully completed at Mon Dec 26 14:14:52 2016 elapsed 0 00:00:14

oracle@afi-ssaerp:~/app/oracle/product/11.2.0/dbhome1104/bin$



Convert before transporting the tablespace  set and then convert the datafiles composing the users and emp,emp1 tablespaces.


RMAN convert command is used to do the conversion. Start RMAN and connect to the target database.



$ RMAN target /

RMAN> convert tablespace 'users','emp','emp1' to platform 'Linux IA (32-bit)'

Copy all export move to destination server.



Import folder we have to create.

$ mkdir /ora/import
$chmod 700 /ora/import


$ scp *.* 192.0.0.45:/ora/import


Convert the database files in target machine

$ rman target /

RMAN> convert database '/ora/import/ data_D-ORATEST_I-3466644995_TS-EMP1_FNO-6_01ro4k07' format "/ora/oracle11/app/oracle/oradata/test/users.dbf";


Same steps we have to do to other data files.

import the tablespace set



$./impdp system/afi123 directory=dump_dir dumpfile=exp_meta.dmp.dmp full=y

If above command show error like in my case one users was missing. So I created that missing user in destination server after that I run the above.



 ./impdp system/afi123 DIRECTORY=dump_dir DUMPFILE=expdat.dmp transport_datafiles='/ora/oracle11/app/oracle/oradata/test/emp1.dbf','/ora/oracle11/app/oracle/oradata/test/emp.dbf','/ora/oracle11/app/oracle/oradata/test/user011.dbf'


Same steps u have to do it for other datafiles as well.


Verify the tablespace from destination server.





SQL> select name from v$tablespace;

NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
USERS100
TEMP
EMP
EMP1
USERS

8 rows selected.

SQL>



SQL> alter tablespace users read write;

SQL> alter tablespace emp read write;

SQL> alter tablespace emp1 read write;