//
//在rapap02新增一個Logical Volume
//掛載到 /mnt/lv011,Copy資料到其中
//卸載並且vgexport
//
[root@rapap02 ~]# fdisk -l
Disk /dev/xvda: 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/xvda1 * 1 13 104391 83 Linux
/dev/xvda2 14 2610 20860402+ 8e Linux LVM
Disk /dev/xvdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/xvdb doesn't contain a valid partition table
Disk /dev/xvdc: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/xvdc doesn't contain a valid partition table
Disk /dev/xvdd: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/xvdd doesn't contain a valid partition table
[root@rapap02 ~]# vgcreate vgtest /dev/xvdd
No physical volume label read from /dev/xvdd
Physical volume "/dev/xvdd" successfully created
Volume group "vgtest" successfully created
[root@rapap02 ~]# vgdisplay vgtest
--- Volume group ---
VG Name vgtest
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 2.00 GB
PE Size 4.00 MB
Total PE 511
Alloc PE / Size 0 / 0
Free PE / Size 511 / 2.00 GB
VG UUID gPeHCF-q2uS-t2Ps-WBLV-aTRU-eWnS-4L8FV5
[root@rapap02 ~]# lvcreate -l +511 -nlv011 vgtest
Logical volume "lv011" created
[root@rapap02 ~]# pvscan
PV /dev/xvdd VG vgtest lvm2 [2.00 GB / 0 free]
PV /dev/xvdc VG VolGroup01 lvm2 [50.00 GB / 0 free]
PV /dev/xvda2 VG VolGroup00 lvm2 [19.88 GB / 0 free]
PV /dev/xvdb VG VolGroup00 lvm2 [29.97 GB / 16.97 GB free]
Total: 4 [101.84 GB] / in use: 4 [101.84 GB] / in no VG: 0 [0 ]
[root@rapap02 ~]# lvscan
ACTIVE '/dev/vgtest/lv011' [2.00 GB] inherit
ACTIVE '/dev/VolGroup01/LogVol02' [50.00 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol00' [26.91 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [5.97 GB] inherit
[root@rapap02 ~]# mkfs -t ext3 /dev/vgtest/lv011
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
261632 inodes, 523264 blocks
26163 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
16352 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@rapap02 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
27331836 4537784 21388472 18% /
/dev/xvda1 101086 13860 82007 15% /boot
tmpfs 4194304 0 4194304 0% /dev/shm
/dev/mapper/VolGroup01-LogVol02
51602044 25518644 23462168 53% /u01
[root@rapap02 ~]# ll /mnt
total 0
[root@rapap02 ~]# mkdir /mnt/lv011
[root@rapap02 ~]# mount /dev/vgtest/lv011 /mnt/lv011
[root@rapap02 ~]#
[root@rapap02 ~]#
[root@rapap02 ~]#
[root@rapap02 ~]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
27331836 4537788 21388468 18% /
/dev/xvda1 101086 13860 82007 15% /boot
tmpfs 4194304 0 4194304 0% /dev/shm
/dev/mapper/VolGroup01-LogVol02
51602044 25518644 23462168 53% /u01
/dev/mapper/vgtest-lv011
2060176 35880 1919644 2% /mnt/lv011
[root@rapap02 ~]# ls /etc
a2ps.cfg desktop-profiles ident.key minicom.users protocols skel
a2ps-site.cfg dev.d idmapd.conf mke2fs.conf quotagrpadmins slrn.rc
acpi dhcp6c.conf init.d mke4fs.conf quotatab smartd.conf
adjtime dhcpd.conf initlog.conf modprobe.conf racoon smi.conf
aide.conf DIR_COLORS inittab modprobe.conf~ rc smrsh
alchemist DIR_COLORS.xterm inputrc modprobe.conf.orabackup rc0.d smt_dhcp_ra_support.conf
aliases dnsmasq.conf ipmi_monitoring_sensors.conf modprobe.d rc1.d snmp
aliases.db dnsmasq.d iproute2 motd rc2.d sound
alsa dumpdates ipsec.conf mrtg rc3.d squid
alternatives edac ipsec.d mtab rc4.d ssh
amanda enscript.cfg ipsec.secrets mtools.conf rc5.d stunnel
amandates enterprise-release iscsi multipath.conf rc6.d subversion
amd.conf environment isdn Muttrc rc.d sudoers
amd.net esd.conf issue Muttrc.local rc.local sysconfig
anacrontab exports issue.net netplug rc.sysinit sysctl.conf
anthy-conf fb.modes java netplug.d readahead.d sysctl.conf.orabackup
at.deny fcoe jvm NetworkManager reader.conf sysctl.ktune
audisp filesystems jvm-commmon nscd.conf reader.conf.d syslog.conf
audit firmware jwhois.conf nsswitch.conf redhat-lsb tcsd.conf
autofs_ldap_auth.conf fonts kdump.conf ntp redhat-release termcap
auto.master foomatic krb5.conf ntp.conf request-key.conf tgt
auto.misc fstab ktune.d odbc.ini resolv.conf tux.mime.types
auto.net gconf ldap.conf odbcinst.ini rhgb udev
auto.smb gcrypt ld.so.cache ofed rmt updatedb.conf
avahi gdm ld.so.conf openldap rndc.key uucp
bashrc ghostscript ld.so.conf.d opt rpc vimrc
blkid gnome-vfs-2.0 lftp.conf oraInst.loc rpm virc
bluetooth gnome-vfs-mime-magic libaudit.conf oratab rwtab warnquota.conf
bonobo-activation gnupg libibverbs.d pam.d rwtab.d watchdog.conf
brltty gpm-root.conf libuser.conf pam_pkcs11 samba webalizer.conf
brltty.conf gre.d localtime pam_smb.conf sane.d wgetrc
capi.conf group login.defs pango sasl2 wpa_supplicant
cdrecord.conf group- logrotate.conf passwd scim wvdial.conf
cipe grub.conf logrotate.d passwd- screenrc X11
conman.conf gshadow logwatch pcmcia scrollkeeper.conf xdg
cron.d gshadow- lsb-release.d Pegasus scsi_id.config xinetd.conf
cron.daily gssapi_mech.conf ltrace.conf php.d securetty xinetd.d
cron.deny gtk lvm php.ini security xml
cron.hourly gtk-2.0 mail pinforc selinux yp.conf
cron.monthly hal mailcap pki sensors.conf yum
crontab hba.conf mail.rc pm services yum.conf
cron.weekly host.conf makedev.d ppp sestatus.conf yum.repos.d
csh.cshrc hosts man.config prelink.cache setroubleshoot zlogin
csh.login hosts.allow maven prelink.conf setuptool.d zlogout
cups hosts.deny mc prelink.conf.d sgml zprofile
dbus-1 hp mcelog.conf printcap shadow zshenv
default httpd mgetty+sendfax profile shadow- zshrc
depmod.d ibm_hosts mime.types profile.d shells
[root@rapap02 ~]# pwd
/root
[root@rapap02 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
27331836 4537788 21388468 18% /
/dev/xvda1 101086 13860 82007 15% /boot
tmpfs 4194304 0 4194304 0% /dev/shm
/dev/mapper/VolGroup01-LogVol02
51602044 25518644 23462168 53% /u01
/dev/mapper/vgtest-lv011
2060176 35880 1919644 2% /mnt/lv011
[root@rapap02 ~]# cd /mnt/lv011
[root@rapap02 lv011]# cp /etc/*.conf .
[root@rapap02 lv011]# mkdir dir1
[root@rapap02 lv011]# mkdir dir2 dir3
[root@rapap02 lv011]# ls
aide.conf dir1 host.conf ld.so.conf mke4fs.conf reader.conf sysctl.conf yp.conf
amd.conf dir2 idmapd.conf lftp.conf modprobe.conf request-key.conf syslog.conf yum.conf
autofs_ldap_auth.conf dir3 initlog.conf libaudit.conf mtools.conf resolv.conf tcsd.conf
brltty.conf dnsmasq.conf ipmi_monitoring_sensors.conf libuser.conf multipath.conf scrollkeeper.conf updatedb.conf
capi.conf esd.conf ipsec.conf logrotate.conf nscd.conf sensors.conf warnquota.conf
cdrecord.conf gpm-root.conf jwhois.conf lost+found nsswitch.conf sestatus.conf watchdog.conf
conman.conf grub.conf kdump.conf ltrace.conf ntp.conf smartd.conf webalizer.conf
dhcp6c.conf gssapi_mech.conf krb5.conf mcelog.conf pam_smb.conf smi.conf wvdial.conf
dhcpd.conf hba.conf ldap.conf mke2fs.conf prelink.conf smt_dhcp_ra_support.conf xinetd.conf
[root@rapap02 lv011]# cd
[root@rapap02 ~]# umount /dev/vgtest/lv011
[root@rapap02 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
27331836 4537788 21388468 18% /
/dev/xvda1 101086 13860 82007 15% /boot
tmpfs 4194304 0 4194304 0% /dev/shm
/dev/mapper/VolGroup01-LogVol02
51602044 25518644 23462168 53% /u01
[root@rapap02 ~]# vgchange -a n vgtest
0 logical volume(s) in volume group "vgtest" now active
[root@rapap02 ~]# vgdisplay
--- Volume group ---
VG Name vgtest
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 2.00 GB
PE Size 4.00 MB
Total PE 511
Alloc PE / Size 511 / 2.00 GB
Free PE / Size 0 / 0
VG UUID gPeHCF-q2uS-t2Ps-WBLV-aTRU-eWnS-4L8FV5
--- Volume group ---
VG Name VolGroup01
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 50.00 GB
PE Size 4.00 MB
Total PE 12799
Alloc PE / Size 12799 / 50.00 GB
Free PE / Size 0 / 0
VG UUID N04jCd-WjJe-pUAm-apea-nAc1-7oNy-oNri2U
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 49.84 GB
PE Size 32.00 MB
Total PE 1595
Alloc PE / Size 1052 / 32.88 GB
Free PE / Size 543 / 16.97 GB
VG UUID q07Lbb-zGJ2-Wtze-S1MK-tDpr-6Cqu-xZs7oT
[root@rapap02 ~]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "vgtest" using metadata type lvm2
Found volume group "VolGroup01" using metadata type lvm2
Found volume group "VolGroup00" using metadata type lvm2
[root@rapap02 ~]# vgexport vgtest
Volume group "vgtest" successfully exported
[root@rapap02 ~]# vgscan
Reading all physical volumes. This may take a while...
Found exported volume group "vgtest" using metadata type lvm2
Found volume group "VolGroup01" using metadata type lvm2
Found volume group "VolGroup00" using metadata type lvm2
[root@rapap02 ~]# vgdisplay vgtest -v
Using volume group(s) on command line
Finding volume group "vgtest"
Volume group vgtest is exported
--- Volume group ---
VG Name vgtest
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
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 2.00 GB
PE Size 4.00 MB
Total PE 511
Alloc PE / Size 511 / 2.00 GB
Free PE / Size 0 / 0
VG UUID gPeHCF-q2uS-t2Ps-WBLV-aTRU-eWnS-4L8FV5
Volume group vgtest is exported
--- Physical volumes ---
PV Name /dev/xvdd
PV UUID GIfDA5-JdVQ-0VWq-bGJG-QsWA-zYPf-joXF9g
PV Status allocatable
Total PE / Free PE 511 / 0
[root@rapap02 ~]# lvscan
Volume group vgtest is exported
ACTIVE '/dev/VolGroup01/LogVol02' [50.00 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol00' [26.91 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [5.97 GB] inherit
//
//在testdb4做vgimport vgtest
//掛載到 /mnt/lv011,檢查資料是否完整
//
[root@testdb4 etc]# cat /etc/fstab
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
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/VolGroup00/LogVol01 swap swap defaults 0 0
[root@testdb4 dev]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
14124720 9951560 3444072 75% /
/dev/xvda1 101086 32579 63288 34% /boot
tmpfs 1048576 0 1048576 0% /dev/shm
[root@testdb4 dev]# fdisk -l
Disk /dev/xvda: 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/xvda1 * 1 13 104391 83 Linux
/dev/xvda2 14 2610 20860402+ 8e Linux LVM
Disk /dev/dm-0: 14.9 GB, 14931722240 bytes
255 heads, 63 sectors/track, 1815 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-0 doesn't contain a valid partition table
Disk /dev/dm-1: 6408 MB, 6408896512 bytes
255 heads, 63 sectors/track, 779 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-1 doesn't contain a valid partition table
[root@testdb4 dev]# fdisk -l
Disk /dev/xvda: 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/xvda1 * 1 13 104391 83 Linux
/dev/xvda2 14 2610 20860402+ 8e Linux LVM
Disk /dev/dm-0: 14.9 GB, 14931722240 bytes
255 heads, 63 sectors/track, 1815 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-0 doesn't contain a valid partition table
Disk /dev/dm-1: 6408 MB, 6408896512 bytes
255 heads, 63 sectors/track, 779 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-1 doesn't contain a valid partition table
Disk /dev/xvdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/xvdb doesn't contain a valid partition table
You have new mail in /var/spool/mail/root
[root@testdb4 dev]# pvscan
PV /dev/xvdb is in exported VG vgtest [2.00 GB / 0 free]
PV /dev/xvda2 VG VolGroup00 lvm2 [19.88 GB / 0 free]
Total: 2 [21.87 GB] / in use: 2 [21.87 GB] / in no VG: 0 [0 ]
[root@testdb4 dev]#
[root@testdb4 dev]# vgimport vgtest
Volume group "vgtest" successfully imported
[root@testdb4 dev]# pvscan
PV /dev/xvdb VG vgtest lvm2 [2.00 GB / 0 free]
PV /dev/xvda2 VG VolGroup00 lvm2 [19.88 GB / 0 free]
Total: 2 [21.87 GB] / in use: 2 [21.87 GB] / in no VG: 0 [0 ]
[root@testdb4 dev]# lvscan
inactive '/dev/vgtest/lv011' [2.00 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol00' [13.91 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [5.97 GB] inherit
[root@testdb4 dev]# vgchange -a y vgtest
1 logical volume(s) in volume group "vgtest" now active
[root@testdb4 dev]# lvscan
ACTIVE '/dev/vgtest/lv011' [2.00 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol00' [13.91 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [5.97 GB] inherit
[root@testdb4 dev]# mkdir /mnt/lv011
[root@testdb4 dev]# mount /dev/vgtest/lv011 /mnt/lv011
[root@testdb4 dev]# cd /mnt/lv011
[root@testdb4 lv011]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
14124720 9951632 3444000 75% /
/dev/xvda1 101086 32579 63288 34% /boot
tmpfs 1048576 0 1048576 0% /dev/shm
/dev/mapper/vgtest-lv011
2060176 36336 1919188 2% /mnt/lv011
[root@testdb4 lv011]# ls
aide.conf dir3 ipsec.conf ltrace.conf prelink.conf syslog.conf
amd.conf dnsmasq.conf jwhois.conf mcelog.conf reader.conf tcsd.conf
autofs_ldap_auth.conf esd.conf kdump.conf mke2fs.conf request-key.conf updatedb.conf
brltty.conf gpm-root.conf krb5.conf mke4fs.conf resolv.conf warnquota.conf
capi.conf grub.conf ldap.conf modprobe.conf scrollkeeper.conf watchdog.conf
cdrecord.conf gssapi_mech.conf ld.so.conf mtools.conf sensors.conf webalizer.conf
conman.conf hba.conf lftp.conf multipath.conf sestatus.conf wvdial.conf
dhcp6c.conf host.conf libaudit.conf nscd.conf smartd.conf xinetd.conf
dhcpd.conf idmapd.conf libuser.conf nsswitch.conf smi.conf yp.conf
dir1 initlog.conf logrotate.conf ntp.conf smt_dhcp_ra_support.conf yum.conf
dir2 ipmi_monitoring_sensors.conf lost+found pam_smb.conf sysctl.conf
//
//掛載到 /mnt/lv011
//移除LVM設定
//
[root@testdb4 lv011]# pvscan
PV /dev/xvdb VG vgtest lvm2 [2.00 GB / 0 free]
PV /dev/xvda2 VG VolGroup00 lvm2 [19.88 GB / 0 free]
PV /dev/xvdc lvm2 [3.00 GB]
Total: 3 [24.87 GB] / in use: 2 [21.87 GB] / in no VG: 1 [3.00 GB]
[root@testdb4 lv011]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
14124720 9951652 3443980 75% /
/dev/xvda1 101086 32579 63288 34% /boot
tmpfs 1048576 0 1048576 0% /dev/shm
/dev/mapper/vgtest-lv011
2060176 36336 1919188 2% /mnt/lv011
[root@testdb4 lv011]# cd
[root@testdb4 ~]# umount /dev/vgtest/lv011
[root@testdb4 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
14124720 9951652 3443980 75% /
/dev/xvda1 101086 32579 63288 34% /boot
tmpfs 1048576 0 1048576 0% /dev/shm
[root@testdb4 ~]# pvremove /dev/xvdc
Labels on physical volume "/dev/xvdc" successfully wiped
[root@testdb4 ~]# pvscan
PV /dev/xvdb VG vgtest lvm2 [2.00 GB / 0 free]
PV /dev/xvda2 VG VolGroup00 lvm2 [19.88 GB / 0 free]
Total: 2 [21.87 GB] / in use: 2 [21.87 GB] / in no VG: 0 [0 ]
[root@testdb4 ~]# pvremove /dev/xvdb
Can't pvremove physical volume "/dev/xvdb" of volume group "vgtest" without -ff
[root@testdb4 ~]# vgremove /dev/vgtest/
Invalid volume group name: vgtest/
Run `vgremove --help' for more information.
[root@testdb4 ~]# vgremove /dev/vgtest
Do you really want to remove volume group "vgtest" containing 1 logical volumes? [y/n]: y
Do you really want to remove active logical volume lv011? [y/n]: y
Logical volume "lv011" successfully removed
Volume group "vgtest" successfully removed
[root@testdb4 ~]# pvremove /dev/xvdb
Labels on physical volume "/dev/xvdb" successfully wiped
[root@testdb4 ~]# pvscan
PV /dev/xvda2 VG VolGroup00 lvm2 [19.88 GB / 0 free]
Total: 1 [19.88 GB] / in use: 1 [19.88 GB] / in no VG: 0 [0 ]
沒有留言:
張貼留言