Sunday, May 11, 2014

Extending the filesystem using Logical Volume and starting the database in Linux_VM

I did the following steps. In this method,
I lost the data but I had a backup in another location.
So, I moved the backup data. Since these are related to Oracle binaries,
I need to change permissions and was able to bring back ASM and oracle database online without any issues.


1. create a new partition (/dev/sde2) as physical volume.


[root@vm1 ~]# pvcreate /dev/sde2
  Physical volume "/dev/sde2" successfully created
[root@vm1 ~]#


[root@vm1 ~]# pvdisplay
  "/dev/sde2" is a new physical volume of "10.00 GB"
  --- NEW Physical volume ---
  PV Name               /dev/sde2
  VG Name
  PV Size               10.00 GB
  Allocatable           NO
  PE Size (KByte)       0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               5Uif87-D6KP-QRCk-D5Ap-l2ju-9EWc-FrxfJ6

[root@vm1 ~]#

2. Create a new volume group .


[root@vm1 ~]# vgcreate vg1 /dev/sde2
  Volume group "vg1" successfully created

  [root@vm1 ~]# lvcreate -n lv_1 -L9.99G vg1
  Rounding up size to full physical extent 9.99 GB
  Logical volume "lv_1" created

 
  [root@vm1 ~]# vgdisplay
  --- Volume group ---
  VG Name               vg1
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               10.00 GB
  PE Size               4.00 MB
  Total PE              2559
  Alloc PE / Size       2558 / 9.99 GB
  Free  PE / Size       1 / 4.00 MB
  VG UUID               mbztlc-JvLo-Jh5l-hDDP-HbeY-2m93-klcyxZ

[root@vm1 ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg1/lv_1
  VG Name                vg1
  LV UUID                WZuzgv-pbGd-aTf3-ctWx-z1Us-ajd1-aolAIr
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                9.99 GB
  Current LE             2558
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

[root@vm1 ~]#

3. Format the new partition to use as ext3.

[root@vm1 ~]# mkfs.ext3 /dev/vg1/lv_1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1310720 inodes, 2619392 blocks
130969 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@vm1 ~]#

