Saturday, June 29, 2013

rebuild datapump metadata

Some times, due to some internal errors, datapump utility binaries may get corrupted. In such cases, we can rebuild that using below ways
In Oracle database 10.1 version :
SQL> connect / as sysdba
SQL >@ $ORACLE_HOME/rdbms/admin/catdp.sql – this will install metadata
SQL >@ $ORACLE_HOME/rdbms/admin/dbmspump.sql – this will create DBMS procedures for datapump
In Oracle database 10.2 version :
SQL >@ $ORACLE_HOME/rdbms/admin/catdph.sql
SQL >@ $ORACLE_HOME/rdbms/admin/prvtdtde.plb
SQL >@ $ORACLE_HOME/rdbms/admin/catdpb.sql
SQL >@ $ORACLE_HOME/rdbms/admin/dbmspump.sql
After performing above steps, all the binaries will be re-build. So, it is better to execute utlrp.sql to recompile invalid objects
SQL >@ $ORACLE_HOME/rdbms/admin/utlrp.sql
In Oracle 11g :
SQL >@ $ORACLE_HOME/rdbms/admin/catproc.sql (catproc.sql will take care of all other script execution)
To recompile invalid objects, if any
SQL >@ $ORACLE_HOME/rdbms/admin/utlrp.sql

12C database

12c MOS:
Oracle Database 12c Release 1 (12.1) Upgrade New Features [ID 1515747.1]
NOTE:1520299.1 - Master Note For Oracle Database 12c Release 1 (12.1) Database/Client Installation/Upgrade/Migration Standalone Environment (Non-RAC)
NOTE:1493645.1 - Oracle Database 12c Release 1 (12.1) DBUA : Understanding New Changes With All New 12.1 DBUA 
NOTE:1503653.1 - Complete Checklist for Manual Upgrades to Oracle Database 12c Release 1 (12.1)
Oracle Database 12c Release 1 (12.1) Upgrade New Features [ID 1515747.1]
RMAN RECOVER TABLE Feature New to Oracle Database 12c [ID 1521524.1]
How to Merge Multiple Partitions in Oracle 12C [ID 1482263.1]
How to Create Interval-Reference Partitioned Tables in Oracle 12c [ID 1519042.1]

Friday, June 28, 2013

AWR report’s use in RAC Env

Generate AWR reports for any instance in the cluster:
Run the awrrpti script from $ORACLE_HOME/rdbms/admin/
as a sys user. The script will ask you for the output format of the report (HTML or TEXT), the instance number, the the number of days (n) will result in the most recent
(n) days of snapshots being listed (If you hit enter, you will get all the available snapshots listed), begin and end snapshot interval Ids …

 Generate AWR Cluster aggregated statistics from all the instances:
Run the awrgrpt script from $ORACLE_HOME/rdbms/admin/ as a sys user. The script will ask you for the output format of the report (HTML or TEXT), the the number of days (n) will result in the most recent
(n) days of snapshots being listed (If you hit enter, you will get all the available snapshots listed), begin and end snapshot interval Ids …

 Generate AWR Global Cluster Difference Report:
Run the awrgdrpt.sql script from $ORACLE_HOME/rdbms/admin/ as a sys user. The script will ask you for the output format of the report (HTML or TEXT), the the number of days (n) will result in the most recent
(n) days of snapshots being listed (If you hit enter, you will get all the available snapshots listed), begin and end snapshot interval Ids of the first and second pair diff intervals…
This report compares the statistic results of differences between two different snapshot intervals, for the whole cluster database.


Generate AWR Report Single Select Statement:
Run the awrsqrpt.sql script from $ORACLE_HOME/rdbms/admin/ as a sys user. The script will ask you for the output format of the report (HTML or TEXT), the the number of days (n) will result in the most recent
(n) days of snapshots being listed (If you hit enter, you will get all the available snapshots listed), begin and end snapshot interval Ids intervals and the SQL_ID for the specific SELECT statement …





How to restrict user not to run any dml from sql prompt(backend),but allow user to run dml from application?

Today one dba  asked me -
How to restrict user not to run any dml from sql prompt(backend),but allow user to run dml from application?

-
I replyed him below-

If You meant to say that privileges user should not change the data through back end using SQLPLUS BUT the same user can insert update delete through application level entry.

Then you can use PRODUCT_USER_PROFILE table to disable certain SQL PL/SQL and SQL*Plus commands in the SQL*Plus environment on a per user basis except system user.
 This will never going to effect user's privileges at application level.

If this table is not installed then you can create PRODUCT_USER_PROFILE by running the command file named PUPBLD.sql.as SYSTEM USER. The exact format of the file extension and the location of the file are system dependent. Mostly this table are installed by default just check first.

These tables allow SQL*Plus to disable commands per user. The tables
are used only by SQL*Plus and do not affect other client tools that access the database.


example:- login in as System user

SQL> CONN SYSTEM/pwd
Connected.
SQL> insert into product_user_profile
(
PRODUCT ,
USERID ,
ATTRIBUTE ,
SCOPE ,
NUMERIC_VALUE,
CHAR_VALUE ,
DATE_VALUE ,
LONG_VALUE
)
values
('SQL*PLUS','SCOTT','INSERT',NULL,NULL,'DISABLED',NULL,NULL);

1. row created.

NOW CONNECT TO HR/HR

SQL> conn HR/HR
Connected.
SQL> insert into test_table values('testing');
SP2-0544: Command "insert" disabled in Product User Profile.

likewise you can add more entry for update,delete and even begin and end keyword of pl/sql command which totally disallowed using of pl/sql block.


Wednesday, June 26, 2013

skip blank lines in between SQL statements in SQL*Plus?

If a SQL script file has blank lines in between SQL statements one may see errors when executing the script in SQL*Plus so if one would like to ignore the blanklines in SQL*Plus one can ignore them by set blanklines on.
Example:
SQL> select object_name
2
SQL> from dba_objects;
SP2-0734: unknown command beginning “from dba_o…” – rest of line ignored.
SQL> set sqlblanklines on
SQL> select object_name
2
3 from dba_objects
4 where rownum < 3;
OBJECT_NAME
——————————————————————————–
ICOL$
I_USER1
– Disable blank lines in between SQL statements
SQL> set sqlblanklines off


How to force a trace file to be created when an ORA error occurs?

