Wednesday, October 7, 2015

'Host key verification failed' Error when scp from one host to another in linux


Problem

When Try to copy file from one host to another below error occur
[root@backup u01]# scp -r RPM_oel6/ 192.168.22.4:/u01
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
ea:d6:b9:ac:45:e5:4a:46:ff:71:0b:84:a6:24:de:b2.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:2
RSA host key for 192.168.22.4 has changed and you have requested strict checking.
Host key verification failed.
lost connection

Solution

Please execute below command and copy again to overcome the issue
sed -i '2d' /root/.ssh/known_hosts 
Where '2d' is line number. If the line number is different then use the same

Thursday, July 16, 2015

Mount NTFS file system on Linux

Below are the steps to mount ntfs file system on linux OS

1. Download fuse RPM from below link and Install
http://www.atrpms.net/dist/el5/fuse/
$ rpm -Uvh --nodeps --force fuse-2.7.4-8_12.el5.x86_64.rpm
$ rpm -Uvh --nodeps --force fuse-kmdl-2.6.18-371.el5xen-2.7.4-8_12.el5.x86_64.rpm
$ rpm -Uvh --nodeps --force fuse-libs-2.7.4-8_12.el5.x86_64.rpm

2. Download fuse-ntfs RPM from below link and Install
http://dag.wieers.com/rpm/packages/fuse-ntfs-3g/
$ rpm -Uvh --nodeps --force fuse-ntfs-3g-1.417-1.el4.rf.x86_64.rpm

3. Mount the HD
$ mount.ntfs-3g /dev/sdb1 /media/disk1 -o force

Tuesday, July 14, 2015

Change sysman Password on 12c EM

Can not Change sysman password through sqlplus when running on Enterprise Manager. Have to use emctl to change sysman because this is used by oms. Please follow below steps to change the password

1. Stop oms
$ export OMS_HOME=/u01/app/oracle/oms12cr3/oms
$ cd $OMS_HOME/bin
$ ./emctl stop oms
do not use -all as admin server need to be up for change password 2. Modify sysman password
$ cd $OMS_HOME/bin
$ emctl config oms -change_repos_pwd -use_sys_pwd -sys_pwd <'sys password'> -new_pwd <'new sysman password'>
2. Restart all oms including Admin server
$ cd $OMS_HOME/bin
$ ./emctl stop oms -all
$ ./emctl start oms

Thursday, June 25, 2015

Add Swap Space on Linux

Find current swap space on the system
# free -m
           total   used    free   shared   buffers  cached
Mem:       16051   15570    481      0       707     12644
-/+ buffers/cache: 2218    13833
Swap:      8189     0      8189

Or

# swapon -s
Filename         Type        Size    Used    Priority
/dev/sda2      partition   8385920    88       -1

 Or

# cat /proc/swaps
Filename         Type        Size    Used    Priority
/dev/sda2      partition   8385920    88       -1

Method 1 - Use Hard Drive Partition

If you have additional hard disk or space available in existing disk then create partition using fdisk command. Assume /dev/sdc1 is newly created partition 

Setup newly created partition as swap area
# mkswap /dev/sdc1
Enable swap partition
# swapon /dev/sdc1
Add following line to /etc/fstab to available even after reboot
# cat /etc/fstab
/dev/sdc1        swap         swap    defaults        0 0
Verify whether newly created swap space is available
# swapon -s
Filename         Type       Size     Used    Priority
/dev/sda2      partition   8385920    88       -1
/dev/sdc1      partition  10234430     0       -2

Method 2 - Use a file for Additional swap space

If you does not have any additional disk then you can create a file on your system and use that for swap space

Create the swap file called 'myswap' using following command (file size in bytes=bs*count)
# dd if=/dev/zero of=/root/myswap bs=1M count=2048
Change the permission of newly created file
# chmod 755 /root/myswap
Make this file as a swap file
# mkswap /root/myswap
Add following line to /etc/fstab to available even after reboot
# cat /etc/fstab
/root/myswap        swap         swap    defaults        0 0
Verify whether newly created swap space is available
# swapon -s
Filename         Type       Size     Used    Priority
/dev/sda2      partition   8385920    88       -1
/root/myswap     file      2097152     0       -2

Tuesday, June 23, 2015

Deploy 12c Management Agent

Here explain how to add target hosts to enterprise manager

Login to Enterprise Manager via Sysman login
Go to Setup->Add Target->Add Targets Manually


 Select Add Host Targets and Click Add Host Button

Click on Add Button and Add the target host name which need to deploy agent and Click on Next Button

