分类: LINUX
2009-08-05 11:48:53
CCM VG信息 Linux下的迁移
名词解释:
LVM :Logical Volume Manager,逻辑卷管理器
vg: Volume Group 卷组
lv: Logical Volume 逻辑卷
pv: Physical Volumn 物理卷
一. 在主机A上创建卷组vg,并且划分逻辑卷lv
1.确保盘柜正确的映射在主机A上
fdisk –l可看到磁盘信息
Disk /dev/cciss/c0d0: 293.5 GB, 293564211200 bytes
255 heads, 63 sectors/track, 35690 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/cciss/c0d0p1 * 1 13 104391 83 Linux
/dev/cciss/c0d0p2 14 2624 20972857+ 83 Linux
/dev/cciss/c0d0p3 2625 3929 10482412+ 83 Linux
/dev/cciss/c0d0p4 3930 35690 255120232+ 5 Extended
/dev/cciss/c0d0p5 3930 4582 5245191 83 Linux
/dev/cciss/c0d0p6 4583 4843 2096451 83 Linux
/dev/cciss/c0d0p7 4844 4974 1052226 82 Linux swap
/dev/cciss/c0d0p8 4975 35690 246726238+ 83 Linux
Disk /dev/sda: 2186.1 GB, 2186136256512 bytes
255 heads, 63 sectors/track, 265782 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sda doesn't contain a valid partition table
Disk /dev/sdb: 1503.2 GB, 1503238553600 bytes
255 heads, 63 sectors/track, 182758 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 1503.6 GB, 1503641731072 bytes
255 heads, 63 sectors/track, 182807 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table
Disk /dev/sdd: 1395.8 GB, 1395864371200 bytes
255 heads, 63 sectors/track, 169704 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdd doesn't contain a valid partition table
Disk /dev/sde: 1400.3 GB, 1400375345152 bytes
255 heads, 63 sectors/track, 170252 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sde doesn't contain a valid partition table
Disk /dev/sdf: 2186.1 GB, 2186136256512 bytes
255 heads, 63 sectors/track, 265782 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdf doesn't contain a valid partition table
Disk /dev/sdg: 1503.2 GB, 1503238553600 bytes
255 heads, 63 sectors/track, 182758 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdg doesn't contain a valid partition table
Disk /dev/sdh: 1503.6 GB, 1503641731072 bytes
255 heads, 63 sectors/track, 182807 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
2.在主机A上用lvm管理磁盘
pvcreate /dev/sda 此命令是创建pv物理卷
pvcreate /dev/sdb
pvcreate /dev/sdc
pvcreate /dev/sdd
pvcreate /dev/sde
pvcreate /dev/sdf
pvcreate /dev/sdg
pvcreate /dev/sdh
vgcreate vgmedia /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg /dev/sdh
此命令是创建vg逻辑卷,其中vgmeida是你想要创建vg的名字
lvcreate –L 100000 –n lvmedia1 /dev/vgmedia 此命令是创建逻辑卷
lvcreate –L 100000 –n lvmedia2 /dev/vgmedia 此命令是创建逻辑卷
lvcreate –L 100000 –n lvmedia3 /dev/vgmedia 此命令是创建逻辑卷
参数L后面跟想要划分的逻辑卷lv的大小,单位是M
参数n后面是创建的逻辑卷的名字
mke2fs –j /dev/vgmedia/lvmedia1 此命令是做文件系统
mke2fs –j /dev/vgmedia/lvmedia1 此命令是做文件系统
mke2fs –j /dev/vgmedia/lvmedia1 此命令是做文件系统
mount /dev/vgmedia/lvmedia1 /home/apache/media/media1
mount /dev/vgmedia/lvmedia2 /home/apache/media/media2
mount /dev/vgmedia/lvmedia3 /home/apache/media/media3
此命令是挂载,/dev/vgmedia/lvmedia1是设备文件,后面/home/apache/media/media1是文件名
到此在第一台主机上的lvm做完
二. Vg信息的转移
1. 在主机A上
vgcfgbackup vgmedia
此命令将vgmedia的信息备份下来,产生一个/etc/lvm/backup/vgmedia 文件,将此文件传到主机B上,注意此文件的权限,它默认是300,属主和属组都是root,如果你不是root用户,需要改变此文件的权限才能下载。
2. 在主机B上
1.确保盘柜正确连接
fdisk –l
Disk /dev/sda: 2186.1 GB, 2186136256512 bytes
255 heads, 63 sectors/track, 265782 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sda doesn't contain a valid partition table
Disk /dev/sdb: 1503.2 GB, 1503238553600 bytes
255 heads, 63 sectors/track, 182758 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 1503.6 GB, 1503641731072 bytes
255 heads, 63 sectors/track, 182807 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table
Disk /dev/sdd: 1395.8 GB, 1395864371200 bytes
255 heads, 63 sectors/track, 169704 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdd doesn't contain a valid partition table
Disk /dev/sde: 1400.3 GB, 1400375345152 bytes
255 heads, 63 sectors/track, 170252 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sde doesn't contain a valid partition table
Disk /dev/sdf: 2186.1 GB, 2186136256512 bytes
255 heads, 63 sectors/track, 265782 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdf doesn't contain a valid partition table
Disk /dev/sdg: 1503.2 GB, 1503238553600 bytes
255 heads, 63 sectors/track, 182758 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdg doesn't contain a valid partition table
Disk /dev/sdh: 1503.6 GB, 1503641731072 bytes
255 heads, 63 sectors/track, 182807 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
2.导入vg信息
mkdir /etc/lvm/backup 在/etc/lvm下创建目录backup
将主机A上的vgmedia 文件传到/etc/lvm/backup目录下
vgcfgrestore vgmedia 在主机B上将vgmedia导入
vgchange –ay 激活卷组
mount /dev/vgmedia/lvmedia1 /home/apache/media/media1 挂载逻辑卷
mount /dev/vgmedia/lvmedia2 /home/apache/media/media2 挂载逻辑卷
mount /dev/vgmedia/lvmedia3 /home/apache/media/media3 挂载逻辑卷
至此,盘柜可在主机B上读写