Friday, November 26, 2010

SSH Configuration between servers

SSH Configuration between linux servers without giving password

SSH can give you authenticated and encrypted connections to remote computers. If you set up keys you can make these connections without passwords.

I test this for RHEL5 64 bit OS

Step1: Generate a public and private key pair on the machine from where you want to login to other machines.

For SSH1:
# ssh-keygen -b 1024 -t rsa
For SSH2 (Recommended):
# ssh-keygen -b 1024 -t dsa
  • You will be prompted for a file in which the key and a passphrase will be saved. 
  • You may press Enter through each of these prompts. 
  • If you do so, the key generation program will assume that you wish to use the default file name of id_dsa and your private key will not be protected by a password.
  • Once this is done, you will see id_rsa and id_rsa.pub file in the .ssh directory in your home directory if you have not supplied a file name as I mentioned above.

Step 2: Copy the content of id_rsa.pub file to authorized_keys2 file available in .ssh directory of the remote host(s)
  • Copy the public keys (id_rsa.pub) to the remote host. That is the content of id_rsa.pub file to the file called  authorized_keys2 available in .ssh directory of the host(s) where you wanted to connect without password. 
  • Be aware that .ssh directory will be available in the home directory as hidden file so make sure it availability by ls -ltr command in the home directory.
# scp ~/.ssh/id_rsa.pub remote_host:/

Step 3: Login to the remote host and check if you already have authorized_keys2 file in .ssh dir. If this doesn’t exist, create it with the following commands.

# touch ~/.ssh/authorized_keys2

Step 4: On the remote host where you are in step 3, copy your public key to the authorized_keys2 file, with the following command.

# cat ~/ id_rsa.pub >> ~/.ssh/authorized_keys2

Step 5: You are set to use SSH authentication without password now. If you want you can delete or move id_rsa.pub file.

You can follow steps 2 – 5 for all other hosts where you want to have public key authentication.


SSH Configuration between serversSocialTwist Tell-a-Friend

Saturday, November 6, 2010

Recompiling Invalid Objects

STEP 1: Use the below query to find INVALID Objects



SELECT OWNER, OBJECT_NAME, OBJECT_TYPE, STATUS FROM DBA_OBJECTS WHERE STATUS='INVALID';
Export the result of the above query to xls.

STEP 2: Identify the Object Type of each invalid object.

STEP 3: If the object type is synonym

Use the below query for generating a query to create or replace invalid synonyms

SELECT  'CREATE OR REPLACE PUBLIC SYNONYM ' ||OBJECT_NAME ||' FOR '
||OBJECT_NAME||';' FROM DBA_OBJECTS where status='INVALID' AND OBJECT_TYPE='SYNONYM';

Use the below query for generating a query to grant privileges to synonyms



SELECT 'GRANT ALL ON ' ||OBJECT_NAME ||' TO PUBLIC||;' FROM DBA_OBJECTS where status='INVALID' AND OBJECT_TYPE='SYNONYM';

STEP 4: Copy and paste the result set of both the above queries in separate file


Now execute the first result set

CREATE OR REPLACE PUBLIC SYNONYM SYNONYM_NAME1 FOR OBJECT_NAME1;

CREATE OR REPLACE PUBLIC SYNONYM SYNONYM_NAME2 FOR OBJECT_NAME2;


CREATE OR REPLACE PUBLIC SYNONYM SYNONYM_NAME3 FOR OBJECT_NAME3;

CREATE OR REPLACE PUBLIC SYNONYM SYNONYM_NAME4 FOR OBJECT_NAME4;

CREATE OR REPLACE PUBLIC SYNONYM SYNONYM_NAME5 FOR OBJECT_NAME5;
CREATE OR REPLACE PUBLIC SYNONYM SYNONYM_NAME6 FOR OBJECT_NAME6;

