首页 » ORACLE, 系统相关 » oracle ASM on LVM (linux卷管理),配置LVM

oracle ASM on LVM (linux卷管理),配置LVM

LVM在后期因先前指定的路径空间不够时调整起来很方便,也可以就用于ASM,但是并不推荐ASM安装在LVM之上,因为LVM的功能在ASM上已存在。

[root@rac1 ~]# fdisk -l
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

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

1,CREATE DISK PARTITIONS

[root@rac1 ~]# fdisk /dev/sdb

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

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

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

[root@rac1 ~]# fdisk -l
..
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1605    12892131   83  Linux
/dev/sdb2            1606        2610     8072662+  83  Linux

2,CREATE Physical Volumes

[root@rac1 ~]# pvcreate /dev/sdb1 /dev/sdb2

[root@rac1 ~]# pvdisplay 
  "/dev/sdb1" is a new physical volume of "12.29 GB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name               
  PV Size               12.29 GB
  Allocatable           NO
  PE Size (KByte)       0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               wdPTFe-4HjL-H7zN-PXlh-l3qk-9kFX-Z7ryWd
   
  "/dev/sdb2" is a new physical volume of "7.70 GB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb2
  VG Name               
  PV Size               7.70 GB
  Allocatable           NO
  PE Size (KByte)       0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               PUt7Xd-Pl9o-6xfa-xth3-LSkc-AXGz-JPgAw6

3,Create  Volume Group
  
[root@rac1 ~]# vgcreate vgtest /dev/sdb1
  Volume group "vgtest" successfully created
[root@rac1 ~]# vgcreate vgtest /dev/sdb2
  A volume group called vgtest already exists.
[root@rac1 ~]# vgextend vgtest /dev/sdb2      
  Volume group "vgtest" successfully extended
[root@rac1 ~]# vgdisplay 
  --- Volume group ---
  VG Name               vgtest
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               19.99 GB
  PE Size               4.00 MB
  Total PE              5117
  Alloc PE / Size       0 / 0   
  Free  PE / Size       5117 / 19.99 GB
  VG UUID               UuS0QK-AIar-uvXO-vk3U-rLlK-8MyS-z122nT
 
4,Create Logical Volumes
 
[root@rac1 ~]# lvcreate -L 1G -n oracle_asm01 vgtest
  Logical volume "oracle_asm01" created
[root@rac1 ~]# lvcreate -L 1G -n oracle_asm02 vgtest
  Logical volume "oracle_asm02" created
[root@rac1 ~]# lvcreate -L 1G -n oracle_asm03 vgtest
  Logical volume "oracle_asm03" created
  [root@rac1 ~]# lvcreate -L 5G -n oracle_soft vgtest  
  Logical volume "oracle_soft" created
[root@rac1 ~]# lvdisplay 
  --- Logical volume ---
  LV Name                /dev/vgtest/oracle_asm01
  VG Name                vgtest
  LV UUID                LYIREw-rSha-9wDh-kpkF-a0or-kY5s-a4FdmA
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                1.00 GB
  Current LE             256
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
   
  --- Logical volume ---
  LV Name                /dev/vgtest/oracle_asm02
  VG Name                vgtest
  LV UUID                D7onU9-EzWF-lSRu-1g8I-0JQm-jPZV-zR2mH6
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                1.00 GB
  Current LE             256
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
   
  --- Logical volume ---
  LV Name                /dev/vgtest/oracle_asm03
  VG Name                vgtest
  LV UUID                k1jC8S-kwHt-cSG4-iHHN-HmVj-w8Xu-fQtII6
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                1.00 GB
  Current LE             256
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2
   
  --- Logical volume ---
  LV Name                /dev/vgtest/oracle_soft
  VG Name                vgtest
  LV UUID                c0hOlT-dPPp-4yF3-Pd6T-uiRQ-hMWn-kWdaz2
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                5.00 GB
  Current LE             1280
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