4.Take backup of the data in /u01 mount point to another location using
Code:
 cp -r /u01/* /backupu01/

5. Unmount the mount point /u01 and create a physical volume for the old partition /dev/sde1
[root@vm1 ~]# umount /u01
[root@vm1 ~]#

[root@vm1 ~]# pvcreate /dev/sde1
  Physical volume "/dev/sde1" successfully created
[root@vm1 ~]#


[root@vm1 ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sde2
  VG Name               vg1
  PV Size               10.00 GB / not usable 4.00 MB
  Allocatable           yes
  PE Size (KByte)       4096
  Total PE              2559
  Free PE               1
  Allocated PE          2558
  PV UUID               5Uif87-D6KP-QRCk-D5Ap-l2ju-9EWc-FrxfJ6

  "/dev/sde1" is a new physical volume of "10.00 GB"
  --- NEW Physical volume ---
  PV Name               /dev/sde1
  VG Name
  PV Size               10.00 GB
  Allocatable           NO
  PE Size (KByte)       0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               AGatSG-0uAO-nxL7-LItd-83ov-AFN8-5jKUcH

 
  6. Extend the volume group vg1 which was created before.
Code:

[root@vm1 ~]# vgextend vg1 /dev/sde1
  Volume group "vg1" successfully extended
[root@vm1 ~]#

[root@vm1 ~]# vgdisplay
  --- Volume group ---
  VG Name               vg1
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               19.99 GB
  PE Size               4.00 MB
  Total PE              5118
  Alloc PE / Size       2558 / 9.99 GB
  Free  PE / Size       2560 / 10.00 GB
  VG UUID               mbztlc-JvLo-Jh5l-hDDP-HbeY-2m93-klcyxZ

[root@vm1 ~]#

7. Extend the logical volume another 10G.

[root@vm1 ~]# lvextend -L +10G /dev/vg1/lv_1
  Extending logical volume lv_1 to 19.99 GB
  Logical volume lv_1 successfully resized

 
  8. Resize the logical volume.
 
  [root@vm1 ~]# resize2fs /dev/vg1/lv_1
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/vg1/lv_1 to 5240832 (4k) blocks.
The filesystem on /dev/vg1/lv_1 is now 5240832 blocks long.

[root@vm1 ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg1/lv_1
  VG Name                vg1
  LV UUID                WZuzgv-pbGd-aTf3-ctWx-z1Us-ajd1-aolAIr
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                19.99 GB
  Current LE             5118
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

[root@vm1 ~]#


9. Now, if you see in /u01 directory, you will not see any files and everything was lost.  
 But , I had the backup. But still my fingers were crossed cos I was not sure whether
I would be able to bring my storage instance (ASM) and oracle db which are under different users "grid" and "oracle".

Lets see in next step what happens.

10. Now, I copy my backup files back to /u01 location.

 cp -r /backupu01/*  /u01


11. Once, all the files are copied, I need to change the permissions for the directory appropriately.
[root@vm1 app]#  chown -R grid:oinstall /u01/app/grid/
[root@vm1 app]# chmod 755 -R /u01/app/grid/


12. Then, login as grid and started the clusterware and asm.
[grid@vm1 ~]$ crsctl start has
CRS-4123: Oracle High Availability Services has been started.
[grid@vm1 ~]$ srvctl start asm
PRCC-1014 : asm was already running
PRCR-1004 : Resource ora.asm is already running
PRCR-1079 : Failed to start resource ora.asm


[root@vm1 baku01]# chown -R oracle:oinstall /u01/app/oracle/
[root@vm1 baku01]# chmod 755 -R /u01/app/oracle/



ASMCMD> cd DATA
ASMCMD> ls
ASM/
ORCL/
ASMCMD> cd ASM
ASMCMD> cd ..
ASMCMD> cd ORCL
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
archivelog/
spfileorcl.ora
ASMCMD> exit

13. Then, I logged in as oracle user and tried to bring up the db and got below error message
For starting for the database


SQL> startup
ORA-01078: failure in processing system parameters
ORA-01565: error in identifying file '+DATA/orcl/spfileorcl.ora'
ORA-17503: ksfdopn:2 Failed to open file +DATA/orcl/spfileorcl.ora
ORA-12547: TNS:lost contact
SQL> create pfile from spfile='+DATA/orcl/spfileorcl.ora';
create pfile from spfile='+DATA/orcl/spfileorcl.ora'
*
ERROR at line 1:
ORA-01565: error in identifying file '+DATA/orcl/spfileorcl.ora'
ORA-17503: ksfdopn:2 Failed to open file +DATA/orcl/spfileorcl.ora
ORA-12547: TNS:lost contact


15. Change the permissions as below (refer metalink
Quote:

REfer metalink (1307075.1)

The issue is caused by incorrect permission of $GRID_HOME/bin/oracle and $ORACLE_HOME/bin/oracle,
which lead to connection failure to ASM instance:


ls -al $GRID_HOME/bin/oracle
-rwxr-x--x 1 grid oinstall 200678464 Feb 28 14:54 oracle

ls -al $ORACLE_HOME/bin/oracle
-rwxr-x--x 1 oracle asmadmin 228886191 Feb 28 15:41 oracle



Oracle binary should have permission of 6751. To correct the permission, as owner of oracle binary:

cd $GRID_HOME/bin
chmod 6751 oracle

cd $ORACLE_HOME/bin
chmod 6751 oracle
 After the change, permission should show:

ls -l $GRID_HOME/bin/oracle
-rwsr-s--x 1 grid oinstall 203974257 May 11 09:30 oracle

ls -l $ORACLE_HOME/bin/oracle
-rwsr-s--x 1 oracle asmadmin 232399431 May 14 13:47 oracle
 Once the permission is fixed, if database still fails to come up, restart Grid Infrastructure.



 [oracle@vm1 bin]$ sqlplus sys as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Tue Jan 21 22:54:35 2014

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

Enter password:
Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  304807936 bytes
Fixed Size                  2227864 bytes
Variable Size             230687080 bytes
Database Buffers           67108864 bytes
Redo Buffers                4784128 bytes
Database mounted.
Database opened.
SQL> exit


16. Once the permission is fixed, if database still fails to come up, restart Grid Infrastructure.


Now I am able to extend the space.
In future, I can add more partitions easily as it due to LV. Also, I am able to bring my databases back online.


SQL> startup
ORA-01078: failure in processing system parameters
ORA-01565: error in identifying file '+DATA/orcl/spfileorcl.ora'
ORA-17503: ksfdopn:2 Failed to open file +DATA/orcl/spfileorcl.ora
ORA-12547: TNS:lost contact
SQL> exit
Disconnected



 Steps posted on forum

No comments:

Post a Comment