189 8069 5689

基于RHEL6.5安装Oracle11g详细教程(9)——附录

9  附录

9.1  Linux LVM
9.1.1  LVM简介

    LVM是 Logical Volume Manager(逻辑卷管理)的简写,它由Heinz Mauelshagen在Linux 2.4内核上实现。LVM将一个或多个硬盘的分区在逻辑上集合,相当于一个大硬盘来使用,当硬盘的空间不够使用的时候,可以继续将其它的硬盘的分区加入其中,这样可以实现磁盘空间的动态管理,相对于普通的磁盘分区有很大的灵活性。

专注于为中小企业提供成都网站建设、成都网站设计服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业嵊州免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了近千家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

    与传统的磁盘与分区相比,LVM为计算机提供了更高层次的磁盘存储。它使系统管理员可以更方便的为应用与用户分配存储空间。在LVM管理下的存储卷可以按需要随时改变大小与移除(可能需对文件系统工具进行升级)。LVM也允许按用户组对存储卷进行管理,允许管理员用更直观的名称(如“sales”、“development” )代替物理磁盘名(如“sda”、“sdb”)来标识存储卷。

如图所示LVM模型:

基于RHEL 6.5安装Oracle 11g详细教程(9)——附录

    由四个磁盘分区可以组成一个很大的空间,然后在这些空间上划分一些逻辑分区,当一个逻辑分区的空间不够用的时候,可以从剩余空间上划分一些空间给空间不够用的分区使用。

9.1.2  LVM基本术语

    前面谈到,LVM是在磁盘分区和文件系统之间添加的一个逻辑层,来为文件系统屏蔽下层磁盘分区布局,提供一个抽象的盘卷,在盘卷上建立文件系统。首先我们讨论以下几个LVM术语:

    物理存储介质(The physical media):这里指系统的存储设备:硬盘,如:/dev/hda1、/dev/sda等等,是存储系统最低层的存储单元。

    物理卷(Physical Volume):物理卷就是指硬盘分区或从逻辑上与磁盘分区具有同样功能的设备(如RAID),是LVM的基本存储逻辑块,但和基本的物理存储介质(如分区、磁盘等)比较,却包含有与LVM相关的管理参数。

    卷组(Volume Group):LVM卷组类似于非LVM系统中的物理硬盘,其由物理卷组成。可以在卷组上创建一个或多个“LVM分区”(逻辑卷),LVM卷组由一个或多个物理卷组成。

    逻辑卷(Logical Volume):LVM的逻辑卷类似于非LVM系统中的硬盘分区,在逻辑卷之上可以建立文件系统(比如/home或者/usr等)。

    PE(Physical Extent):每一个物理卷被划分为称为PE(Physical Extents)的基本单元,具有唯一编号的PE是可以被LVM寻址的最小单元。PE的大小是可配置的,默认为4MB。

    LE(Logical Extent):逻辑卷也被划分为被称为LE(Logical Extents) 的可被寻址的基本单位。在同一个卷组中,LE的大小和PE是相同的,并且一一对应。

简单来说就是:

    PV:是物理的磁盘分区

    VG:LVM中的物理的磁盘分区,也就是PV,必须加入VG,可以将VG理解为一个仓库或者是几个大的硬盘。

    LV:也就是从VG中划分的逻辑分区

如下图所示PV、VG、LV三者关系:

基于RHEL 6.5安装Oracle 11g详细教程(9)——附录

9.1.3 安装LVM

首先确定系统中是否安装了lvm工具:

[root@rhel65 ~]# rpm -qa | grep lvm

mesa-private-llvm-3.3-0.3.rc3.el6.x86_64

lvm2-libs-2.02.100-8.el6.x86_64

lvm2-2.02.100-8.el6.x86_64

如果命令结果输入类似于上例,那么说明系统已经安装了LVM管理工具;如果命令没有输出则说明没有安装LVM管理工具,则需要从网络下载或者从光盘装LVM rpm工具包。

9.1.4 创建和管理LVM

要创建一个LVM系统,一般需要经过以下步骤:

1、创建分区

使用分区工具(如:fdisk等)创建LVM分区,方法和创建其他一般分区的方式是一样的,区别仅仅是LVM的分区类型为8e。

