网站建设资讯

NEWS

网站建设资讯

迁移逻辑卷

pvmove /dev/sdd --搬迁PE数据到VG其他成员

vgreduce vg0 /dev/sdd 删除VG0的 /dev/sdd

pvremove /dev/sdd 删除PV

[root@centos6 ~]#lsblk --查看/dev/sdb

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 100M 0 loop /mnt/xdisk
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 97.7G 0 part /
├─sda3 8:3 0 48.8G 0 part /data
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 2G 0 part [SWAP]
sdb 8:16 0 20G 0 disk
sr0 11:0 1 1024M 0 rom
loop100 7:100 0 100M 0 loop
[root@centos6 ~]#pvcreate /dev/sdb
Device /dev/sdb not found (or ignored by filtering).
[root@centos6 ~]#pvs

创新互联服务紧随时代发展步伐,进行技术革新和技术进步,经过10年的发展和积累,已经汇集了一批资深网站策划师、设计师、专业的网站实施团队以及高素质售后服务人员,并且完全形成了一套成熟的业务流程,能够完全依照客户要求对网站进行成都网站设计、成都网站建设、建设、维护、更新和改版,实现客户网站对外宣传展示的首要目的,并为客户企业品牌互联网化提供全面的解决方案。

[root@centos6 ~]#dd if=/dev/zero of=/dev/sdb bs=1 count=512 --清除/dev/sdb的分区信息

512+0 records in
512+0 records out
512 bytes (512 B) copied, 0.00557043 s, 91.9 kB/s
[root@centos6 ~]#
[root@centos6 ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 100M 0 loop /mnt/xdisk
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 97.7G 0 part /
├─sda3 8:3 0 48.8G 0 part /data
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 2G 0 part [SWAP]
sdb 8:16 0 20G 0 disk
sr0 11:0 1 1024M 0 rom
loop100 7:100 0 100M 0 loop
[root@centos6 ~]#mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sda3 on /data type ext4 (rw)
/mnt/disk on /mnt/xdisk type ext4 (rw,loop=/dev/loop0)
[root@centos6 ~]#
[root@centos6 ~]#blkid ----确认DEV/sdb 没有分区信息
/dev/sda1: UUID="15c47a81-93fd-4e76-971e-2383b42b1f8f" TYPE="ext4"
/dev/sda2: UUID="70112905-ef35-4144-8a2e-1313c7378581" TYPE="ext4"
/dev/sda5: UUID="1311bb6e-4d1f-4cd1-8994-705d8203c6a0" TYPE="swap"
/dev/sda3: UUID="d9896327-7ae0-4fe7-9993-e1b4e14faf6b" TYPE="ext4"
/dev/loop0: UUID="5ef7cf1b-23f9-48ec-a3de-3a44a8beb0a3" TYPE="ext4"
/dev/loop100: UUID="5ef7cf1b-23f9-48ec-a3de-3a44a8beb0a3" TYPE="ext4"
[root@centos6 ~]#pvcreate /dev/sdb ---创建PV
Physical volume "/dev/sdb" successfully created
[root@centos6 ~]#vgs

[root@centos6 ~]#vgcreate -s 16M vg0 /dev/sdb -创建物理卷 vg0
Volume group "vg0" successfully created
[root@centos6 ~]#lvcreate -n MySQL -L 2G vg0 --创建lv
Logical volume "mysql" created.
[root@centos6 ~]#mkfs.ext4 /dev/vg0/mysql ---分区
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 width=0 blocks
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

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

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@centos6 ~]#
[root@centos6 ~]#mkdir /mnt/mysql ---创建挂载点
[root@centos6 ~]#mount /dev/vg0/mysql /mnt/mysql/---挂载
[root@centos6 ~]#cp /etc/* /mnt/mysql/ ---拷贝数据
cp: omitting directory /etc/abrt'
cp: omitting directory
/etc/acpi'

cp: omitting directory /etc/yum'
cp: omitting directory
/etc/yum.repos.d'
[root@centos6 ~]#ls /mnt/mysql/
adjtime bashrc drirc gshadow issue.net logrotate.conf my.cnf pm-utils-hd-apm-restore.conf reader.conf smartd.conf warnquota.conf
aliases cas.conf enscript.cfg gshadow- kde4rc lost+found nanorc pnm2ppa.conf redhat-release sos.conf wgetrc
aliases.db centos-release environment gssapi_mech.conf kderc lsb-release netconfig