There was an issue we ran into where one of the users ran out temporary tablespace (TEMP) we had message in the database alert log that there oracle couldn’t extend temporary tablespace and we couldn’t find the cause and user who ran into the issue. So turning on event for the error oracle will create a trace file which will contain user, machine, os, SQL which will allow DBA to find additional information.
Example:
– ORA-1652: unable to extend temp .. (for temp tablespace)
SQL> ALTER system SET EVENTS ’1652 TRACE NAME ERRORSTACK LEVEL 3′;
It will write to the alert.log
Tue Jul 21 11:04:45 2009
Errors in file /u01/admin/TESTDB/udump/testdb_ora_17682588.trc:
ORA-1652: unable to extend temp segment by 128 in tablespace TEMP
The trace file would contain the following information including the SQL statement:
….
oct: 2, prv: 0, sql: 7000000593f3dc8, psql: 700000057c3ec30, user: 420/TEST
O/S info: user: ajaffer, term: MYCOMPUTER, ospid: 3684:2444, machine: MYCOMPUTERNAME
To turn trace off one would run the following SQL:
SQL> ALTER system SET EVENTS ’1652 TRACE NAME ERRORSTACK OFF’;
If one would like to set event in the spfile, you can set by executing the DDL below. If there are multiple events then it can be set by they have to be “:” separated. In the example below event is set for ORA-01653 and ORA-01652
SQL> alter system set event=’1653 TRACE NAME ERRORSTACK LEVEL 3:1652 TRACE NAME ERRORSTACK LEVEL 3′ scope=SPFILE;
To clear the event in the spfile, you can execute the following SQL ALTER SYSTEM SET EVENT=” SCOPE=spfile;
One can similar turn trace on for various ora errors but be aware that some of them by caused internally from within Oracle example ORA-604 which you may not want to turn on event for.

Tracing a session via a logon trigger

Awhile back I found a tip which has come in handy quite a few times. Just recently I was troubleshooting an ORA-03124 error which occurred during a run of a BI tool. The BI tool spawns many sessions while gathering and processing data so Its not practical to sit there, grab the sessions information and turn on tracing manually.

CREATE OR REPLACE TRIGGER ON_LOGON_QC
AFTER LOGON ON DATABASE
WHEN ( USER = 'QC' )
BEGIN
execute immediate 'alter session set events ''10046 trace name context forever, level 12''';
EXCEPTION
WHEN OTHERS THEN
NULL;
END;

Of course, don't forget to disable it after!

Important Initialization parameters that affect the CBO

Important Initialization parameters that affect the CBO
Apart from generating statistics, the setup of the below mentioned parameters play a very crucial role in dictating how your system will work. Setting these will depend a lot on what kind of environment you want to create, Online, Batch processing, Data warehousing or a combination of more than one.

1) OPTIMIZER_MODE
This will decide the mode in which the optimizer engine should run in. Valid values are RULE, CHOOSE, ALL_ROWS, FIRST_ROWS (_n).
Optionally, the OPTIMIZER_MODE can be set to CHOOSE. This is kind of an intermediate option between RBO and CBO. In fact, it tries to run the query in either CBO or RBO depending on the availability or unavailability of statistics. Therefore, if the tables present in the query have statistics generated on them, CBO (ALL_ROWS only) is preferred or RBO is taken up.
e.g.: optimizer_mode = first_rows
For an OLTP system, FIRST_ROWS would be the ideal option for fast response time. ALL_ROWS is meant for batch-oriented applications. Note, a plan that produces the first n rows with the fastest response time might not be an optimal plan if requirement is to obtain the entire result, so decide as per the need of the application

2) OPTIMIZER_INDEX_COST_ADJOptimizer_Index_Cost_Ad takes a value between 1 and 10000 (default 100). Setting this value makes the index more or less friendly to the optimizer. For example setting it to 50 tells the optimizer that an execution plan that uses index(es) is half as expensive as other execution plans that are not using them. The lower the value (less than 100), the less full table scan executions will take place in the system.
Use of indexes in OLTP is a crucial factor for deciding the response time, but sometimes, full table scans provide better throughput. Nested loop joins are influenced by this parameter value. Set this parameter to a value that is optimal for your application. I recommend set this parameter between 10 - 20 for OLTP and 50 for DSS Systems..
If you are having slow performance because the CBO first_rows optimizer mode is favoring too many full-table scans, you can reset the optimizer_index_cost_adj parameter to immediately tune all of the SQL in your database to favor index scans over full-table scans. This is a "silver bullet" that can improve the performance of an entire database in cases where the database is OTLP and you have verified that the full-table scan costing is too low.
3) OPTIMIZER_INDEX_CACHING
This tells optimizer to favor nested loops and IN-list iterators over sort-merge and hash joins. The default value is 100 and makes nested loops and IN-list operator look less expensive and more appealing to Optimizer. The value basically indicates the percentage of index blocks that the optimizer should assume are present in cache. 
I recommend set this parameter to 85.

4) DB_FILE_MULTIBLOCK_READ_COUNT
This parameter determines the number of database blocks read in one input/output operation during a full table scan. The value set is used in computing the cost of full table scans. OLTP systems will not benefit by setting a high value for this parameter as the computed cost for full table scan execution plans would reduced. The maximum size is Operating system dependent.
e.g.: db_file_multiblock_read_count = 1 (may be set to a higher value)

5) SORT_AREA_SIZE
This parameter defines the maximum memory space allocated per user process that requires sorting of data and for insert and updates to bitmap indexes. Optimizer uses the set value for determining the cost of sorting in a query. This defaults to 64K. Normally a size of 64K to 1M is appropriate for OLTP systems.
Sort-merge joins are influenced by this parameter value. The bigger the size the more appealing will be sort-merge joins over nested-loop and hash joins. The lower the size the more sorting will take place in temporary segments. So assign a value that has been evaluated for your setup.
Oracle recommends the use of PGA_AGGREGATE_TARGET instead of this parameter from Oracle 9i.

6) SORT_MULTIBLOCK_READ_COUNT
This specifies the number of database blocks to be read each time a sort performs a read from a temporary segment. The default value is 2. General recommendation is to keep the default value. However, if you intend to hike up the SORT_AREA_SIZE considerably, you may evaluate the improvement by changing this parameter.
e.g.: sort_multiblock_read_count = 2

7) HASH_JOIN_ENABLED
Hash joins are available only in CBO. In hash joins, a hash table is created on the join key of the smallest sized table. It then joins the other tables to find the match. Hash joins may prove to be faster than other type of joins in some conditions, especially when the index is missing or search criteria is not very selective. Hash joins require a large amount of memory as the hash tables are retained; this may sometimes result in memory swapping.
Nested-loop joins return the first row faster than sort-merge and hash joins and are preferred for OLTP, but other types of joins cannot be ignored for running other aspects of the applications.
e.g.: hash_join_enabled = true

8) HASH_AREA_SIZE
This specifies the maximum amount of memory in bytes to be used for a hash join per process. It is defaulted to 2 times SORT_AREA_SIZE.
Oracle recommends the use of PGA_AGGREGATE_TARGET instead of this parameter from Oracle 9i.
e.g.: hash_area_size = 2097152
Setting this to a very low number may sometimes result in the following error.
ORA-6580: Hash Join ran out of memory while keeping large rows in memory.