Provide Installation Base Directory and Instance directory on target host

Review the Host Information and click on Deploy Agent button to begin the installation

Now Management Agent will deploy on target host

Ignore the Privileges warning and click on Continue->Continue, All Host

Run the root.sh to complete the Agent deployment


Go to Setup->Add Target->Add Targets Manually and select 'Add Target Declaratively by Specifying Target Monitoring Properties'
Select 'Database Instance' to Target Type and specific hostname for Monitoring Agent and click on 'Add Manually' Button

Provide Database Details of Agent and Test the connection


Agent configuration completed and now can monitor newly added DB through EM

Thursday, June 11, 2015

Install 12c Enterprise Manager

Prerequisites 

  • Download and Install Oracle Database 11g R2 on linux platform
  • Download Enterprise Manager Cloud control from following link
  • http://www.oracle.com/technetwork/oem/grid-control/downloads/index.html

  • If you have performed a default database installation you will need to de-configure Enterprise Manager Database Control. Run the following command as the "oracle" user.

  • $ emca -deconfig dbcontrol db -repos drop -SYS_PWD <sys pasword> -SYSMAN_PWD <sysman password>

  • Make following initialization parameter changes and restart the instance

  • $sqlplus / AS SYSDBA
    SQL>ALTER SYSTEM SET processes=300 SCOPE=SPFILE;
    SQL>ALTER SYSTEM SET session_cached_cursors=200 SCOPE=SPFILE
    SQL>ALTER SYSTEM SET sga_target=2G SCOPE=SPFILE;
    SQL>ALTER SYSTEM SET shared_pool_size=600M SCOPE=SPFILE;
    SQL>ALTER SYSTEM SET pga_aggregate_target=1G SCOPE=SPFILE;
    SQL>ALTER SYSTEM SET job_queue_processes=20 SCOPE=SPFILE;
    
    SQL>SHUTDOWN IMMEDIATE
    SQL>STARTUP
    
    If you have done a default installation as described here, the UNDO tablespace will be autoextensible. If you have done a custom installation make sure the UNDO tablespace is at least 200M in size. Also, make sure you have 3 redo logs of at least 300M to prevent a warning during the installation.

    Cloud Control Installation

    Create Following installation directories for management server and agent

    $ mkdir -p /u01/app/oracle/oms12cr3
    $ mkdir -p /u01/app/oracle/agent12cr3
    
    Unzip the cloud control media and begin the installation by running runinstaller
    $ mkdir em
    $ unzip -d em em12103p1_linux64_disk1.zip
    $ unzip -d em em12103p1_linux64_disk2.zip
    $ unzip -d em em12103p1_linux64_disk3.zip
    $ cd em
    
    $ ./runInstaller
    
    If you wish to receive support information enter the e-mail address else skip

    If you wish to check for updates enter the details else skip

    If you have completed all the prerequisites then installation pass all the checks

    Select 'Create a new Enterprise Manager System' and 'simple' option

    Enter Middleware and Agent installation locations

    Enter Administrator password and Database Details

    If you have any additional warnings, check they don't look like show-stoppers, then click the 'OK' button to continue and click 'Install' button to begin the installation


    When prompted, run the root scripts, then click the 'OK' button
    Make note of the URL below and close. Copy of following information are stored in /u01/app/oracle/oms12cr3/oms/install/setupinfo.txt file.

    Login to the EM using above URL.


    Startup and Shutdown Enterprise Manager

    Oracle Management Server
    export OMS_HOME=/u01/app/oracle/oms12cr3/oms
    $OMS_HOME/bin/emctl start oms
    $OMS_HOME/bin/emctl stop oms
    $OMS_HOME/bin/emctl status oms
    
    Agent
    export AGENT_HOME=/u01/app/oracle/agent12cr3/core/12.1.0.3.0
    $AGENT_HOME/bin/emctl start agent
    $AGENT_HOME/bin/emctl stop agent
    $AGENT_HOME/bin/emctl status agent
    

    Sunday, May 17, 2015

    Migrate Non ASM to ASM Database - 11g

    Prerequisite
    Running Non ASM 11g Database

    Migration Steps

    Download and Install appropriate ASMLib RPM's
    • oracleasm-support-2.1.7-1.el5.i386.rpm
    • oracleasmlib-2.0.4-1.el5.i386.rpm
    • oracleasm-[your-kernel-version].rpm

    Then create the disk as follows which using creation of ASM instance









    I have created 2 disks DISK1 and DISK2

    Check the permission of created disk under /dev/oracleasm/disks/


    Now unzip the grid software and install using ./runInstaller

    And select 'Install and Configure Grid Infrastructure for Standalone Server' as we are not using ASM for RAC database.


    Here you can able see the disks created earlier. I have kept the redundancy 'External' so that only one disk is required for a disk group. For redundancy 'Normal' we need to have a two disks in a diskgroup and for 'High' we need a minimum for three disks. Select the disk which has to be added to diskgroup named 'DATA'.

    Provide the password for SYS and ASMSNMP

     Select the OS group or keep as It is



     Click Finish to begin the installation





    Once the installation is completed you can check whether ASM processes are running

    Now below are the steps to move Non ASM DB to ASM disks
    SQL> select name from v$database;
    
    NAME
    ---------
    DEV
    
    SQL> select file_name from dba_data_files;
    
    FILE_NAME
    --------------------------------------------------------------------------------
    /u01/app/oracle/oradata/DEV/users01.dbf
    /u01/app/oracle/oradata/DEV/undotbs01.dbf
    /u01/app/oracle/oradata/DEV/sysaux01.dbf
    /u01/app/oracle/oradata/DEV/system01.dbf
    /u01/app/oracle/oradata/DEV/example01.dbf
    
    SQL> select file_name from dba_temp_files;
    
    FILE_NAME
    --------------------------------------------------------------------------------
    /u01/app/oracle/oradata/DEV/temp01.dbf
    
    
    SQL> show parameter spfile;
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    spfile                               string      /u01/app/oracle/product/11.2.0
                                                     /dbhome_1/dbs/spfileDEV.ora
    
    
    SQL> show parameter control_file;
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    control_file_record_keep_time        integer     7
    control_files                        string      /u01/app/oracle/oradata/DEV/co
                                                     ntrol01.ctl, /u01/app/oracle/f
                                                     lash_recovery_area/DEV/control
                                                     02.ctl
    
    SQL> alter system set control_files='+DATA' scope=spfile;
    
    System altered.
    
    SQL> alter system set db_create_file_dest='+DATA' scope=spfile;
     
    System altered.
    
    SQL> shutdown immediate
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    
    SQL> startup nomount;
    ORACLE instance started.
    
    Total System Global Area 1653518336 bytes
    Fixed Size                  2213896 bytes
    Variable Size             956303352 bytes
    Database Buffers          687865856 bytes
    Redo Buffers                7135232 bytes
    
    SQL> exit
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    
    [oracle@dev ~]$ rman target /
    
    Recovery Manager: Release 11.2.0.1.0 - Production on Thu May 14 11:05:40 2015
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    connected to target database: DEV (not mounted)
    
    RMAN> restore controlfile from '/u01/app/oracle/oradata/DEV/control01.ctl';
    
    Starting restore at 14-MAY-15
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=23 device type=DISK
    
    channel ORA_DISK_1: copied control file copy
    output file name=+DATA/dev/controlfile/current.257.879678343
    Finished restore at 14-MAY-15
    
    RMAN> alter database mount;
    
    database mounted
    released channel: ORA_DISK_1
    
    RMAN> backup as copy database format '+DATA'
    2> ;
    
    Starting backup at 14-MAY-15
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=25 device type=DISK
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00001 name=/u01/app/oracle/oradata/DEV/system01.dbf
    output file name=+DATA/dev/datafile/system.258.879679631 tag=TAG20150514T112711 RECID=2 STAMP=879679658
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00002 name=/u01/app/oracle/oradata/DEV/sysaux01.dbf
    output file name=+DATA/dev/datafile/sysaux.259.879679667 tag=TAG20150514T112711 RECID=3 STAMP=879679687
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00003 name=/u01/app/oracle/oradata/DEV/undotbs01.dbf
    output file name=+DATA/dev/datafile/undotbs1.260.879679691 tag=TAG20150514T112711 RECID=4 STAMP=879679697
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00005 name=/u01/app/oracle/oradata/DEV/example01.dbf
    output file name=+DATA/dev/datafile/example.261.879679699 tag=TAG20150514T112711 RECID=5 STAMP=879679703
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
    channel ORA_DISK_1: starting datafile copy
    copying current control file
    output file name=+DATA/dev/controlfile/backup.262.879679707 tag=TAG20150514T112711 RECID=6 STAMP=879679707
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00004 name=/u01/app/oracle/oradata/DEV/users01.dbf
    output file name=+DATA/dev/datafile/users.263.879679709 tag=TAG20150514T112711 RECID=7 STAMP=879679709
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    including current SPFILE in backup set
    channel ORA_DISK_1: starting piece 1 at 14-MAY-15
    channel ORA_DISK_1: finished piece 1 at 14-MAY-15
    piece handle=+DATA/dev/backupset/2015_05_14/nnsnf0_tag20150514t112711_0.264.879679711 tag=TAG20150514T112711 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 14-MAY-15
    
    RMAN> switch database to copy;
    
    datafile 1 switched to datafile copy "+DATA/dev/datafile/system.258.879679631"
    datafile 2 switched to datafile copy "+DATA/dev/datafile/sysaux.259.879679667"
    datafile 3 switched to datafile copy "+DATA/dev/datafile/undotbs1.260.879679691"
    datafile 4 switched to datafile copy "+DATA/dev/datafile/users.263.879679709"
    datafile 5 switched to datafile copy "+DATA/dev/datafile/example.261.879679699"
    
    RMAN> alter database open;
    
    database opened
    
    RMAN> Exit
    
    SQL> select file_name from dba_data_files;
    
    FILE_NAME
    --------------------------------------------------------------------------------
    +DATA/dev/datafile/users.263.879679709
    +DATA/dev/datafile/undotbs1.260.879679691
    +DATA/dev/datafile/sysaux.259.879679667
    +DATA/dev/datafile/system.258.879679631
    +DATA/dev/datafile/example.261.879679699
    
    SQL> select file_name from dba_temp_files;
    
    FILE_NAME
    --------------------------------------------------------------------------------
    /u01/app/oracle/oradata/DEV/temp01.dbf
    
    SQL> alter database tempfile '/u01/app/oracle/oradata/DEV/temp01.dbf' drop including datafiles;
    
    Database altered.
    
    SQL> select file_name from dba_temp_files;
    
    no rows selected
    
    SQL> alter tablespace temp add tempfile size 300M;
    
    Tablespace altered.
    
    SQL> select file_name from dba_temp_files;
    
    FILE_NAME
    --------------------------------------------------------------------------------
    +DATA/dev/tempfile/temp.265.879682295
    
    SQL> select member from v$logfile;
    
    MEMBER
    --------------------------------------------------------------------------------
    /u01/app/oracle/oradata/DEV/redo03.log
    /u01/app/oracle/oradata/DEV/redo02.log
    /u01/app/oracle/oradata/DEV/redo01.log
    
    
    SQL> alter database add logfile group 4 '+DATA' size 10M;
    
    Database altered.
    
    SQL> alter database add logfile group 5 '+DATA' size 10M;
    
    Database altered.
    
    SQL> alter database add logfile group 6 '+DATA' size 10M;
    
    Database altered.
    
    SQL> select member from v$logfile;
    
    MEMBER
    --------------------------------------------------------------------------------
    /u01/app/oracle/oradata/DEV/redo03.log
    /u01/app/oracle/oradata/DEV/redo02.log
    /u01/app/oracle/oradata/DEV/redo01.log
    +DATA/dev/onlinelog/group_4.266.879682579
    +DATA/dev/onlinelog/group_5.267.879682595
    +DATA/dev/onlinelog/group_6.268.879682607
    
    6 rows selected.
    
    
    SQL> alter database drop logfile group 2;
    
    Database altered.
    
    SQL> alter database drop logfile group 3;
    
    Database altered.
    
    SQL> select member from v$logfile;
    
    MEMBER
    --------------------------------------------------------------------------------
    /u01/app/oracle/oradata/DEV/redo01.log
    +DATA/dev/onlinelog/group_4.266.879682579
    +DATA/dev/onlinelog/group_5.267.879682595
    +DATA/dev/onlinelog/group_6.268.879682607
    
    SQL>  
    
    SQL> select group#,status from v$log;
    
        GROUP# STATUS
    ---------- ----------------
             1 ACTIVE
             4 ACTIVE
             5 CURRENT
             6 UNUSED
    
    SQL> alter system switch logfile;
    
    System altered.
    
    SQL> select group#,status from v$log;
    
        GROUP# STATUS
    ---------- ----------------
             1 ACTIVE
             4 ACTIVE
             5 ACTIVE
             6 CURRENT
    
    
    SQL> alter system checkpoint;
    
    System altered.
    
    SQL> select group#,status from v$log;
    
        GROUP# STATUS
    ---------- ----------------
             1 INACTIVE
             4 CURRENT
             5 INACTIVE
             6 INACTIVE
    
    SQL> alter database drop logfile group 1;
    
    Database altered.
    
    SQL>