[root@centos6 ~]#umount /mnt/mysql/ ---卸载
[root@centos6 ~]#
[root@centos6 ~]#
[root@centos6 ~]#
[root@centos6 ~]#df --确认
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 100660656 4661276 90879380 5% /
tmpfs 501508 72 501436 1% /dev/shm
/dev/sda1 999320 34112 912780 4% /boot
/dev/sda3 50264772 53048 47651724 1% /data
/mnt/disk 95054 1550 88384 2% /mnt/xdisk

[root@centos6 ~]#vgrename vg0 vg1 ---更改VG名

Volume group "vg0" successfully renamed to "vg1"
[root@centos6 ~]#vgdisplay---确认
--- Volume group ---
VG Name vg1
System ID
Format lvm2
Metadata Areas 1
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 1
Act PV 1
VG Size 19.98 GiB
PE Size 16.00 MiB
Total PE 1279
Alloc PE / Size 128 / 2.00 GiB
Free PE / Size 1151 / 17.98 GiB
VG UUID UBne4H-QpbX-G3jP-Zq12-NUhZ-7iXV-OAPjCZ

[root@centos6 ~]#vgchange -an vg1 --禁用vg1

0 logical volume(s) in volume group "vg1" now active
[root@centos6 ~]#vgdisplay --确认
--- Volume group ---
VG Name vg1
System ID
Format lvm2
Metadata Areas 1
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 1
Act PV 1
VG Size 19.98 GiB
PE Size 16.00 MiB
Total PE 1279
Alloc PE / Size 128 / 2.00 GiB
Free PE / Size 1151 / 17.98 GiB
VG UUID UBne4H-QpbX-G3jP-Zq12-NUhZ-7iXV-OAPjCZ

[root@centos6 ~]#lvdisplay
--- Logical volume ---
LV Path /dev/vg1/mysql
LV Name mysql
VG Name vg1
LV UUID L9uTCB-aSN6-arMv-eLrA-rAcJ-eKO3-IIuWUX
LV Write Access read/write
LV Creation host, time centos6.localdomain, 2020-03-02 13:47:43 +0800
LV Status NOT available
LV Size 2.00 GiB
Current LE 128
Segments 1
Allocation inherit
Read ahead sectors auto

[root@centos6 ~]#vgexport vg1 --导出VG1

Volume group "vg1" successfully exported
[root@centos6 ~]#lvdisplay ---确认
Volume group vg1 is exported
[root@centos6 ~]#vgdisplay
--- Volume group ---
VG Name vg1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status exported/resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 19.98 GiB
PE Size 16.00 MiB
Total PE 1279
Alloc PE / Size 128 / 2.00 GiB
Free PE / Size 1151 / 17.98 GiB
VG UUID UBne4H-QpbX-G3jP-Zq12-NUhZ-7iXV-OAPjCZ

[root@bogon ~]$echo '- - -' > /sys/class/scsi_host/host2/scan --把centos6 的磁盘添加到Centos7 上

[root@bogon ~]$lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /mnt/boot
├─sda2 8:2 0 100G 0 part /
├─sda3 8:3 0 50G 0 part /data
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 2G 0 part [SWAP]
├─sda6 8:6 0 1G 0 part /mnt/sda6
└─sda7 8:7 0 2G 0 part /mnt/sda7
sdb 8:16 0 200G 0 disk
├─sdb1 8:17 0 4G 0 part
│ └─vg0-mysql 253:0 0 5.9G 0 lvm
└─sdb2 8:18 0 2G 0 part /home
sdc 8:32 0 20G 0 disk
sdd 8:48 0 10G 0 disk
├─vg0-mysql 253:0 0 5.9G 0 lvm
└─vg0-binlog 253:1 0 1G 0 lvm /mnt/binlog
sde 8:64 0 20G 0 disk
sr0 11:0 1 3.7G 0 rom /mnt/cdrom
sr1 11:1 1 10G 0 rom

[root@bogon ~]$