9) HASH_MULTIBLOCK_IO_COUNT
This specifies how many sequential blocks a hash join reads and writes in one Input/Output activity. Oracle recommends not changing or assigning a value to this parameter; this will let oracle decide on the appropriate value for each individual query. In such casees, the value of the parameter will appear as 0 in the V$PARAMETER view.
This parameter is renamed to _HASH_MULTIBLOCK_IO_COUNT as of Oracle 9i.
e.g.: hash_multi_block_io_count = 0

10) BITMAP_MERGE_AREA_SIZE
This parameter is relevant for systems using bitmap indexes. It specifies the amount of memory Oracle uses to merge bitmaps retrieved from a range scan of a bitmap index. The default value is 1 MB, which is considered sufficient for most setups.
Oracle recommends use of PGA_AGGREGATE_TARGET instead of this parameter from Oracle 9i.
e.g.: bitmap_merge_area_size = 1048576

11) QUERY_REWRITE_ENABLED
This parameter is relevant for systems using Materialized views, Function based indexes and stored outlines. Setting this parameter enables query rewrite for the database. The materialized views should also be query rewrite enabled to allow the optimizer to redirect a query to it rather than the actual tables listed in the FROM clause. Query rewriting is internally done by the optimizer based on what results are expected and whether these are already present in materialized view form.
e.g.: query_rewrite_enabled = true
12) QUERY_REWRITE_INTEGRITY
This parameter determines the extent to which the optimizer must enforce query rewriting to Materialized views. This determines the accuracy of the query rewrite. It can be set to ENFORCED, TRUSTED or STALE_TOLERATED. ENFORCED option uses Materialized views if they contain fresh data, thus guarantying the integrity and consistency of data. TRUSTED uses relationships that have been defined in the system for rewriting the query. STALE_TOLERATED allows the use of relationships that are not enforced and may use stale data. For OLTP systems, ENFORCED would be the ideal setup, as reports need to be up-to-date.
e.g.: query_rewrite_integrity = enforced
13) ALWAYS_ANTI_JOIN
This parameter specifies the join method for anti-joins, for example when a NOT IN operator is present in your query. It can be set to NESTED_LOOPS, MERGE or HASH. It is defaulted to NESTED_LOOPS in Oracle 8i and CHOOSE in Oracle 9i.
This parameter is renamed to _ALWAYS_ANTI_JOIN as of Oracle 9i.
e.g.: always_anti_join = nested_loops

14) ALWAYS_SEMI_JOIN
This parameter specifies the join method for semi-joins. These types of joins are carried out by Optimizer after transforming a query. In such joins, duplicate values from the inner table are removed and then the type of join specified in the parameter is used to perform a semi-join. It can be set to NESTED_LOOPS, MERGE or HASH. In Oracle 8i, it is defaulted to STANDARD and in Oracle 9i it is defaulted to CHOOSE, to pick up an appropriate join.
This parameter is renamed to _ALWAYS_SEMI_JOIN as of Oracle 9i.
e.g.: always_semi_join = nested_loops

15) STAR_TRANSFORMATION_ENABLED
This specifies whether query transformation will be applied to star queries. It can be set to TRUE, FALSE or TEMP_DISABLE (transformation will take place but will not use temporary tables). I presently set it to FALSE due to some known issues of sub-optimal queries being generated. If you intend to use this, please upgrade your version to 8.1.7.4 and above.
e.g.: star_transformation_enabled = false

16) PARALLEL_BROADCAST_ENABLED
This parameter refers to parallel executions in cluster databases. It is meant for improving hash and sort-merge join operations where a very large result set is joined with a very small result set. When this option is enabled, the optimizer broadcasts a copy of all rows in the smaller result set to all cluster databases that are processing some rows of the larger result set.
It is obsolete in release 9.2.0.
e.g.: parallel_broadcast_enabled = false

17) OPTIMIZER_DYNAMIC_SAMPLING
This parameter is introduced in release 9i. It is meant for situations where tables are not analyzed. As CBO depends heavily on statistics, the parameter tells the optimizer to sample the unanalyzed tables that are being used in a query. A level of 0 to 10 can be specified, the higher the value the more time optimizer spends in sampling.
e.g.: optimizer_dynamic_sampling = 1
18) PARTITION_VIEW_ENABLED
This parameter is meant for backward compatibility to support partition views. Oracle recommends use of partition tables rather than partition views. If you are migrating to CBO, chances are that you may not be using partition views.
e.g.: partition_view_enabled = false

19) CURSOR_SHARING
This parameter determines what kind of SQL statements can share the same cursor. It can be set to FORCE, SIMILAR or EXACT. FORCE will try to squeeze statements that may differ in some literals to share the same cursor. SIMILAR is somewhat the same but will try to maintain the plan optimization for identical statements. EXACT allows statements with exact identical text to share a cursor.
Using FORCE may sometimes result in unexpected results.
e.g.: cursor_sharing = exact
20) PGA_AGGREGATE_TARGET
Introduced in Oracle 9i, this parameter specifies the aggregate PGA memory available to all server processes attached to an instance. This parameter can be set for automatic sizing of SQL working areas. It replaces other existing parameters like SORT_AREA_SIZE, BITMAP_MERGE_AREA_SIZE and HASH_AREA_SIZE.
It can be set to a value between 10 MB to 4000 GB, depending on the setup requirement. 
1- Make a first estimate for PGA_AGGREGATE_TARGET  based on the following rule:
    PGA_AGGREGATE_TARGET  = (Total Physical Memory * 0.16)    - For OLTP systems  (16% of Server Physical Mem)
    PGA_AGGREGATE_TARGET  = (Total Physical Memory * 0 .4  )   - For DSS systems   (40% of Server Physical Mem)

Oracle Database 12c R1 (12.1.0.1.0) is finally released!

:)

Tuesday, June 25, 2013

Configure ssh certificate for password less login

It is not very difficult but every time I want to create and populate an ssh certificate I have to search for it. So I will show how to create and populate an ssh certificate for password less login over ssh.
And if we have a look to man page of ssh (see below), it sounds really simple. Just create your key, copy the key to destination and register in authorized_keys. But how to do that in a simple way?
Steps to do:
  • create a key:
    eeelin:~$ ssh-keygen #(Don’t enter a password for password less login)
  • copy the key to remote:
    eeelin:~$ cat ~/.ssh/id_rsa.pub | ssh user@host ‘cat >> ~/.ssh/authorized_keys’
To use certificates would be much more secure than use an ssh connection with password. If you use a certificate there is a guarantee it is the owner of this certificate. And if you provide a password while generating the certificate it would improve security again. And you don’t have to remember all the original passwords.
Another reason to use a certificate is, an application which has to connect over ssh. It would be possible just to put the certificate into the application and nobody has to know the password.