5,mount oracle_soft and mack file-system  
[root@rac1 ~]# ll /dev/vgtest/*
lrwxrwxrwx 1 root root 31 Jul 11 14:03 /dev/vgtest/oracle_asm01 -> /dev/mapper/vgtest-oracle_asm01
lrwxrwxrwx 1 root root 31 Jul 11 14:03 /dev/vgtest/oracle_asm02 -> /dev/mapper/vgtest-oracle_asm02
lrwxrwxrwx 1 root root 31 Jul 11 14:03 /dev/vgtest/oracle_asm03 -> /dev/mapper/vgtest-oracle_asm03
lrwxrwxrwx 1 root root 30 Jul 11 14:07 /dev/vgtest/oracle_soft -> /dev/mapper/vgtest-oracle_soft

[root@rac1 dev]# mkfs.ext3 /dev/vgtest/oracle_soft 
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
655360 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 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

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

This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@rac1 dev]# cd /
[root@rac1 /]# mkdir u01
[root@rac1 /]# mount /dev/vgtest/oracle_soft /u01
[root@rac1 /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5              15G  3.3G   11G  25% /
/dev/sda3             996M   34M  911M   4% /tmp
/dev/sda1              99M   21M   74M  22% /boot
tmpfs                1007M     0 1007M   0% /dev/shm
/dev/mapper/vgtest-oracle_soft
                      5.0G  139M  4.6G   3% /u01

6, resize oracle_soft LV(if not enough free disk space)
[root@rac1 /]# vgdisplay
  --- Volume group ---
  VG Name               vgtest
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                4
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               19.99 GB
  PE Size               4.00 MB
  Total PE              5117
  Alloc PE / Size       2048 / 8.00 GB
  Free  PE / Size       3069 / 11.99 GB
  VG UUID               UuS0QK-AIar-uvXO-vk3U-rLlK-8MyS-z122nT

[root@rac1 /]# lvextend -L +2G /dev/vgtest/oracle_soft
  Extending logical volume oracle_soft to 7.00 GB
  Logical volume oracle_soft successfully resized
[root@rac1 /]# resize2fs /dev/vgtest/oracle_soft 7G
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vgtest/oracle_soft is mounted on /u01; on-line resizing required
Performing an on-line resize of /dev/vgtest/oracle_soft to 1835008 (4k) blocks.
The filesystem on /dev/vgtest/oracle_soft is now 1835008 blocks long.

[root@rac1 /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5              15G  3.3G   11G  25% /
/dev/sda3             996M   34M  911M   4% /tmp
/dev/sda1              99M   21M   74M  22% /boot
tmpfs                1007M     0 1007M   0% /dev/shm
/dev/mapper/vgtest-oracle_soft
                      6.9G  140M  6.5G   3% /u01  

7,Create ORACLE ASM and Change device permissions
[root@rac1 /]# cd /dev/mapper/
[root@rac1 mapper]# ll
total 0
crw------- 1 root root  10, 62 Jul 11 15:41 control
brw-rw---- 1 root disk 253,  0 Jul 11 15:41 vgtest-oracle_asm01
brw-rw---- 1 root disk 253,  1 Jul 11 15:41 vgtest-oracle_asm02
brw-rw---- 1 root disk 253,  2 Jul 11 15:41 vgtest-oracle_asm03
brw-rw---- 1 root disk 253,  3 Jul 11 15:41 vgtest-oracle_soft

chown grid:oinstall vgtest-oracle_asm*
chmod 660 vgtest-oracle_asm*

8,Create ASM diskgroups(11g or later can use ASMCA Utility)
SQL> alter system set  asm_diskstring =’/dev/mapper/vgtest-oracle_asm*’
sql>create diskgroup dg01 external redundancy disk '/dev/mapper/vgtest-oracle_asm01'
sql>create diskgroup dg02 external redundancy disk '/dev/mapper/vgtest-oracle_asm02'
sql>create diskgroup dg03 external redundancy disk '/dev/mapper/vgtest-oracle_asm03'

"Note: Do not add logical volumes to Automatic Storage Management disk groups. Automatic Storage Management works best when you add raw disk devices to disk groups. If you are using Automatic Storage Management, then do not use LVM for striping. Automatic Storage Management implements striping and mirroring."

extend read				  
http://www.anbob.com/?p=1069
http://www.anbob.com/?p=1430

打赏

对不起,这篇文章暂时关闭评论。