Wednesday, 31 January 2018

Moving Controlfile in ASM from one diskgroup to another diskgroup

Step by Step Moving Controlfile in ASM from one diskgroup to another diskgroup

[oracle@testdb ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jan 31 14:31:34 2018

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
   
[grid@testdb ~]$ asmcmd
ASMCMD> lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  NORMAL  N         512   4096  1048576     10228    10122                0            5061              0             N  ARCH/
MOUNTED  NORMAL  N         512   4096  1048576     10228     7040                0            3520              0             N  DATA/
MOUNTED  NORMAL  N         512   4096  1048576     10228     9620                0            4810              0             N  FRA/

-- Checking Controlfile Location

SQL> show parameter control

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      +DATA/testdb/controlfile/curre
                                                 nt.260.966829689, +FRA/testdb/
                                                 controlfile/current.256.966829
                                                 691
control_management_pack_access       string      DIAGNOSTIC+TUNING
SQL>


-- Moving Controlfile from +FRA to +ARCH

SQL> alter system set control_files='+DATA/testdb/controlfile/current.260.966829689','+ARCH/TESTDB/CONTROLFILE/control02.ctl' scope=spfile;

System altered.

-- Now shutting down the Database

SQL>

[grid@testdb ~]$ cd /u01/app/11.2.0/grid/bin/

[grid@testdb bin]$ srvctl stop database -d testdb -o immediate;

[[grid@testdb bin]$ srvctl status database -d testdb
Database is not running.

-- Copy controlfile to new location

[grid@testdb bin]$ asmcmd

ASMCMD> cd arch

ASMCMD> pwd
+arch
ASMCMD> ls
TESTDB/
ASMCMD> cd TESTDB
ASMCMD> mkdir CONTROLFILE

ASMCMD> cp +DATA/testdb/controlfile/current.260.966829689 +ARCH/TESTDB/CONTROLFILE/control02.ctl
copying +DATA/testdb/controlfile/current.260.966829689 -> +ARCH/TESTDB/CONTROLFILE/control02.ctl
ASMCMD>

-- Starting the Database up

[grid@testdb bin]$ pwd
/u01/app/11.2.0/grid/bin

[grid@testdb bin]$ ./srvctl start database -d testdb

[grid@testdb bin]$ ./srvctl status database -d testdb
Database is running.
[grid@testdb bin]$

--Checking Controlfile on new location

SQL> show parameter control

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      +DATA/testdb/controlfile/curre
                                                 nt.260.966829689, +ARCH/testdb
                                                 /controlfile/control02.ctl
control_management_pack_access       string      DIAGNOSTIC+TUNING
SQL>


Installing Grid Infrastructure for Single Instance (Oracle Restart) /Configuring Single instance Database on ASM


 Implementing GI for single Instance (Oracle Restart)

Configuring Oracle Parameter
Oracle restart is when we implement GI for single instance database, than we call it as oracle restarts, and you can use service utilities on it.
Below are the steps starting from oracle installation till Database creation on ASM Disk Groups:

vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
192.168.1.20            testdb
::1             localhost6.localdomain6 localhost6
Parameter Setting
Oracle recommend the following minimum parameter settings.
Vi /etc/sysctl.conf
    fs.suid_dumpable = 1
    fs.aio-max-nr = 1048576
    fs.file-max = 6815744
    kernel.shmall = 2097152
    kernel.shmmax = 536870912
    kernel.shmmni = 4096
    kernel.sem = 250 32000 100 128
    net.ipv4.ip_local_port_range = 9000 65500
    net.core.rmem_default = 262144
    net.core.rmem_max = 4194304
    net.core.wmem_default = 262144
    net.core.wmem_max = 1048586

Run the following command to change the current kernel parameters.
    /sbin/sysctl –p


Adding Security Limits
Add the following lines to the "/etc/security/limits.conf" file.

    oracle              soft    nproc   2047
    oracle              hard    nproc   16384
    oracle              soft    nofile  4096
    oracle              hard    nofile  65536
    oracle              soft    stack   10240
grid              soft    nproc   2047
    grid              hard    nproc   16384
    grid              soft    nofile  1024
    grid              hard    nofile  65536

Package Installation

nstall the following packages if they are not already present.

    # From Oracle Linux 5 DVD
    cd /media/cdrom/Server
    rpm -Uvh --force --nodeps binutils-2.*
    rpm -Uvh --force --nodeps compat-libstdc++-33*
    rpm -Uvh --force --nodeps compat-libstdc++-33*.i386.rpm
    rpm -Uvh --force --nodeps elfutils-libelf*
    rpm -Uvh --force --nodeps glibc-2.*
    rpm -Uvh --force --nodeps glibc-common-2.*
    rpm -Uvh --force --nodeps glibc-devel-2.*
    rpm -Uvh --force --nodeps glibc-headers-2.*
    rpm -Uvh --force --nodeps gcc-4.*
    rpm -Uvh --force --nodeps gcc-c++-4.*
    rpm -Uvh --force --nodeps ksh*
    rpm -Uvh --force --nodeps libaio-0.*
    rpm -Uvh --force --nodeps libaio-devel-0.*
    rpm -Uvh --force --nodeps libgomp-4.*
    rpm -Uvh --force --nodeps libgcc-4.*
    rpm -Uvh --force --nodeps libstdc++-4.*
    rpm -Uvh --force --nodeps libstdc++-devel-4.*
    rpm -Uvh --force --nodeps make-3.*
    rpm -Uvh --force --nodeps sysstat-7.*
    rpm -Uvh --force --nodeps unixODBC-2.*
    rpm -Uvh --force --nodeps unixODBC-devel-2.*
    rpm -Uvh --force --nodeps numactl-devel-*
    cd /

Create users and groups:

#groupadd -g 501 oinstall
#groupadd -g 502 dba
#groupadd -g 503 oper
#groupadd -g 504 asmadmin
#groupadd -g 506 asmdba
#groupadd -g 507 asmoper

# /usr/sbin/useradd -g oinstall -G asmadmin,asmdba,asmoper,dba -d /home/grid -m grid

# /usr/sbin/useradd -g oinstall -G dba,asmdba,oper -d /home/oracle -m oracle

Set new password for oracle user:

#passwd grid
#passwd oracle

Create the Oracle Inventory Directory

To create the Oracle Inventory directory, enter the following commands as the root user:

# mkdir -p /u01/app/oraInventory
# chown -R grid:oinstall /u01/app/oraInventory
# chmod -R 775 /u01/app/oraInventory


Create the Oracle Grid Infrastructure Home Directory

To create the Grid Infrastructure home directory, enter the following commands as the root user:

# mkdir -p /u01/app/11.2.0/grid
# chown -R grid:oinstall /u01/app/11.2.0/grid
# chmod -R 775 /u01/app/11.2.0/grid

# mkdir -p /u01/app/grid
# chown -R grid:oinstall /u01/app/grid
# chmod -R 775 /u01/app/grid


Create the Oracle Base Directory

To create the Oracle Base directory, enter the following commands as the root user:

# mkdir -p /u01/app/oracle
# mkdir /u01/app/oracle/cfgtoollogs --needed to ensure that dbca is able to run after the rdbms installation.
# chown -R oracle:oinstall /u01/app/oracle
# chmod -R 775 /u01/app/oracle

Create the Oracle RDBMS Home Directory

To create the Oracle RDBMS Home directory, enter the following commands as the root user:

# mkdir -p /u01/app/oracle/product/11.2.0
# chown -R oracle:oinstall /u01/app/oracle/product/11.2.0
# chmod -R 775 /u01/app/oracle/product/11.2.0

Edit the ‘/home/grid/.bash_profile’ file on first Oracle RAC Node for Oracle Grid Infrastructure Installation:

# Oracle 11gR2 Grid Infrastructure environment
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/u01/app/grid

Edit the ‘/home/oracle/.bash_profile’ file on first Oracle RAC Node for Oracle RDBMS Installation:

# Oracle 11gR2 RDBMS environment
# Oracle Settings
    TMP=/tmp; export TMP
    TMPDIR=$TMP; export TMPDIR

    ORACLE_HOSTNAME=testdb; export ORACLE_HOSTNAME
    ORACLE_UNQNAME=testdb; export ORACLE_UNQNAME
    ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
    ORACLE_HOME=$ORACLE_BASE/product/11.2.0; export ORACLE_HOME
    ORACLE_SID=testdb; export ORACLE_SID
    PATH=/usr/sbin:$PATH; export PATH
    PATH=$ORACLE_HOME/bin:$PATH; export PATH

    LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
    CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

Now installing packages for ASMLIB
[root@testdb Server]# pwd
/media/Enterprise Linux dvd 20080528/Server
[root@testdb Server]# rpm -Uvh --force --nodeps oracleasm-support-2.0.4-1.el5.i386.rpm
warning: oracleasm-support-2.0.4-1.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing...                ########################################### [100%]
   1:oracleasm-support      ########################################### [100%]
[root@testdb Server]# rpm -Uvh --force --nodeps oracleasm-2.6.18-92.el5-2.0.4-1.el5.i686.rpm
warning: oracleasm-2.6.18-92.el5-2.0.4-1.el5.i686.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing...                ########################################### [100%]
   1:oracleasm-2.6.18-92.el5########################################### [100%]
[root@testdb Server]# cd /u01/
[root@testdb u01]# rpm -Uvh --force --nodeps oracleasmlib-2.0.4-1.el5.i386.rpm
warning: oracleasmlib-2.0.4-1.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing...                ########################################### [100%]
   1:oracleasmlib           ########################################### [100%]
[root@testdb u01]# rpm -Uvh --force --nodeps oracleasm-2.6.18-92.el5PAE-2.0.4-1.el5.i686.rpm
[root@testdb u01]#

Now Unzipping the Grid Software
cd /u01
unzip linux_11gR2_grid.zip

Partitioning the Disks added

[root@testdb ~]# fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         637     5116671   83  Linux
/dev/sda2             638        1790     9261472+  82  Linux swap / Solaris
/dev/sda3            1791        2487     5598652+  83  Linux
/dev/sda4            2488        5221    21960855    5  Extended
/dev/sda5            2488        3124     5116671   83  Linux
/dev/sda6            3125        5221    16844121   83  Linux

Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdd: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdd doesn't contain a valid partition table

Disk /dev/sde: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sde doesn't contain a valid partition table

Disk /dev/sdf: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdf doesn't contain a valid partition table

Disk /dev/sdg: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdg doesn't contain a valid partition table

[root@testdb ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-652, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-652, default 652):
Using default value 652

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Similarly for all others
[root@testdb ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-652, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-652, default 652):
Using default value 652

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Creating ASM Volume Disks:

#
[root@testdb Server]# /etc/init.d/oracleasm createdisk disk1 /dev/sdb1
Marking disk "/dev/sdb1" as an ASM disk: [  OK  ]
[root@testdb Server]# /etc/init.d/oracleasm createdisk disk2 /dev/sdc1
Marking disk "/dev/sdc1" as an ASM disk: [  OK  ]
[root@testdb Server]# /etc/init.d/oracleasm createdisk disk3 /dev/sdd1
Marking disk "/dev/sdd1" as an ASM disk: [  OK  ]
[root@testdb Server]# /etc/init.d/oracleasm createdisk disk4 /dev/sde1
Marking disk "/dev/sde1" as an ASM disk: [  OK  ]
[root@testdb Server]# /etc/init.d/oracleasm createdisk disk5 /dev/sdf1
Marking disk "/dev/sdf1" as an ASM disk: [  OK  ]
[root@testdb Server]# /etc/init.d/oracleasm createdisk disk6 /dev/sdg1
Marking disk "/dev/sdg1" as an ASM disk: [  OK  ]
[root@testdb Server]#

Listing the Created Disks:
[root@testdb Server]# /etc/init.d/oracleasm listdisks
DISK1
DISK2
DISK3
DISK4
DISK5
DISK6
[root@testdb Server]#
Now Run GI SW to install GI and making DG






















Installing Oracle Software & Database Creation:
Login through oracle user:















Configuring Listener









Configuring DB


















Installing Oracle 11g on Linux

Unpack Files Unzip the files. # 11.2.0.1 unzip linux.x64_11gR2_database_1of2.zip unzip linux.x64_11gR2_database_2of2.zip #11.2.0.2 u...