How to Save Oracle Database license costs

First, understand how Oracle is now licensed.
Oracle has switched pricing the database from total number of sockets to total number of CORES or CPUs.
This switch has a hidden cost many do not see when upgrading hardware because the newer intel® processors have more cores on them. Therefore, updating system with just newer intel® chips can cause license cost of Oracle to skyrocket. 
Do you really need to spend 10 times more on database license costs? Is your performance going to go up 10 times?
At Tuning Ace we like to offer you the possibility of not having to spend extra on database license costs. We like to offer the possibility that your current hardware is sufficiently sized today and to run your applications. We like to help you see that tuning your existing system can be the solution today with out new hardware. We also offer today the Tuning Ace Tuning Suite®, a product that is designed to identify solutions to performance today.

How to Increase Website Revenue without more hardware.
Let's face it, website revenue is based on how quickly orders can be pushed through your systems. Throwing hardware at the system will not increase the response time users see.
Questions:
- What is your response time? ( THis should be under 3 seconds )
- How many orders per minute can your process?
- Does the fulfillment process slow down the website?
- Do you want your ATG website to run faster?

From the users point of view:

- How long does it take to add an item to the shopping cart? Does the time vary over the day?
- How long does does it take to check out?

Will your systems handle the load on black friday or cyber monday?

Do you think adding nodes or adding CPUs to the system will improve user experience? The
We know, if your site is taking over 3 seconds to respond to the user, you are loosing customers and revenue.
We know, Switching from a single node database to an RAC environment can actually slow user response time.
We also know, Adding nodes in an RAC environment can actually slow user response time and lower your revenue.
Any change to your application or system that slows the time it take a user to add an item to the shopping cart lowers your revenue.



Thursday, June 20, 2013

Download PuTTY


PuTTY is an SSH and telnet client, developed originally by Simon Tatham for the Windows platform. PuTTY is open source software that is available with source code and is developed and supported by a group of volunteers.
For download click here.

Saturday, June 15, 2013

log files for OPatch and OUI

OPatch (Common for Windows and Unix)

OPatch version - 1.0.0.0.XX. (Oracle RDBMS -9.2.0.X.X and 10.1.0.X.X )

In the list below, locate the command you executed. The location of the log is listed after the command.

1) opatch lsinventory -detail
<ORACLE_HOME>/.patch_storage/LsInventory__<timestamp>.log


2) opatch lsinventory -all
<ORACLE_HOME>/.patch_storage/LsInventory__<timestamp>.log


3) opatch apply
<ORACLE_HOME>/.patch_storage/<ID of patch>/Apply_<ID of patch>_<timestamp>.log


4) opatch rollback -id <ID of patch>
<ORACLE_HOME>/.patch_storage/<ID of patch>/RollBack__<ID of patch>_<timestamp>.log

Steps to relink oracle binary with RAC env

Execute the following on all nodes where the ORACLE_HOME exists:

1. Log in as the ORACLE_HOME owner.

2. Stop all resources (database, listener, ASM etc) that's running from the home. When stopping database, use NORMAL or IMMEDIATE option.

3. If relinking 11gR2 Grid Infrastructure home, unlock GI home as root: $GRID_HOME/crs/install/rootcrs.pl -unlock

4. Execute the following to relink:
  cd $ORACLE_HOME/rdbms/lib
  make -f ins_rdbms.mk rac_on ioracle

If interconnect is infiniband and RDS protocol is being used instead of UDP:
  cd $ORACLE_HOME/rdbms/lib
  make -f ins_rdbms.mk ipc_rds ioracle

Caution: confirm infiniband interconnect and RDS protocol before executing it
Note: If you are changing more than 1 home, repeat the make command for all homes.

5. If relinking 11gR2 Grid Infrastructure home, lock GI home as root: $GRID_HOME/crs/install/rootcrs.pl -patch

To check whether a running instance is a RAC instance :

Multiple options here:

1. Check sqlplus banner (Applicable to Windows):

$ORACLE_HOME/bin/sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Fri Dec 26 12:11:13 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

A RAC instance will show "Real Application Clusters" option in the banner.

2. Check whether lmon background process exists for the instance

ps -ef| grep lmon | grep <ORACLE_SID>
oracle   627     1  0   Apr 15     ?  1:02 ora_lmon_racd

Only RAC instance has lmon background process.

3. Check cluster_database parameter

SQL> show parameter cluster_database

Output "true" means it's RAC instance but this is not reliable as a RAC instance may have cluster_database set to false during maintenance period.





Relinking Oracle Software on UNIX

Relinking Oracle manually is suggested under the following circumstances
(even though the OS vendor may not require it):

- An OS upgrade has occurred.
- A change has been made to the OS system libraries. This can occur during 
the application of an OS patch.
- A new install failed during the relinking phase.
- Individual Oracle executables core dump during initial startup.
- An individual Oracle patch has been applied (however, explicit relink 
instructions are usually either included in the README or integrated into 
the patch install script)  




Manually Removing all Oracle Components on Microsoft Windows Platforms

A. Removing Components on Windows 32bit and 64bit (All Versions).
---------------------------------------------
To remove all Oracle components from a computer on Windows 32bit and 64bit (All Versions):

1.   Check privileges:
     -----------------
1.a. Ensure you are logged in as a user with Administrator privileges. 


2.   Stop all Oracle services (if any are running):
     ----------------------------------------------
2.a. NT: Choose Start > Settings > Control Panel > Services. 
     Other Versions of Windows: Right click My Computer > Manage > Services and Applications > 
           > Services
 
2.b. If any Oracle services (their names begin with Oracle) exist and have 
     the status Started, select the service and click Stop. 

2.c. Click Close to exit the Services window. 

2.d. Close the Control Panel/Computer Management window.


3.   Remove the entries in the Windows registry:
     -------------------------------------------
3.a. Start the registry editor: 
     Choose Start > Run > regedit 

     Note: On Windows NT you can use regedt32 instead. The searching 
           capabilities of regedt32 is limited compared to regedit. It will be
           needed to be able to edit 32-bit entries in the registry. Since we 
           are not going to update any 32-bit entry it is not needed.


3.b. Go to HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE 
     Note the value of the key INST_LOC, this is the location of the 
     Oracle Universal Installer (OUI).  The default location is 
     C:\Program Files\Oracle\Inventory.  If this value is different, make 
     note of it, so we can delete these files later.
     Delete this ORACLE key. 

3.c. Go to HKEY_LOCAL_MACHINE\SOFTWARE\ODBC and expand all subkeys and
     remove all keys under here which are related with the
     "Oracle ODBC Driver"

3.d. Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services and remove 
     all keys under here that begin with ORACLE or ORAWEB. 

3.e. Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\...
     ...\Application  and remove all keys under here that begin with ORACLE.

