LVM
Posted 李伟铭
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LVM相关的知识,希望对你有一定的参考价值。
Connecting to 172.16.122.208:22...
Connection established.
To escape to local shell, press ‘Ctrl+Alt+]‘.
Last login: Wed Jul 19 01:50:42 2017 from 172.16.8.51
[[email protected] ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-root
992M 350M 591M 38% /
/dev/mapper/rootvg-usr
9.7G 2.8G 6.5G 31% /usr
/dev/mapper/rootvg-opt
3.9G 137M 3.6G 4% /opt
/dev/mapper/rootvg-app
20G 173M 19G 1% /app
/dev/mapper/rootvg-var
3.9G 298M 3.4G 8% /var
/dev/mapper/rootvg-tmp
3.9G 137M 3.6G 4% /tmp
/dev/mapper/rootvg-home
3.9G 137M 3.6G 4% /home
/dev/mapper/oravg-oraclelv
40G 176M 38G 1% /u01
/dev/sda1 494M 18M 451M 4% /boot
tmpfs 3.9G 0 3.9G 0% /dev/shm
[[email protected] ~]$ fdisk /dev/sd
sda sda1 sda2 sdb sdb1
[[email protected] ~]$ init 6
-bash: init: command not found
[[email protected] ~]$ su -
Password:
[[email protected] ~]# init 6
[[email protected] ~]# Connection closing...Socket close.
Connection closed by foreign host.
Disconnected from remote host(ora 172.16.122.208) at 18:36:35.
Type `help‘ to learn how to use Xshell prompt.
[d:\~]$
Connecting to 172.16.122.208:22...
Could not connect to ‘172.16.122.208‘ (port 22): Connection failed.
Type `help‘ to learn how to use Xshell prompt.
[d:\~]$
Connecting to 172.16.122.208:22...
Connection established.
To escape to local shell, press ‘Ctrl+Alt+]‘.
Last login: Mon Jul 24 10:36:04 2017 from 172.16.8.51
[[email protected] ~]$ su -
Password:
[[email protected] ~]# fdisk /dev/sd
sda sda1 sda2 sdb sdb1 sdc
[[email protected] ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won‘t be recoverable.
The number of cylinders for this disk is set to 6527.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help):
[[email protected] ~]# fdisk /dev/sdc
[[email protected] ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won‘t be recoverable.
The number of cylinders for this disk is set to 6527.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): p
Disk /dev/sdc: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-6527, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-6527, default 6527):
Using default value 6527
Command (m for help): t
Selected partition 1
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/sdc: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 6527 52428096 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-root
992M 350M 591M 38% /
/dev/mapper/rootvg-usr
9.7G 2.8G 6.5G 31% /usr
/dev/mapper/rootvg-opt
3.9G 137M 3.6G 4% /opt
/dev/mapper/rootvg-app
20G 173M 19G 1% /app
/dev/mapper/rootvg-var
3.9G 296M 3.4G 8% /var
/dev/mapper/rootvg-tmp
3.9G 137M 3.6G 4% /tmp
/dev/mapper/rootvg-home
3.9G 137M 3.6G 4% /home
/dev/mapper/oravg-oraclelv
40G 176M 38G 1% /u01
/dev/sda1 494M 18M 451M 4% /boot
tmpfs 3.9G 0 3.9G 0% /dev/shm
[[email protected] ~]# pvcreate /dev/sd
sda sda1 sda2 sdb sdb1 sdc sdc1
[[email protected] ~]# pvcreate /dev/sdc1
Writing physical volume data to disk "/dev/sdc1"
Physical volume "/dev/sdc1" successfully created
[[email protected] ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 rootvg lvm2 a-- 59.47G 4.47G
/dev/sdb1 oravg lvm2 a-- 49.97G 9.97G
/dev/sdc1 lvm2 a-- 50.00G 50.00G
[[email protected] ~]# vgextend oravg /dev/sdc1
Volume group "oravg" successfully extended
[[email protected] ~]# vgs
VG #PV #LV #SN Attr VSize VFree
oravg 2 1 0 wz--n- 99.94G 59.94G
rootvg 1 8 0 wz--n- 59.47G 4.47G
[[email protected] ~]# lvcreate -L 50G -n oradatalv oravg
Logical volume "oradatalv" created
[[email protected] ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
oraclelv oravg -wi-ao 40.00G
oradatalv oravg -wi-a- 50.00G
app rootvg -wi-ao 20.00G
home rootvg -wi-ao 4.00G
opt rootvg -wi-ao 4.00G
root rootvg -wi-ao 1.00G
swap01 rootvg -wi-ao 8.00G
tmp rootvg -wi-ao 4.00G
usr rootvg -wi-ao 10.00G
var rootvg -wi-ao 4.00G
[[email protected] ~]# mkfs.ext4 /dev/oravg/oradatalv
mke2fs 1.42 (29-Nov-2011)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3276800 inodes, 13107200 blocks
655360 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
400 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, 1605632, 2654208,
4096000, 7962624, 11239424
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done
[[email protected] ~]#
[[email protected] ~]# mkdir /oradata
[[email protected] ~]# chown oracle:oinstall /oradata
chown: `oracle:oinstall‘: invalid user
[[email protected] ~]#
[[email protected] ~]# mount /dev/oravg/oradatalv /oradata/
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-root
992M 350M 591M 38% /
/dev/mapper/rootvg-usr
9.7G 2.8G 6.5G 31% /usr
/dev/mapper/rootvg-opt
3.9G 137M 3.6G 4% /opt
/dev/mapper/rootvg-app
20G 173M 19G 1% /app
/dev/mapper/rootvg-var
3.9G 296M 3.4G 8% /var
/dev/mapper/rootvg-tmp
3.9G 137M 3.6G 4% /tmp
/dev/mapper/rootvg-home
3.9G 137M 3.6G 4% /home
/dev/mapper/oravg-oraclelv
40G 176M 38G 1% /u01
/dev/sda1 494M 18M 451M 4% /boot
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/mapper/oravg-oradatalv
50G 180M 47G 1% /oradata
[[email protected] ~]# vi /etc/fstab
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-root
992M 350M 591M 38% /
/dev/mapper/rootvg-usr
9.7G 2.8G 6.5G 31% /usr
/dev/mapper/rootvg-opt
3.9G 137M 3.6G 4% /opt
/dev/mapper/rootvg-app
20G 173M 19G 1% /app
/dev/mapper/rootvg-var
3.9G 296M 3.4G 8% /var
/dev/mapper/rootvg-tmp
3.9G 137M 3.6G 4% /tmp
/dev/mapper/rootvg-home
3.9G 137M 3.6G 4% /home
/dev/mapper/oravg-oraclelv
40G 176M 38G 1% /u01
/dev/sda1 494M 18M 451M 4% /boot
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/mapper/oravg-oradatalv
50G 180M 47G 1% /oradata
[[email protected] ~]# cd /oradata/
[[email protected] oradata]# ll
total 16
drwx------ 2 root root 16384 Jul 24 10:48 lost+found
[[email protected] oradata]# timed out waiting for input: auto-logout
[[email protected] ~]$ timed out waiting for input: auto-logout
Connection closing...Socket close.
Connection closed by foreign host.
Disconnected from remote host(ora 172.16.122.208) at 19:05:02.
Type `help‘ to learn how to use Xshell prompt.
[d:\~]$
Connecting to 172.16.122.208:22...
Connection established.
To escape to local shell, press ‘Ctrl+Alt+]‘.
Last login: Mon Jul 24 10:38:30 2017 from 172.16.8.51
[[email protected] ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-root
992M 350M 591M 38% /
/dev/mapper/rootvg-usr
9.7G 2.8G 6.5G 31% /usr
/dev/mapper/rootvg-opt
3.9G 137M 3.6G 4% /opt
/dev/mapper/rootvg-app
20G 173M 19G 1% /app
/dev/mapper/rootvg-var
3.9G 296M 3.4G 8% /var
/dev/mapper/rootvg-tmp
3.9G 137M 3.6G 4% /tmp
/dev/mapper/rootvg-home
3.9G 137M 3.6G 4% /home
/dev/mapper/oravg-oraclelv
40G 176M 38G 1% /u01
/dev/sda1 494M 18M 451M 4% /boot
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/mapper/oravg-oradatalv
50G 180M 47G 1% /oradata
[[email protected] ~]$ init 6
-bash: init: command not found
[[email protected] ~]$ su -
Password:
[[email protected] ~]# init 6
[[email protected] ~]# Connection closing...Socket close.
Connection closed by foreign host.
Disconnected from remote host(ora 172.16.122.208) at 19:08:05.
Type `help‘ to learn how to use Xshell prompt.
[d:\~]$
Connecting to 172.16.122.208:22...
Could not connect to ‘172.16.122.208‘ (port 22): Connection failed.
Type `help‘ to learn how to use Xshell prompt.
[d:\~]$
Connecting to 172.16.122.208:22...
Connection established.
To escape to local shell, press ‘Ctrl+Alt+]‘.
Last login: Mon Jul 24 11:07:27 2017 from 172.16.8.51
[[email protected] ~]$ su -
Password:
[[email protected] ~]# fdisk /dev/sd
sda sda1 sda2 sdb sdb1 sdc sdc1 sdd
[[email protected] ~]# fdisk /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won‘t be recoverable.
The number of cylinders for this disk is set to 6527.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): p
Disk /dev/sdd: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-6527, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-6527, default 6527):
Using default value 6527
Command (m for help): t
Selected partition 1
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/sdd: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdd1 1 6527 52428096 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[[email protected] ~]# pvcreate /dev/sd
sda sda1 sda2 sdb sdb1 sdc sdc1 sdd sdd1
[[email protected] ~]# pvcreate /dev/sdd1
Writing physical volume data to disk "/dev/sdd1"
Physical volume "/dev/sdd1" successfully created
[[email protected] ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 rootvg lvm2 a-- 59.47G 4.47G
/dev/sdb1 oravg lvm2 a-- 49.97G 9.94G
/dev/sdc1 oravg lvm2 a-- 49.97G 0
/dev/sdd1 lvm2 a-- 50.00G 50.00G
[[email protected] ~]# vgcreate mauservg /dev/sdd1 -s 64M
Volume group "mauservg" successfully created
[[email protected] ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 rootvg lvm2 a-- 59.47G 4.47G
/dev/sdb1 oravg lvm2 a-- 49.97G 9.94G
/dev/sdc1 oravg lvm2 a-- 49.97G 0
/dev/sdd1 mauservg lvm2 a-- 49.94G 49.94G
[[email protected] ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
oraclelv oravg -wi-ao 40.00G
oradatalv oravg -wi-a- 50.00G
app rootvg -wi-ao 20.00G
home rootvg -wi-ao 4.00G
opt rootvg -wi-ao 4.00G
root rootvg -wi-ao 1.00G
swap01 rootvg -wi-ao 8.00G
tmp rootvg -wi-ao 4.00G
usr rootvg -wi-ao 10.00G
var rootvg -wi-ao 4.00G
[[email protected] ~]# lvcreate -L 30G -n mauserlv mauservg
Logical volume "mauserlv" created
[[email protected] ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
mauserlv mauservg -wi-a- 30.00G
oraclelv oravg -wi-ao 40.00G
oradatalv oravg -wi-a- 50.00G
app rootvg -wi-ao 20.00G
home rootvg -wi-ao 4.00G
opt rootvg -wi-ao 4.00G
root rootvg -wi-ao 1.00G
swap01 rootvg -wi-ao 8.00G
tmp rootvg -wi-ao 4.00G
usr rootvg -wi-ao 10.00G
var rootvg -wi-ao 4.00G
[[email protected] ~]# mkfs.ext4 /dev/mauservg/mauserlv
mke2fs 1.42 (29-Nov-2011)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1966080 inodes, 7864320 blocks
393216 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
240 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, 1605632, 2654208,
4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done
[[email protected] ~]#
[[email protected] ~]# mkdir /mauser
[[email protected] ~]# mount /dev/mauservg/mauserlv /mauser/
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-root
992M 351M 591M 38% /
/dev/mapper/rootvg-usr
9.7G 2.8G 6.5G 31% /usr
/dev/mapper/rootvg-opt
3.9G 137M 3.6G 4% /opt
/dev/mapper/rootvg-app
20G 173M 19G 1% /app
/dev/mapper/rootvg-var
3.9G 296M 3.4G 8% /var
/dev/mapper/rootvg-tmp
3.9G 137M 3.6G 4% /tmp
/dev/mapper/rootvg-home
3.9G 137M 3.6G 4% /home
/dev/mapper/oravg-oraclelv
40G 176M 38G 1% /u01
/dev/sda1 494M 18M 451M 4% /boot
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/mapper/mauservg-mauserlv
30G 172M 28G 1% /mauser
[[email protected] ~]# vi /etc/fstab
[[email protected] ~]# timed out waiting for input: auto-logout
[[email protected] ~]$ su -
Password:
[[email protected] ~]# vi /etc/fstab
[[email protected] ~]#
以上是关于LVM的主要内容,如果未能解决你的问题,请参考以下文章