root@bogon ~]$vgdisplay ---查看到新增VG1

--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 22
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size 33.95 GiB
PE Size 16.00 MiB
Total PE 2173
Alloc PE / Size 442 / <6.91 GiB
Free PE / Size 1731 / <27.05 GiB
VG UUID r8Yxfa-Zm0l-C8J3-c2RH-6MB5-dVYQ-TnFIm9

--- Volume group ---
VG Name vg1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status exported/resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 19.98 GiB
PE Size 16.00 MiB
Total PE 1279
Alloc PE / Size 128 / 2.00 GiB
Free PE / Size 1151 / 17.98 GiB
VG UUID UBne4H-QpbX-G3jP-Zq12-NUhZ-7iXV-OAPjC

[root@bogon ~]$vgimport vg1 --导入VG1

Volume group "vg1" successfully imported
[root@bogon ~]$
[root@bogon ~]$
[root@bogon ~]$
[root@bogon ~]$
[root@bogon ~]$vgdisplay ---确认
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 22
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size 33.95 GiB
PE Size 16.00 MiB
Total PE 2173
Alloc PE / Size 442 / <6.91 GiB
Free PE / Size 1731 / <27.05 GiB
VG UUID r8Yxfa-Zm0l-C8J3-c2RH-6MB5-dVYQ-TnFIm9

--- Volume group ---
VG Name vg1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
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 19.98 GiB
PE Size 16.00 MiB
Total PE 1279
Alloc PE / Size 128 / 2.00 GiB
Free PE / Size 1151 / 17.98 GiB
VG UUID UBne4H-QpbX-G3jP-Zq12-NUhZ-7iXV-OAPjCZ

[root@bogon ~]$lvdisplay --发现新的LV

--- Logical volume ---
LV Path /dev/vg0/mysql
LV Name mysql
VG Name vg0
LV UUID T00lR8-XzZI-9yze-AQp1-heCq-1oiw-xSTlf1
LV Write Access read/write
LV Creation host, time bogon, 2020-03-09 20:51:44 -0400
LV Status available

open 0

LV Size <5.91 GiB
Current LE 378
Segments 3
Allocation inherit
Read ahead sectors auto

  • currently set to 8192
    Block device 253:0

    --- Logical volume ---
    LV Path /dev/vg0/binlog
    LV Name binlog
    VG Name vg0
    LV UUID w6Y2t4-gr2y-oYvO-vIGh-03Q2-SQnu-d3MPOv
    LV Write Access read/write
    LV Creation host, time bogon, 2020-03-09 21:07:38 -0400
    LV Status available

    open 1

    LV Size 1.00 GiB
    Current LE 64
    Segments 1
    Allocation inherit
    Read ahead sectors auto

  • currently set to 8192
    Block device 253:1

--- Logical volume ---

LV Path /dev/vg1/mysql

LV Name mysql
VG Name vg1
LV UUID L9uTCB-aSN6-arMv-eLrA-rAcJ-eKO3-IIuWUX
LV Write Access read/write
LV Creation host, time centos6.localdomain, 2020-03-02 00:47:43 -0500
LV Status NOT available
LV Size 2.00 GiB
Current LE 128
Segments 1
Allocation inherit
Read ahead sectors auto

echo '- - -' > /sys/class/scsi_host/host0/scan

1079 2020-03-10 00:22:51 lsblk
1080 2020-03-10 00:23:00 echo '- - -' > /sys/class/scsi_host/host2/scan ---检测新增硬盘
1081 2020-03-10 00:23:03 lsblk
1082 2020-03-10 00:35:18 vgdisplay
1083 2020-03-10 00:37:02 vgimport vg1 ---导入VG1
1084 2020-03-10 00:37:07 vgdisplay
1085 2020-03-10 00:38:08 lvdisplay
1086 2020-03-10 00:42:11 vgchange -ay vg1 --改变活动状态
1087 2020-03-10 00:42:19 lvdisplay
1088 2020-03-10 00:42:48 mkdir -p /mnt/vg1/mysql
1089 2020-03-10 00:43:08 mount /dev/vg1/mysql /mnt/vg1/mysql


网站名称:迁移逻辑卷
网页地址:http://cdweb.net/article/iijdeh.html