3.f. Go to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\...
     ...\Uninstall  and remove any entries related to Oracle.  

3.g. Go to HKEY_CLASSES_ROOT, remove all keys that begin with Ora or ORCL
     (e.g. Oracle..., ORADC..., ORAMMC..., OraOLE..., OraPerf... and ORCL...).

3.h. Go to HKEY_LOCAL_MACHINE\SOFTWARE\Classes, remove all keys that begin 
     with Ora or ORCL
     (e.g. Oracle..., ORADC..., ORAMMC..., OraOLE..., OraPerf... and ORCL...).

3.i. Go to HKEY_CURRENT_USER\Software\Oracle, delete this ORACLE key.

3.j. Go to HKEY_USERS\…\Software\Oracle, delete this ORACLE key.

3.k. Close the registry. 


4.   Clean up the environment settings:
     ----------------------------------
4.a. NT: Choose Start > Settings > Control Panel > System > Environment tab
     Other Windows Versions:  Right Click My Computer > Select Properties > Click on the Advanced Tab > Click on 
     Environment Variables Button
  
4.b. At "System Variables" click on the variable PATH in order to modify 
     the value. For example, you may see a path similar to this one: 
     C:\ORACLE\ORA81\BIN;C:\PROGRAM FILES\ORACLE\JRE\1.1.7\BIN 

4.c. If an %ORACLE_HOME% was installed, remove this %ORACLE_HOME%\BIN path.

4.d. If JRE was installed by Oracle, remove the JRE path.

4.e. If there is a CLASSPATH variable under "System Variables", first make 
     note of the path defined, then delete it.  This variable can be added 
     back at a later date if needed.

4.f. Check if there are any other Oracle variables set in "System Variables", 
     ORACLE_HOME, ORACLE_SID, TNS_ADMIN, JSERV or WV_GATEWAY_CFG.  If these 
     exist, delete them also.

4.g. Click on APPLY and OK.

4.h. Close the Window.


5.   Delete the software and icons:
     ------------------------------
5.a. NT: Choose Start > Programs > Windows NT Explorer.
     Other Windows Versions:  Choose Start > Programs > Accessories > Windows Explorer.

5.b. NT: Go to %SystemDrive%\WINNT\PROFILES\ALL USERS\START MENU\PROGRAMS
     Other Windows Versions: Go to %SystemDrive%\DOCUMENTS AND SETTINGS\ALL USERS\...
           ...\START MENU\PROGRAMS
       Note 1: These locations depend on whether OS was upgraded from NT, or 
               this was a fresh install of 2000/XP.
       Note 2: To locate your System Drive, type in DOS-box: echo %SystemDrive%

     and delete the following icons: 
     - Oracle Installation Products 
     - PRODUCT_NAME - HOME_NAME  e.g.
          Oracle for Windows NT - Dev6i
          Oracle Reports 6i - Dev6i
          Oracle Olap Client 2.2 - Dev6i
          Oracle9i Lite
          Oracle - OraHome92


5.c. Go to %SystemDrive%\Program Files\Oracle or the location of INST_LOC as
     noted earlier in step 3.b. and delete this directory. 
     Note: In order to successfully delete all files, you may have to reboot
           your computer first, in order to clear Operating System locks 
           on those files.

5.d. Go to the temporary directory and delete all files and directories in 
     here (see note in 5.c.).
     NT: %SystemDrive%\Temp
     Other Windows Versions: 
       %SystemDrive%\Documents and Settings\<username>\Local Settings\Temp\ 

5.e. Go to the drive where the Oracle software is installed on your machine
     and delete all ORACLE_BASE directories on your hard drive (see note in 
     5.c.).

5.f. Close the Windows Explorer / Windows NT Explorer.


6.   Finish the removal:
     -------------------
6.a. Empty the recycle bin
     Right click on recycle bin > Empty Recycle Bin.

6.b. Reboot your computer.

6.c. Optionally: If you are on Windows 2000 or XP run the System Defragmenter 
     utility:
     - from Control Panel, select Administrative Tools > Computer Management
     - expand Storage, then select Disk Defragmenter
     - highlight each virtual drive, in turn, and click Defragment
     - reboot your computer when finished.


B. Removing Components on Windows 95 or Windows 98.
---------------------------------------------------
To remove all Oracle components from a computer on Windows 95/Windows 98:

1.   Remove the entries in the Windows registry:
     -------------------------------------------
1.a. Start the registry editor at the MS-DOS command prompt: 
     C:\> REGEDIT

1.b. Go to HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE 
     Note the value of the key INST_LOC, this is the location of the Oracle 
     Universal Installer.  The default location is 
     C:\Program Files\Oracle\Inventory
     If this value is different, make note of it, so we can delete these files
     later. Delete this ORACLE key. 

1.c. Go to HKEY_LOCAL_MACHINE\SOFTWARE\ODBC and expand all subkeys and
     remove all keys under here which are related with the
     "Oracle ODBC Driver".

1.d. Go to: 
     HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
     and remove any entries related to Oracle.  

1.e. Go to HKEY_CLASSES_ROOT, remove all keys that begin with Ora or ORCL
     (e.g. Oracle..., ORADC..., ORAMMC..., OraOLE..., OraPerf... and ORCL...).

1.f. Go to HKEY_LOCAL_MACHINE\SOFTWARE\Classes, remove all keys that begin 
     with Ora or ORCL
     (e.g. Oracle..., ORADC..., ORAMMC..., OraOLE..., OraPerf... and ORCL...).

1.g. Go to HKEY_CURRENT_USER\Software\Oracle, delete this ORACLE key.

1.h. Go to HKEY_USERS\…\Software\Oracle, delete this ORACLE key.

1.i. Close the registry. 


2.   Clean up the environment settings:
     ----------------------------------
2.a. Open your AUTOEXEC.BAT with an editor to modify the PATH variable.
     For example, you may see a path similar to this one: 
     C:\ORACLE\ORA81\BIN;G:\PROGRAM FILES\ORACLE\JRE\1.1.7\BIN .

2.b. If an %ORACLE_HOME% was installed, remove this %ORACLE_HOME%\BIN path.

2.c. If there is a CLASSPATH variable set in the AUTOEXEC.BAT, first make note
     of the path defined, then delete it.  This variable can be added back at
     a later date if needed.

2.d. If JRE was installed by Oracle, remove the JRE path.

2.e. Save the AUTOEXEC.BAT file and close the edit.


3.   Delete the software and icons:
     ------------------------------
3.a. Choose Start > Programs > Windows Explorer.

3.b. Go to SYSTEM_DRIVE:\WINDOWS\START MENU\PROGRAMS
     and delete the following icons: 
     - Oracle - HOME_NAME 
       where HOME_NAME is the previous Oracle home name. 
     - Oracle Installation Products 