[root@rhel65 ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes

64 heads, 32 sectors/track, 20480 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000059fe

Device Boot Start End Blocks Id System

/dev/sda1 * 2 501 512000 83 Linux

/dev/sda2 502 20480 20458496 8e Linux LVM

Disk /dev/mapper/VolGroup-lv_root: 18.8 GB, 18798870528 bytes

255 heads, 63 sectors/track, 2285 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-lv_swap: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Disk /dev/sdb: 53.7 GB, 53687091200 bytes

64 heads, 32 sectors/track, 51200 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

使用fdisk创建分区,根据设备文件的绝对路径(/dev/hda)进入分区管理

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

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x4849a8f8.

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)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

switch off the mode (command 'c') and change display units to

sectors (command 'u').

Command (m for help): m

Command action

a toggle a bootable flag

b edit bsd disklabel

c toggle the dos compatibility flag

d delete a partition

l list known partition types

m print this menu

n add a new partition

o create a new empty DOS partition table

p print the partition table

q quit without saving changes

s create a new empty Sun disklabel

t change a partition's system id

u change display/entry units

v verify the partition table

w write table to disk and exit

x extra functionality (experts only)

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-51200, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-51200, default 51200): +10G

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): L

0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris

1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-

2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-

3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-

4 FAT16 <32M 41 PPC PReP Boot 85 Linux extended c7 Syrinx

5 Extended 42 SFS 86 NTFS volume set da Non-FS data

6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / .

7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility

8 AIX 4f QNX4.x 3rd part 8e Linux LVM df BootIt

9 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access

a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O

b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor

c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs

e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT

f W95 Ext'd (LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/

10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b

11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor

12 Compaq diagnost 61 SpeedStor a9 NetBSD f4 SpeedStor

14 Hidden FAT16 <3 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary

16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS

17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE

18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto

1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep

1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT

1e Hidden W95 FAT1

Hex code (type L to list codes): 8e

Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdb: 53.7 GB, 53687091200 bytes

64 heads, 32 sectors/track, 51200 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x4849a8f8

Device Boot Start End Blocks Id System

/dev/sdb1 1 10241 10486768 8e Linux LVM

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@rhel65 ~]# partprobe

[root@rhel65 ~]# mkfs -t ext4 /dev/sdb1

mke2fs 1.41.12 (17-May-2010)

warning: 256 blocks unused.

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe blocks

656640 inodes, 2621440 blocks

131084 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

8208 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 23 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

一定要指定分区的格式为8e,这是LVM的分区格式

2、创建PV