CREATE OR REPLACE PUBLIC succeeded.
CREATE OR REPLACE PUBLIC succeeded.
CREATE OR REPLACE PUBLIC succeeded.
CREATE OR REPLACE PUBLIC succeeded.
CREATE OR REPLACE PUBLIC succeeded.
CREATE OR REPLACE PUBLIC succeeded.

Now execute the second result set

GRANT ALL ON SYNONYM_NAME1 TO PUBLIC;
GRANT ALL ON SYNONYM_NAME2 TO PUBLIC;
GRANT ALL ON SYNONYM_NAME3 TO PUBLIC;
GRANT ALL ON SYNONYM_NAME4 TO PUBLIC;
GRANT ALL ON SYNONYM_NAME5 TO PUBLIC;
GRANT ALL ON SYNONYM_NAME6 TO PUBLIC;

GRANT ALL succeeded.
GRANT ALL succeeded.
GRANT ALL succeeded.
GRANT ALL succeeded.
GRANT ALL succeeded.
GRANT ALL succeeded.

Use the below query to check whether the objects has been recompiled and the status is VALID

SELECT OWNER, OBJECT_NAME, OBJECT_TYPE, STATUS FROM DBA_OBJECTS
WHERE STATUS='VALID' AND OBJECT_TYPE='SYNONYM' AND OBJECT_NAME IN ('OBJECT_NAME1','OBJECT_NAME2','OBJECT_NAME3','OBJECT_NAME4',
'OBJECT_NAME5';

STEP 5: If the object type is not synonym


Recompile other objects as the show below




Recompiling Invalid ObjectsSocialTwist Tell-a-Friend

Uploading CSV in SQLLDR

Normal CSV Upload



Step 1: Before loading data you need two files control file and csv file.
Step 2: Change the following in the control file


  •   Path of the csv file.
  •   Table name.
  •   Column names for which the data has to be inserted.
Step 3: Execute the command sqlldr control=c:\ctrl3, log=c:\tablename.log userid=username/password@connectionname
    


Blob and Date Column CSV Upload via SQLLDR
  
Step 1: Before loading data you need two files control file and csv file .


This is different from normal upload since it has date field to be loaded and XML_BLOB field that need to loaded.


Prerequisite: Char_Set_ID will be given
  
Step 2: Export the Char_Set  table (for the Char_Set_ID given) excluding the char_set_xml column as csv.

Step 3: Now export the char_set_xml column for each of the given Char_Set_ID as single dat file.
  
Step 4: Change the following in the csv file
  •  In the XML_BLOB (char_Set_xml) column mention the path of the dat file XML_BLOB (char_Set_xml).
  •  Also check for the date format of the date fields as mentioned in the control file.
Step 5: Change the following in the control file
  •  Path of the csv file.
  •  Table name.
  •  Column names for which the data has to be inserted.
  • Give the correct format of the date fields. For Example insert_date Date "MM/DD/YYYY HH24:MI:SS",
  • XML_BLOB column has to be mentioned as below in the control file. For Example lob file filler char,CHAR_SET_XML LOBFILE(lob_file) TERMINATED BY EOF
Step 4: Execute the command sqlldr control=c:\ctrl, log=c:\tablename.log userid=suvin/welcome@connectionname
 
Control File Content


LOAD DATA

INFILE "c:\char_set.csv"
Append INTO TABLE CHAR_SET
FIELDS TERMINATED BY ','
(
CHAR_SET_ID,
CHAR_SET_ID,
CHAR_SET_NAME,
QUERY_TABLE_ID,
lob_file filler char,
CHAR_SET_XML LOBFILE(lob_file) TERMINATED BY EOF,
domain_name,
insert_user,
insert_date Date "MM/DD/YYYY HH24:MI:SS",
update_user,
update_date Date "MM/DD/YYYY HH24:MI:SS"
)
Sample

Microsoft Windows XP [Version 5.1.2600]


(C) Copyright 1985-2001 Microsoft Corp.


C:\Documents and Settings\;sqlldr userid=suvin/welcome@tmstest control=c:/CTRL4, log=tablename_04_NOV.log


SQL*Loader: Release 10.1.0.2.0 - Production on Wed Nov 3 17:13:44 2010
Copyright (c) 1982, 2004, Oracle. All rights reserved.


Commit point reached - logical record count 53


C:\Documents and Settings\sqlldr userid=suvin/welcome@tmsprod1 control=c:/CTRL4, log=tablename_04_NOV.log


SQL*Loader: Release 10.1.0.2.0 - Production on Wed Nov 3 17:16:01 2010
Copyright (c) 1982, 2004, Oracle. All rights reserved.


Commit point reached - logical record count 53


C:\Documents and Settings\;

Uploading CSV in SQLLDRSocialTwist Tell-a-Friend

Monday, October 18, 2010

How To Repair the Master Boot Record In Windows XP

Repairing the master boot record on your Windows XP system is accomplished using the fixmbr command, available in Recovery Console. This is necessary when the master boot record has become corrupt due to a virus or some kind of damage.




Follow these easy steps to repair a damaged master boot record in Windows XP.



Difficulty: Easy

Time Required: Repairing the master boot record on a Windows XP system takes less than 15 minutes


Here's How:

Enter Windows XP Recovery Console.
 
When you reach the command prompt (detailed in Step 6 in the link above), type the following and then press Enter.
 
fixmbr
 
The fixmbr utility will write a master boot record to the hard drive that you're currently using to boot into Windows XP. This will repair any corruption or damage that the master boot record may have.
 
Take out the Windows XP CD, type exit and then press Enter to restart your PC.
 
Assuming that a corrupt master boot record was your only issue, Windows XP should now start normally
How To Repair the Master Boot Record In Windows XPSocialTwist Tell-a-Friend

Monday, June 28, 2010

How To Recover Windows 7 Multi-boot Option with Windows XP

Hello guys i think this is the common problem to all, as if you use Windows 7 as a second operating system with Windows Vista or Windows XP boot menu option automatically creates a new operating system option in the boot menu there.  However, if you have Windows 7, and then try installing Windows XP, you will overwrite the MBR with one that does not recognize the code, the boot loader of Windows 7.
If any body of us are in the same situation and looking for the way to fix and get back Windows 7 option in boot menu then follow below simple steps.

1. Open a command prompt in the Xp/Vista operating( i mean in the older operating systems ) systems and run from the Windows 7 DVD the following command, Hear H is my drive letter replace yours:
H:\boot\ bootsect.exe /nt60 all
Just restart, now you should see the Windows 7 menu.

2. To restore the menu entry for your earlier version of Windows, open an elevated Command Prompt window and type this command:
bcdedit /create {ntldr} –H “Menu description goes here”
                                                     (or)


Download and Install EasyBCD on your Windows 7 to add boot entry for XP.

Launch the app and go to Add/Remove Entries. Under “Add an Entry” open the Windows tab and select the Type as “Windows NT/2k/XP/2k3”.

Give it a name like ‘Windows XP’ and click on ‘Add Entry’. Then select Save.


That’s it. Now restart you PC and you’ll be presented with two options, Windows 7 and Windows XP. Select the one which you want to work on.


Cheers:
Substitute your own description for the placeholder text, being sure to include the quotation marks. The next time you start your computer, the menus should appear as you intended.
How To Recover Windows 7 Multi-boot Option with Windows XPSocialTwist Tell-a-Friend

Thursday, May 20, 2010

killing rac sessions

SET LINESIZE 100

COLUMN spid FORMAT A10

COLUMN username FORMAT A10

COLUMN program FORMAT A45



SELECT s.inst_id,

s.sid,

s.serial#,

p.spid,

s.username,

s.program

FROM gv$session s

JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id

WHERE s.type != 'BACKGROUND';


The basic syntax for killing a session is shown below.


SQL> ALTER SYSTEM KILL SESSION 'sid,serial#';



In a RAC environment, you optionally specify the INST_ID, shown when querying the

GV$SESSION view. This allows you to kill a session on different RAC node.


SQL> ALTER SYSTEM KILL SESSION 'sid,serial#@inst_id';


In addition to the syntax described above, you can add the IMMEDIATE clause.


SQL> ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;


DISCONNECT SESSION


SQL> ALTER SYSTEM DISCONNECT SESSION 'sid,serial#' POST_TRANSACTION;

SQL> ALTER SYSTEM DISCONNECT SESSION 'sid,serial#' IMMEDIATE;


The POST_TRANSACTION and IMMEDIATE clauses can be used together, but the documentation

states that in this case the IMMEDIATE clause is ignored. In addition, the syntax diagram

suggests both clauses are optional, but in reality, one or both must be specified or you

receive an error.


SQL> alter system disconnect session '30,7';

alter system disconnect session '30,7'

*

ERROR at line 1:

ORA-02000: missing POST_TRANSACTION or IMMEDIATE keyword


The Windows Approach

To kill the session on the Windows operating system, first identify the session, then

substitute the relevant SID and SPID values into the following command issued from the

command line.


C:> orakill ORACLE_SID spid


The UNIX Approach

To kill the session on UNIX or Linux operating systems, first identify the session, then substitute the relevant SPID into the following command.


% kill spid

If after a few minutes the process hasn't stopped, terminate the session using the following.


% kill -9 spid

If in doubt check that the SPID matches the UNIX PROCESSID shown using.


% ps -ef
grep ora


----------------Session Waits--------------------

SQL> select event, seconds_in_wait, sid from v$session_wait where sid in (10,14);
killing rac sessionsSocialTwist Tell-a-Friend

Export and Import Dump

------------Importing Full Dump File-------------




If you want to Import all the objects in a dump file then you can type the

following command.



$impdp hr/hr DUMPFILE=dpump_dir1:expfull.dmp FULL=y

LOGFILE=dpump_dir2:full_imp.log



This example imports everything from the expfull.dmp dump file. In this example,

a DIRECTORY parameter is not provided. Therefore, a directory object must be provided

on both the DUMPFILE parameter and the LOGFILE parameter



-------------Importing Objects of One Schema to another Schema---------------



The following example loads all tables belonging to hr schema to scott schema



$impdp SYSTEM/password DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp

REMAP_SCHEMA=hr:scott



If SCOTT account exist in the database then hr objects will be loaded into scott schema.

If scott account does not exist, then Import Utility will create the SCOTT account with

an unusable password because, the dump file was exported by the user SYSTEM and imported

by the user SYSTEM who has DBA privileges.



-------------Loading Objects of one Tablespace to another Tablespace--------------------



You can use remap_tablespace option to import objects of one tablespace to another

tablespace by giving the command



$impdp SYSTEM/password DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp

REMAP_TABLESPACE=users:sales



The above example loads tables, stored in users tablespace, in the sales tablespace.



---------Generating SQL File containing DDL commands using Data Pump Import---------



You can generate SQL file which contains all the DDL commands which Import would have

executed if you actually run Import utility



The following is an example of using the SQLFILE parameter.



$ impdp hr/hr DIRECTORY=dpump_dir1 DUMPFILE=expfull.dmp

SQLFILE=dpump_dir2:expfull.sql



A SQL file named expfull.sql is written to dpump_dir2.



-----------------------Importing objects of only a Particular Schema---------------------



$impdp hr/hr SCHEMAS=hr,oe DIRECTORY=dpump_dir1 LOGFILE=schemas.log

DUMPFILE=expdat.dmp



-----------------Importing Only Particular Tables---------------



The following example shows a simple use of the TABLES parameter to import only the employees and jobs tables from the expfull.dmp file. You can create the expfull.dmp dump file used in this example by running the example provided for the Full Database Export in Previous Topic.



$impdp hr/hr DIRECTORY=dpump_dir1 DUMPFILE=expfull.dmp TABLES=employees,jobs



This will import only employees and jobs tables from the DUMPFILE
Export and Import DumpSocialTwist Tell-a-Friend