3.c. Go to SYSTEM_DRIVE:\Program Files\Oracle or the location of INST_LOC as
     noted earlier in step 1.b and delete this directory.
 
3.d  Go to SYSTEM_DRIVE:\Temp and delete all files and directories in here.

3.e. Go to the drive where the Oracle software is installed on your machine
     and delete all ORACLE_BASE directories on your hard drive.

3.f. Remove any Oracle-related .INI files that may exist in the Windows 
     directory. The Windows directory may be found by entering 
     "echo %WINDIR%" from a command prompt. 
     Typical Oracle .INI files include ORADIM73.INI, ORADIM80.INI, 
     ORACLE.INI, ORAODBC.INI
 
3.g. Close the Windows Explorer.


4.   Finish the removal:
     -------------------
4.a. Empty the recycle bin
     Right click on recycle bin > Empty Recycle Bin

4.b. Reboot your computer.

Friday, June 14, 2013

Disable USB ports on Windows PC via Registry

    1. Click on Start.
    2. Click on Run. If you cannot find RUN, type it in the search box.
    3. Type "regedit" without quotes. This will launch the Registry Editor.
    4. Navigate to  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\usbstor.
    5. In the work area, double click on Start.
    6. In the Value Data box, enter 4.
    7. Click on OK.
    8. Close Registry Editor and refresh your desktop.
    9. To re-enable access to your USB ports, enter 3 in the Value Data box in Step 6.

Tuesday, June 11, 2013

Display TIMESTAMP of deteled files or folder in linux

Typically when you type history from command line, it displays the command# and the command. For auditing purpose, it may be beneficial to display the timestamp along with the command as shown below.

[oracle@micro ~]$ export HISTTIMEFORMAT='%F  %T'