[root@rhel65 ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes

64 heads, 32 sectors/track, 20480 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000059fe

Device Boot Start End Blocks Id System

/dev/sda1 * 2 501 512000 83 Linux

/dev/sda2 502 20480 20458496 8e Linux LVM

Disk /dev/mapper/VolGroup-lv_root: 18.8 GB, 18798870528 bytes

255 heads, 63 sectors/track, 2285 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-lv_swap: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Disk /dev/sdb: 53.7 GB, 53687091200 bytes

64 heads, 32 sectors/track, 51200 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x4849a8f8

Device Boot Start End Blocks Id System

/dev/sdb1 1 10241 10486768 8e Linux LVM

[root@rhel65 ~]# pvdisplay

--- Physical volume ---

PV Name /dev/sda2

VG Name VolGroup

PV Size 19.51 GiB / not usable 3.00 MiB

Allocatable yes (but full)

PE Size 4.00 MiB

Total PE 4994

Free PE 0

Allocated PE 4994

PV UUID ISzl0X-XuA1-aG63-IdZH-HqKS-XuRm-DrzKM8

[root@rhel65 ~]# pvcreate /dev/sdb1

Physical volume "/dev/sdb1" successfully created

[root@rhel65 ~]# pvdisplay

--- Physical volume ---

PV Name /dev/sda2

VG Name VolGroup

PV Size 19.51 GiB / not usable 3.00 MiB

Allocatable yes (but full)

PE Size 4.00 MiB

Total PE 4994

Free PE 0

Allocated PE 4994

PV UUID ISzl0X-XuA1-aG63-IdZH-HqKS-XuRm-DrzKM8

"/dev/sdb1" is a new physical volume of "10.00 GiB"

--- NEW Physical volume ---

PV Name /dev/sdb1

VG Name

PV Size 10.00 GiB

Allocatable NO

PE Size 0

Total PE 0

Free PE 0

Allocated PE 0

PV UUID 67HlFe-THuW-GtNS-Hih2-chFP-3tP9-brczra

3、创建VG

[root@rhel65 ~]# vgdisplay

--- Volume group ---

VG Name VolGroup

System ID

Format lvm2

Metadata Areas 1

Metadata Sequence No 3

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 2

Open LV 2

Max PV 0

Cur PV 1

Act PV 1

VG Size 19.51 GiB

PE Size 4.00 MiB

Total PE 4994

Alloc PE / Size 4994 / 19.51 GiB

Free PE / Size 0 / 0

VG UUID brWwTY-jesr-1lZw-lRfy-ZL7h-0nb4-3fRzgl

[root@rhel65 ~]# vgcreate VolGroup00 /dev/sdb1

Volume group "VolGroup00" successfully created

[root@rhel65 ~]# vgdisplay

--- Volume group ---

VG Name VolGroup00

System ID

Format lvm2

Metadata Areas 1

Metadata Sequence No 1

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 0

Open LV 0

Max PV 0

Cur PV 1

Act PV 1

VG Size 10.00 GiB

PE Size 4.00 MiB

Total PE 2559

Alloc PE / Size 0 / 0

Free PE / Size 2559 / 10.00 GiB

VG UUID IA2LQx-Jljz-nGhg-VtHj-t52q-URmK-u9LV0Z

--- Volume group ---

VG Name VolGroup

System ID

Format lvm2

Metadata Areas 1

Metadata Sequence No 3

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 2

Open LV 2

Max PV 0

Cur PV 1

Act PV 1

VG Size 19.51 GiB

PE Size 4.00 MiB

Total PE 4994

Alloc PE / Size 4994 / 19.51 GiB

Free PE / Size 0 / 0

VG UUID brWwTY-jesr-1lZw-lRfy-ZL7h-0nb4-3fRzgl

创建完成VG之后,才能从VG中划分一个LV。

4、创建LV

[root@rhel65 ~]# lvdisplay

--- Logical volume ---

LV Path /dev/VolGroup/lv_root

LV Name lv_root

VG Name VolGroup

LV UUID swKZLT-Cm7C-kkNH-AUGe-N9WY-q2bD-l9imoi

LV Write Access read/write

LV Creation host, time localhost.localdomain, 2014-05-12 03:14:21 +0800

LV Status available

# open 1

LV Size 17.51 GiB

Current LE 4482

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:0

--- Logical volume ---

LV Path /dev/VolGroup/lv_swap

LV Name lv_swap

VG Name VolGroup

LV UUID QGLb0h-Qtfe-yxzY-kLah-qnwX-FN7n-lIjxdW

LV Write Access read/write

LV Creation host, time localhost.localdomain, 2014-05-12 03:14:37 +0800

LV Status available

# open 1

LV Size 2.00 GiB

Current LE 512

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:1

[root@rhel65 ~]# lvcreate -L 5G -n lv_backup VolGroup00

Logical volume "lv_backup" created

[root@rhel65 ~]# lvdisplay

--- Logical volume ---

LV Path /dev/VolGroup00/lv_backup

LV Name lv_backup

VG Name VolGroup00

LV UUID hMOdIa-WZUL-ZGqQ-m5Jj-DrCf-KiPM-FNJRds

LV Write Access read/write

LV Creation host, time rhel65.kely.com, 2014-05-16 06:53:39 +0800

LV Status available

# open 0

LV Size 5.00 GiB

Current LE 1280

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:2

--- Logical volume ---

LV Path /dev/VolGroup/lv_root

LV Name lv_root

VG Name VolGroup

LV UUID swKZLT-Cm7C-kkNH-AUGe-N9WY-q2bD-l9imoi

LV Write Access read/write

LV Creation host, time localhost.localdomain, 2014-05-12 03:14:21 +0800

LV Status available

# open 1

LV Size 17.51 GiB

Current LE 4482

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:0

--- Logical volume ---

LV Path /dev/VolGroup/lv_swap

LV Name lv_swap

VG Name VolGroup

LV UUID QGLb0h-Qtfe-yxzY-kLah-qnwX-FN7n-lIjxdW

LV Write Access read/write

LV Creation host, time localhost.localdomain, 2014-05-12 03:14:37 +0800

LV Status available

# open 1

LV Size 2.00 GiB

Current LE 512

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:1

创建了一个名字为lv_backup,容量大小是5G的分区,其中:-L:指定LV的大小 -n:指定LV的名。VolGroup00:表示从这个VG中划分LV。

5、LV格式化及挂载

下一步需要对LV进行格式化(使用mksf进行格式化操作),然后LV才能存储资料

[root@rhel65 ~]# mkfs -t ext4 /dev/VolGroup00/lv_backup

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe blocks

327680 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

8192 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 20 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

[root@rhel65 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root 18G 3.0G 14G 19% /

tmpfs 2.0G 72K 2.0G 1% /dev/shm

/dev/sda1 485M 39M 421M 9% /boot

[root@rhel65 ~]# mkdir /backup

[root@rhel65 ~]# mount /dev/VolGroup00/lv_backup /backup/

[root@rhel65 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root 18G 3.0G 14G 19% /

tmpfs 2.0G 72K 2.0G 1% /dev/shm

/dev/sda1 485M 39M 421M 9% /boot

/dev/mapper/VolGroup00-lv_backup 5.0G 138M 4.6G 3% /backup

将格式化后的LV分区挂载到指定的目录下,就可以像普通目录一样存储数据了

挂载之后,可以看到此LV的容量。

如果要在系统启动的时候启动LV,最好是将lv_backup写入fstable 文件中,如下所示:

[root@rhel65 ~]# vi /etc/fstab

#

# /etc/fstab

# Created by anaconda on Mon May 12 03:15:06 2014

#

# Accessible filesystems, by reference, are maintained under '/dev/disk'

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

/dev/mapper/VolGroup-lv_root / ext4 defaults 1 1

UUID=374c9216-76f4-4e4b-a7a7-d7ecdd1d3740 /boot ext4 defaults 1 2

/dev/mapper/VolGroup-lv_swap swap swap defaults 0 0

tmpfs /dev/shm tmpfs defaults 0 0

devpts /dev/pts devpts gid=5,mode=620 0 0

sysfs /sys sysfs defaults 0 0

proc /proc proc defaults 0 0

/dev/mapper/VolGroup00-lv_backup /backup ext4 defaults 0 0

使用Vim编辑器,打开/etc/fstab,在最后一行添加如上所示,其中/dev/VolGroup00/lv_backup指定需要挂载的分区LV,/root/test指定要挂载的目录(挂载点),ext4分区文件系统格式,其它使用默认即可

9.1.5  LVM扩容

1、创建分区:

[root@rhel65 ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes

64 heads, 32 sectors/track, 20480 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000059fe

Device Boot Start End Blocks Id System

/dev/sda1 * 2 501 512000 83 Linux

/dev/sda2 502 20480 20458496 8e Linux LVM

Disk /dev/mapper/VolGroup-lv_root: 18.8 GB, 18798870528 bytes

255 heads, 63 sectors/track, 2285 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-lv_swap: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Disk /dev/sdb: 53.7 GB, 53687091200 bytes

64 heads, 32 sectors/track, 51200 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x4849a8f8

Device Boot Start End Blocks Id System

/dev/sdb1 1 10241 10486768 8e Linux LVM

Disk /dev/mapper/VolGroup00-lv_backup: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

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

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

switch off the mode (command 'c') and change display units to

sectors (command 'u').

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 2

First cylinder (10242-51200, default 10242):

Using default value 10242

Last cylinder, +cylinders or +size{K,M,G} (10242-51200, default 51200): +10G

Command (m for help): t

Partition number (1-4): 2

Hex code (type L to list codes): 8e

Changed system type of partition 2 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdb: 53.7 GB, 53687091200 bytes

64 heads, 32 sectors/track, 51200 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x4849a8f8

Device Boot Start End Blocks Id System

/dev/sdb1 1 10241 10486768 8e Linux LVM

/dev/sdb2 10242 20482 10486784 8e Linux LVM

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@rhel65 ~]# partprobe

[root@rhel65 ~]# mkfs -t ext4 /dev/sdb2

mke2fs 1.41.12 (17-May-2010)

warning: 256 blocks unused.

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe blocks

656640 inodes, 2621440 blocks

131084 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

8208 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 23 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

[root@rhel65 ~]# partx /dev/sdb

# 1: 32- 20973567 ( 20973536 sectors, 10738 MB)

# 2: 20973568- 41947135 ( 20973568 sectors, 10738 MB)

# 3: 0- -1 ( 0 sectors, 0 MB)

# 4: 0- -1 ( 0 sectors, 0 MB)

2、创建PV

[root@rhel65 ~]# pvdisplay

--- Physical volume ---

PV Name /dev/sdb1

VG Name VolGroup00

PV Size 10.00 GiB / not usable 4.98 MiB

Allocatable yes

PE Size 4.00 MiB

Total PE 2559

Free PE 1279

Allocated PE 1280

PV UUID 67HlFe-THuW-GtNS-Hih2-chFP-3tP9-brczra

--- Physical volume ---

PV Name /dev/sda2

VG Name VolGroup

PV Size 19.51 GiB / not usable 3.00 MiB

Allocatable yes (but full)

PE Size 4.00 MiB

Total PE 4994

Free PE 0

Allocated PE 4994

PV UUID ISzl0X-XuA1-aG63-IdZH-HqKS-XuRm-DrzKM8

[root@rhel65 ~]# pvcreate /dev/sdb2

Physical volume "/dev/sdb2" successfully created

[root@rhel65 ~]# pvdisplay

--- Physical volume ---

PV Name /dev/sdb1

VG Name VolGroup00

PV Size 10.00 GiB / not usable 4.98 MiB

Allocatable yes

PE Size 4.00 MiB

Total PE 2559

Free PE 1279

Allocated PE 1280

PV UUID 67HlFe-THuW-GtNS-Hih2-chFP-3tP9-brczra

--- Physical volume ---

PV Name /dev/sda2

VG Name VolGroup

PV Size 19.51 GiB / not usable 3.00 MiB

Allocatable yes (but full)

PE Size 4.00 MiB

Total PE 4994

Free PE 0

Allocated PE 4994

PV UUID ISzl0X-XuA1-aG63-IdZH-HqKS-XuRm-DrzKM8

"/dev/sdb2" is a new physical volume of "10.00 GiB"

--- NEW Physical volume ---

PV Name /dev/sdb2

VG Name

PV Size 10.00 GiB

Allocatable NO

PE Size 0

Total PE 0

Free PE 0

Allocated PE 0

PV UUID 4negrT-RwR2-AQoZ-33GH-9JzD-Qftw-eCbmll

3、扩展VG

将/dev/sdb2添加到VolGroup00中。

[root@rhel65 ~]# vgdisplay

--- Volume group ---

VG Name VolGroup00

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 1

Max PV 0

Cur PV 1

Act PV 1

VG Size 10.00 GiB

PE Size 4.00 MiB

Total PE 2559

Alloc PE / Size 1280 / 5.00 GiB

Free PE / Size 1279 / 5.00 GiB

VG UUID IA2LQx-Jljz-nGhg-VtHj-t52q-URmK-u9LV0Z

--- Volume group ---

VG Name VolGroup

System ID

Format lvm2

Metadata Areas 1

Metadata Sequence No 3

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 2

Open LV 2

Max PV 0

Cur PV 1

Act PV 1

VG Size 19.51 GiB

PE Size 4.00 MiB

Total PE 4994

Alloc PE / Size 4994 / 19.51 GiB

Free PE / Size 0 / 0

VG UUID brWwTY-jesr-1lZw-lRfy-ZL7h-0nb4-3fRzgl

[root@rhel65 ~]# vgextend VolGroup00 /dev/sdb2

Volume group "VolGroup00" successfully extended

[root@rhel65 ~]# vgdisplay

--- Volume group ---

VG Name VolGroup00

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 1

Max PV 0

Cur PV 2

Act PV 2

VG Size 20.00 GiB

PE Size 4.00 MiB

Total PE 5119

Alloc PE / Size 1280 / 5.00 GiB

Free PE / Size 3839 / 15.00 GiB

VG UUID IA2LQx-Jljz-nGhg-VtHj-t52q-URmK-u9LV0Z

--- Volume group ---

VG Name VolGroup

System ID

Format lvm2

Metadata Areas 1

Metadata Sequence No 3

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 2

Open LV 2

Max PV 0

Cur PV 1

Act PV 1

VG Size 19.51 GiB

PE Size 4.00 MiB

Total PE 4994

Alloc PE / Size 4994 / 19.51 GiB

Free PE / Size 0 / 0

VG UUID brWwTY-jesr-1lZw-lRfy-ZL7h-0nb4-3fRzgl

4、扩展LV

给lv_backup增加1G空间,扩展到6G。

[root@rhel65 ~]# lvdisplay

--- Logical volume ---

LV Path /dev/VolGroup00/lv_backup

LV Name lv_backup

VG Name VolGroup00

LV UUID hMOdIa-WZUL-ZGqQ-m5Jj-DrCf-KiPM-FNJRds

LV Write Access read/write

LV Creation host, time rhel65.kely.com, 2014-05-16 06:53:39 +0800

LV Status available

# open 1

LV Size 5.00 GiB

Current LE 1280

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:2

--- Logical volume ---

LV Path /dev/VolGroup/lv_root

LV Name lv_root

VG Name VolGroup

LV UUID swKZLT-Cm7C-kkNH-AUGe-N9WY-q2bD-l9imoi

LV Write Access read/write

LV Creation host, time localhost.localdomain, 2014-05-12 03:14:21 +0800

LV Status available

# open 1

LV Size 17.51 GiB

Current LE 4482

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:0

--- Logical volume ---

LV Path /dev/VolGroup/lv_swap

LV Name lv_swap

VG Name VolGroup

LV UUID QGLb0h-Qtfe-yxzY-kLah-qnwX-FN7n-lIjxdW

LV Write Access read/write

LV Creation host, time localhost.localdomain, 2014-05-12 03:14:37 +0800

LV Status available

# open 1

LV Size 2.00 GiB

Current LE 512

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:1

[root@rhel65 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root 18G 3.0G 14G 19% /

tmpfs 2.0G 72K 2.0G 1% /dev/shm

/dev/sda1 485M 39M 421M 9% /boot

/dev/mapper/VolGroup00-lv_backup 5.0G 138M 4.6G 3% /backup

[root@rhel65 ~]# lvextend -L +1G /dev/VolGroup00/lv_backup

Extending logical volume lv_backup to 6.00 GiB

Logical volume lv_backup successfully resized

[root@rhel65 ~]# resize2fs /dev/VolGroup00/lv_backup

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/VolGroup00/lv_backup is mounted on /backup; on-line resizing required

old desc_blocks = 1, new_desc_blocks = 1

Performing an on-line resize of /dev/VolGroup00/lv_backup to 1572864 (4k) blocks.

The filesystem on /dev/VolGroup00/lv_backup is now 1572864 blocks long.

[root@rhel65 ~]# lvdisplay

--- Logical volume ---

LV Path /dev/VolGroup00/lv_backup

LV Name lv_backup

VG Name VolGroup00

LV UUID hMOdIa-WZUL-ZGqQ-m5Jj-DrCf-KiPM-FNJRds

LV Write Access read/write

LV Creation host, time rhel65.kely.com, 2014-05-16 06:53:39 +0800

LV Status available

# open 1

LV Size 6.00 GiB

Current LE 1536

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:2

--- Logical volume ---

LV Path /dev/VolGroup/lv_root

LV Name lv_root

VG Name VolGroup

LV UUID swKZLT-Cm7C-kkNH-AUGe-N9WY-q2bD-l9imoi

LV Write Access read/write

LV Creation host, time localhost.localdomain, 2014-05-12 03:14:21 +0800

LV Status available

# open 1

LV Size 17.51 GiB

Current LE 4482

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:0

--- Logical volume ---

LV Path /dev/VolGroup/lv_swap

LV Name lv_swap

VG Name VolGroup

LV UUID QGLb0h-Qtfe-yxzY-kLah-qnwX-FN7n-lIjxdW

LV Write Access read/write

LV Creation host, time localhost.localdomain, 2014-05-12 03:14:37 +0800

LV Status available

# open 1

LV Size 2.00 GiB

Current LE 512

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:1

[root@rhel65 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root 18G 3.0G 14G 19% /

tmpfs 2.0G 72K 2.0G 1% /dev/shm

/dev/sda1 485M 39M 421M 9% /boot

/dev/mapper/VolGroup00-lv_backup 6.0G 138M 5.5G 3% /backup


文章名称:基于RHEL6.5安装Oracle11g详细教程(9)——附录
标题链接:http://jkwzsj.com/article/jodhej.html

其他资讯