[oracle@micro ~]$ history |grep rm
   26  2013-06-11  06:06:34cd rmn
   28  2013-06-11  06:06:34cd rman/
   34  2013-06-11  06:06:34cat rman target / log=/shared/backup_arch/Restor_rman.log << EOF
   35  2013-06-11  06:06:34cat rman.log
   36  2013-06-11  06:06:34cat rman.trc
   45  2013-06-11  06:06:34cat rmna.sh
   49  2013-06-11  06:06:34cd rman/
   52  2013-06-11  06:06:34rm -fr *
   57  2013-06-11  06:06:34 rman target /
   65  2013-06-11  06:06:34  rman target /
   67  2013-06-11  06:06:34 rman target /
   81  2013-06-11  06:06:34  rman target /
   91  2013-06-11  06:06:34rman target/
  114  2013-06-11  06:06:34rm -v fro_ac_0521.gz fro_ac_20130525.dmp fro_ac_0523.gz
  117  2013-06-11  06:06:34cd /backup/rman/
  133  2013-06-11  06:06:34cd rman_bakup_piece/
  137  2013-06-11  06:06:34cat rman.log
  138  2013-06-11  06:06:34cat rmna.sh
  139  2013-06-11  06:06:34cat rmna.sh
  141  2013-06-11  06:06:34rm -fr *
  175  2013-06-11  06:06:34rmna
  176  2013-06-11  06:06:34rman
  178  2013-06-11  06:06:34rman
  201  2013-06-11  06:06:34scp 172.16.0.218:/shared/backup_arch/rman_bakup_piece/* .
  213  2013-06-11  06:06:34rm -fr *
  221  2013-06-11  06:06:34rm /crd01/oradata/OTOWNPRD/control01.ctl
  222  2013-06-11  06:06:34rm /crd02/oradata/OTOWNPRD/control02.ctl
  223  2013-06-11  06:06:34rm /crd03/oradata/OTOWNPRD/control03.ctl
  235  2013-06-11  06:06:34scp 172.16.0.218:/shared/backup_arch/rman_bakup_piece/OTOWNPRD_arch* .
  257  2013-06-11  06:06:34rman
  260  2013-06-11  06:06:34rman
  277  2013-06-11  06:06:34rman target/
  332  2013-06-11  06:06:34rm -fr test_*
  337  2013-06-11  06:06:34rm -fr *.dmp
  398  2013-06-11  06:06:34rm -rf adump/ cdump/ udump/
  408  2013-06-11  06:06:34rm -rf *
  474  2013-06-11  06:06:34rm *
  479  2013-06-11  06:06:34rm -v alert_reportdb.log
  489  2013-06-11  06:06:34rm *
  557  2013-06-11  06:06:34rm -fr OTOWNPRD_1_2*
  631  2013-06-11  06:06:34cd dirprm
  633  2013-06-11  06:06:34vi rep1.prm
  634  2013-06-11  06:06:34cat rep1.prm
  636  2013-06-11  06:06:34cat load2.prm
  637  2013-06-11  06:06:34cat jagent.prm
  675  2013-06-11  06:06:34cd dirprm
  705  2013-06-11  06:06:34rm -fr *
  731  2013-06-11  06:06:34cd /shared/oradata/dirprm
  733  2013-06-11  06:06:34cat jagent.prm
  743  2013-06-11  06:06:34cd dirprm
  748  2013-06-11  06:06:34mkdir -p /shared/oradata/dirprm/ex
  822  2013-06-11  06:06:34cd dirprm
  827  2013-06-11  06:06:34cd ../load2.prm
  828  2013-06-11  06:06:34cat  ../load2.prm
  829  2013-06-11  06:06:34cat  ../rep1.prm
  830  2013-06-11  06:06:34cat  ../mgr.prm
  924  2013-06-11  06:06:34ls /shared/oradata/dirprm
  958  2013-06-11  06:06:34cd dirprm/
  961  2013-06-11  06:06:34cat dpump.prm
 1011  2013-06-11  06:08:29history |grep rm
 1017  2013-06-11  06:09:48history |grep rm
[oracle@micro ~]$ 

Validate a zip files/archive

Sometime you may want to validate a zip archive without extracting it. To test the validity of the zip file, pass option –t as shown below.

unzip -t var-log.zip
Archive: var-log.zip
testing: var/log/acpid OK
testing: var/log/anaconda.log OK
testing: var/log/anaconda.syslog OK
skip...
testing: var/log/wtmp OK
testing: var/log/wtmp.1 OK
testing: var/log/Xorg.0.log OK
No errors detected in compressed data of var-log.zip.

Password Protection of Zip files

Pass the option –P to the zip command to assign a password to the zip file.

zip -P mysecurepwd var-log-protected.zip /var/log/*
The above option is good if you are using the command inside a shell-script for background jobs. However, when you are performing the compression interactively on the command-line, you don’t want the password to be visible in the history. So, use the option –e as shown below to assign the password.

# zip -e var-log-protected.zip /var/log/*
Enter password:
Verify password:
updating: var/log/acpid (deflated 81%)
updating: var/log/anaconda.log (deflated 79%)

When you are uncompressing a password protected file, it will ask for the password as shown below.

# unzip var-log-protected.zip
Archive: var-log-protected.zip
[var-log-protected.zip] var/log/acpid password:

How to zip a directory and it’s files recursively?

# unzip var-log.zip
Archive: var-log.zip
inflating: var/log/acpid
inflating: var/log/anaconda.log
inflating: var/log/anaconda.syslog
inflating: var/log/anaconda.xlog
creating: var/log/audit/

zip multiple files

ziping multiple files -

zip var-log-files.zip /var/log/*
adding: var/log/acpid (deflated 81%)
adding: var/log/anaconda.log (deflated 79%)
adding: var/log/anaconda.syslog (deflated 73%)
adding: var/log/anaconda.xlog (deflated 82%)
adding: var/log/audit/ (stored 0%)
adding: var/log/boot.log (stored 0%)
adding: var/log/boot.log.1 (deflated 40%)
adding: var/log/boot.log.2 (deflated 42%)
adding: var/log/boot.log.3 (deflated 40%)
adding: var/log/boot.log.4 (deflated 40%)




Change foreground color of the linux prompt

oracle@micro /etc/mail>  export PS1="\e[1;34m\u@\h \w> \e[m "oracle@micro /etc/mail>  export PS1="\e[1;34m\u@\h \w> \e[m "
oracle@micro /etc/mail>  export PS1="\e[1;34m\u@\h \w> \e[m "
oracle@micro /etc/mail>  export PS1="\e[1;34m\u@\h \w> \e[m "
oracle@micro /etc/mail>
Color Code Table:
Black 0;30
Blue 0;34
Green 0;32
Cyan 0;36
Red 0;31
Purple 0;35
Brown 0;33
[Note: Replace 0 with 1 for dark color]  

Display total connect time of users

Ac command will display the statistics about the user’s connect time.

Connect time for the current logged in user

$ ac –d
Jun 1 total 1.08
Jun 2 total 0.99
Jun 3 total 3.39
Jun 4 total 4.50
Today total 6.10


To get a connect time report for a specific user, execute the following: 

[oracle@micro oradata]$ ac -d oracle
Apr  6 total        5.05
Apr  7 total        7.66
Apr  8 total        2.48
Apr  9 total        6.52
Apr 10 total        9.69
Apr 11 total       14.81
Apr 12 total        2.81
Apr 13 total       12.53
Apr 14 total        4.13
Apr 15 total       11.94
Apr 16 total       13.95
Apr 17 total        7.92
Apr 18 total       26.23
Apr 19 total       46.76
Apr 20 total       18.20
Apr 21 total       17.71
Apr 22 total       33.48
Apr 23 total       36.38
Apr 24 total        8.80
Apr 25 total        9.12
Apr 26 total       15.82
Apr 27 total       10.55
Apr 28 total        4.53
Apr 29 total       12.21
Apr 30 total        9.73
May  1 total       13.79
May  2 total        5.33
May  3 total       10.74
May  4 total        7.38
May  5 total        0.96
May  6 total        9.58
May  7 total        8.53
May  8 total       16.80
May  9 total       19.05
May 10 total       13.03
May 11 total       11.72
May 12 total       10.04
May 13 total        7.90
May 14 total        7.05
May 15 total       10.06
May 16 total       11.02
May 17 total        7.55
May 18 total        9.70
May 19 total        5.34
May 20 total       18.96
May 21 total        7.63
May 22 total        9.68
May 23 total       11.00
May 24 total       11.60
May 25 total       19.75
May 27 total        0.10
May 29 total        1.15
Jun  1 total        6.69
Jun  3 total        0.30
Jun  4 total       21.69
Jun  5 total        5.09
Jun  6 total       19.26
Jun  7 total        3.73
Jun  8 total       16.36
Jun 10 total       28.15
Today total        6.73
[oracle@micro oradata]$ 

Saturday, June 8, 2013

mysql remote connection mysql database server

mysql remote connection mysql database server 


 Connect to a remote web server, but the connection is always prompt is not allowed to connect to the server, I have read that there is no limit on the server, the firewall off, but still this solution to the problem is as follows: 

Run: mysql> GRANT ALL ON *. * To name @ localhost identified by 'name'; 

If you want this mysql user to allow a visit from the IP can change localhost to the IP, if you want to allow access to a host name, host name can be changed to allow all remote access, it seems blank can (not tested).



Run: mysql> GRANT ALL PRIVILEGES ON *. * To root @ "%" identified by '12345 'with grant Option your; 


The above command creates a super account from any machine logged in as root and the password is 12345. In this way, the easy to use graphical tool login and operations, including change the root password. 

Tuesday, June 4, 2013

Step By Step Guide On Creating Physical Standby Using RMAN Duplicate In ASM Filesystem For ASM Primary

Pre-Requisite
a) Database (PRIMARY) is up and running and the datafiles, controlfiles residing in ASM.
b) ASM instance and diskgroups configured in STANDBY server.
c) Network connectivity between PRIMARY and STANDBY server

PROCEDURE
1.Enable force logging in PRIMARY.
2.Create SRL(standby redo logs) in PRIMARY.
3.Backup the PRIMARY database.
4.Make proper changes in the parameter file of PRIMARY.
5.Create the parameter file for STANDBY
6.Copy the files (RMAN Backup, init.ora) to STANDBY
7.Establish the connectivity between PRIMARY and STANDBY.
8.Start the STANDBY instance and use RMAN duplicate to create standby database
9. Create SRL on standby.
10.Start the MRP process,
11. Verify whether the log are shipped and applied properly @the standby

Consider two databases of names PRIMARY= PRIMA  and STANDBY= MYSTD
1. Enable Forced Logging on PRIMARY
SQL> ALTER DATABASE FORCE LOGGING;
2. Configure Standby Redo Log on PRIMARY
a. Check the log files and sizes,
SQL>SELECT GROUP#,BYTES FROM V$LOG;
b. Create SRL
ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 SIZE 100M;


c. Verify the standby redo log file groups were created(do this after the creation of stanby database)

SQL> SELECT GROUP#,THREAD#,SEQUENCE#,ARCHIVED,STATUS FROM V$STANDBY_LOG;

3. Use RMAN to backup PRIMARY database with archivelog & controlfile.

RMAN>backup database format '/tmp/dbbkp/PRIMA_%U';
RMAN>backup archivelog all format '/tmp/dbbkp/PRIMA_ARC_%U';
RMAN> backup current controlfile for standby format '/tmp/dbbkp/PRIMA_CONTROL.bkp';

4. Make the necessary changes to PRIMARY  .

DB_NAME=pri
DB_UNIQUE_NAME=pri
LOG_ARCHIVE_CONFIG='DG_CONFIG=(PRIMA,MYSTD)'
LOG_ARCHIVE_DEST_2= 'SERVICE=stdby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=MYSTD'
LOG_ARCHIVE_DEST_STATE_2=DEFER
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=30
FAL_SERVER=MYSTD
FAL_CLIENT=PRIMA
DB_FILE_NAME_CONVERT='MYSTD','PRIMA'
LOG_FILE_NAME_CONVERT='MYSTD','PRIMA'
STANDBY_FILE_MANAGEMENT=AUTO


5. Create the parameter file for standby,

a. CREATE PFILE='<specify any location>' from spfile; (@primary,)
b. Make the necessary changes, for example,

DB_NAME=PRIMA
DB_UNIQUE_NAME=MYSTD
LOG_ARCHIVE_CONFIG='DG_CONFIG=(PRIMA,MYSTD)'
CONTROL_FILES='+DATA','+FRA'
DB_FILE_NAME_CONVERT='PRIMA','MYSTD'
LOG_FILE_NAME_CONVERT='PRIMA','MYSTD'
LOG_ARCHIVE_FORMAT=log%t_%s_%r.arc
LOG_ARCHIVE_DEST_2= 'SERVICE=PRIMA LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PRIMA'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
STANDBY_FILE_MANAGEMENT=AUTO
FAL_SERVER=PRIMA
FAL_CLIENT=MYSTD

Note: If the ASM Disk groups names are different between PRIMARY and STANDBY do the necessary changes in STANDBY with the parameters DB_CREATE_FILE_DEST and DB_CREATE_ONLINE_LOG_DEST_n
 
6. Copy the files (RMAN Backup, init.ora) to STANDBY
a) Copy the RMAN backup files created in /tmp/dbbkp (step3) to STANDBY in identical locationExample:scp /tmp/dbbkp/* oracle@core1:/tmp/dbbkp/*
b) Copy the init.ora (step 5) to STANDBY
c) Recreate the password file in standby using orapwd utility


7. Establish the connectivity between primary and standby.

In PRIMARY (TNSNAMES.ORA)


MYSTD=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.9.200.108)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = MYSTD.server.com)
)
)

In STANDBY (TNSNAMES.ORA)
PRIMA=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.9.200.107)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PRIMA.server.com)
)
)


NOTE: Use TNSPING <servicename> to check the connectivity between PRIMARY and STANDBY
 
8. Start the STANDBY instance and use RMAN duplicate to create standby database

NOTE: Make sure the ASM instance also running.
$export ORACLE_SID=MYSTD
SQL>create spfile from pfile=’<specify the newly created parameter location>’
SQL>startup nomount 
 
NOTE: Connect to catalog if your primary database has catalog database.
 
$RMAN target sys/<passwd>@primary catalog RMAN/RMAN@RMAN auxiliary sys/<passwd>
RMAN> RUN {
allocate auxiliary channel C1 device type disk;
duplicate target database for standby;
}


9. Create SRL(Standby Redo logs) on standby,

NOTE:SIZE OF STANDBY LOGFILE SHOULD BE SAME AS ONLINE LOGFILE
 
 
For Example,

ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 SIZE 100M;
10. Start the MRP process in PRIMARY

In PRIMARY

SQL>ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;

In STANDBY
SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

11. Verify whether the log are shipped and applied properly in the standby

a. execute on PRIMARY database

SQL> ALTER SYSTEM SWITCH LOGFILE;

b. execute on STANDBY database

SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

c. Issue more log switches at PRIMARY

SQL> ALTER SYSTEM SWITCH LOGFILE;

d. Verify the new redo data was archived on the standby database.On the standby database, query the V$ARCHIVED_LOG view to verify the redo data was received and archived on the standby database:

SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME  FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

NOTE: Verify new archived redo log files were applied. At the standby database, query the V$ARCHIVED_LOG view to verify the archived redo log files were applied.

SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;


Recompiles/Invalidates all PL/SQL code inside Oracle Db

from sys user we can below script for Recompiles/Invalidates all PL/SQL Code , this will very help full ,

Instance has to be started in upgrade mode and Oracle built-in PLSQL code has to be revalidated. As "startup upgrade" hangs too, we have no option other than using "alter database open migrate" command which achieves the same target databse state as follows:


# sqlplus "/as sysdba"
shutdown immediate
startup mount
alter database open migrate;
@$ORACLE_HOME/admin/utlirp.sql   ---- this script invalidates all PL/SQL code
@$ORACLE_HOME/admin/utlrp.sql    ---- this script recompiles everything again
shutdown immediate
startup

Script to Generate Sequence creation DDL for all primary keys using the current values

This is best achieved by a PL/SQL procedure that generates the required DDL.

Please create below procedure, which can generate DDLs given a schema name:

CREATE OR REPLACE procedure GenerateSeqDDL(schemaowner in varchar2)
IS
  TYPE RecTyp IS RECORD (
tabname VARCHAR2(30),
colname VARCHAR2(30));

  TYPE TabTyp IS TABLE OF RecTyp INDEX BY BINARY_INTEGER;
  sqtab   TabTyp;
  i BINARY_INTEGER;
  m number;

  cursor c1 is
select cons.table_name, col.column_name, cons.owner
from dba_constraints cons
inner join dba_cons_columns col on cons.owner = col.owner and cons.constraint_name = col.constraint_name
inner join dba_tab_cols cols on col.owner = cols.owner and cols.table_name = col.table_name and col.column_name = cols.column_name
where constraint_type = 'P' and cons.owner=schemaowner and cols.data_type = 'NUMBER';
BEGIN

  i := 1;

  FOR rec in c1
  LOOP
sqtab(i).tabname := rec.table_name;
sqtab(i).colname := rec.column_name;
dbms_output.put_line(rec.table_name);
i := i+1;
  END LOOP;

      FOR i2 IN 1..sqtab.count LOOP
execute immediate 'select max(' || sqtab(i2).colname ||') +1 from ' || schemaowner || '.' || sqtab(i2).tabname into m;
DBMS_OUTPUT.PUT_LINE('CREATE SEQUENCE ' || sqtab(i2).tabname || '_PK_SEQ START WITH ' || m || ' MAXVALUE 999999999999999999999999999 MINVALUE 1 NOCYCLE CACHE 20 NOORDER;');
END LOOP;

ENd;
/

Migrate MySQL database to another Server

Make the backup of the database


mysqldump -u root -p --opt [DB_name] > /tmp/[database_name].sql

Where DB_name is the database you want to move.

Copy the database to the new server


You can use rsync, scp or ftp, I will show you how to do it with scp

scp /tmp/[database_name].sql user@newserver.com:/tmp/

Create the database in the new server

 

mysql -u root -pcreate database [database_name];

grant all privileges on [database_name].* to "some-user"@"hostname" identified by "some-strong-password";


flush privileges;

exit

Import the backup


mysql -u root -p [database_name] < /tmp/[database_name].sql