关于linux中的磁盘扩容和LVM的疑问
我在VM虚拟机中安装Linux玩oracle9i,当初我只将分区sda1的容量分给/根目录,但是现在数据量不断增加,第一块磁盘已经不够用了.我需要将/根目录扩容,但是现在...
我在VM虚拟机中安装Linux玩oracle9i,当初我只将分区sda1的容量分给/根目录,但是现在数据量不断增加,第一块磁盘已经不够用了.我需要将/根目录扩容,但是现在就算增加另一块磁盘也不会为原来的分区起到作用.
商业应用的时候,分区的数据一定会不断增长,DBA是怎样解决问题的?
听说LVM可以,粗略一看好像最后要格式化才可以mount上去.
备份我也不懂.我只想用最简便方法尽快让数据库运行下去!
各位DBA有什么好的办法吗?谢谢 展开
商业应用的时候,分区的数据一定会不断增长,DBA是怎样解决问题的?
听说LVM可以,粗略一看好像最后要格式化才可以mount上去.
备份我也不懂.我只想用最简便方法尽快让数据库运行下去!
各位DBA有什么好的办法吗?谢谢 展开
2个回答
展开全部
LVM 甚至可以在服务器不断电的情况下动态对磁盘进行扩容,再虚拟一块硬盘后来加入到LVM中
1.添加虚拟硬盘
先关掉虚拟机的电源,然后选择虚拟机,点右键,setting里面点击Add后选择硬盘设备,设置硬盘为1G
2.开启电源,RHEL5启动完成后
格式化硬盘,划出硬盘分区并将格式改为 LVM格式
fdisk -l 查看硬盘分区情况
Disk /dev/hda: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 522 4088542+ 8e Linux LVM
Disk /dev/hdb: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 1985 1000408+ 8e Linux LVM
fdisk /dev/hdb
n
p
2
Command (m for help): n 新建分区
Command action
e extended
p primary partition (1-4) 分区类型为主分区(如果硬盘分区超过4个了,则选择扩展分区,再新建逻辑分区)
p
Partition number (1-4): 2 第几个分区
First cylinder (1986-8322, default 1986): 起始磁柱
Using default value 1986 这时选默认
Last cylinder or +size or +sizeM or +sizeK (1986-8322, default 8322): +1024M 这里我们将这个分区设成一G
Command (m for help): p 查看分区情况
Disk /dev/hdb: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 1985 1000408+ 8e Linux LVM
/dev/hdb2 1986 3970 1000440 83 Linux
Command (m for help): t 更改分区的类型
Partition number (1-4): 2 选择第二个
Hex code (type L to list codes): 8e 这里磁盘格式为 LINUX LVM ,可以使用L来进行查看
Command (m for help): p 再次查看
Disk /dev/hdb: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 1985 1000408+ 8e Linux LVM
/dev/hdb2 1986 3970 1000440 8e Linux LVM 可以看到 hdb2已经变成LVM格式了
Command (m for help): w 保存,切记要保存,不然上面分区,格式化的操作都不会执行,等于白做了
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks. 这里提示我们重启系统后分区表才会改变,其实用下面一个命令即可
partprobe
[root@el5test ~]# fdisk -l
Disk /dev/hda: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 522 4088542+ 8e Linux LVM
Disk /dev/hdb: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 1985 1000408+ 8e Linux LVM
/dev/hdb2 1986 3970 1000440 8e Linux LVM 可以看到hdb2格式化完成了
3.加入到LVM中
[root@el5test ~]# pvdisplay 先看下系统中PV
--- Physical volume ---
PV Name /dev/hda2
VG Name VolGroup00
PV Size 3.90 GB / not usable 24.72 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 124
Free PE 0
Allocated PE 124
PV UUID 0fxOi9-ZeOY-OlQf-QmIO-Gpb4-kaci-24ovGP
--- Physical volume ---
PV Name /dev/hdb1
VG Name VolGroup00
PV Size 976.96 MB / not usable 16.96 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 30
Free PE 5
Allocated PE 25
PV UUID dtNfYJ-31fK-5CxL-9Pxa-pYWb-GcQ5-Vt5011
[root@el5test ~]# pvcreate /dev/hdb2 建立物理卷(PV)
Physical volume "/dev/hdb2" successfully created
[root@el5test ~]# vgextend VolGroup00 /dev/hdb2 把新物理卷加入到卷组中去
/dev/cdrom: open failed: Read-only file system
Attempt to close device '/dev/cdrom' which is not open.
Volume group "VolGroup00" successfully extended 加入成功
[root@el5test ~]# lvextend -L+1G /dev/VolGroup00/LogVol00 把新的空间加到逻辑卷中去
Extending logical volume LogVol00 to 5.03 GB
Logical volume LogVol00 successfully resized
[root@el5test ~]# resize2fs -p /dev/VolGroup00/LogVol00 加上去之后,目前用df -h还看不到新的空间,需要激活
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 1318912 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 1318912 blocks long.
[root@el5test ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
4.9G 3.0G 1.7G 65% / 可以看到这个卷动态放大了
/dev/hda1 99M 14M 81M 15% /boot
tmpfs 132M 0 132M 0% /dev/shm
none 132M 104K 132M 1% /var/lib/xenstored
1.添加虚拟硬盘
先关掉虚拟机的电源,然后选择虚拟机,点右键,setting里面点击Add后选择硬盘设备,设置硬盘为1G
2.开启电源,RHEL5启动完成后
格式化硬盘,划出硬盘分区并将格式改为 LVM格式
fdisk -l 查看硬盘分区情况
Disk /dev/hda: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 522 4088542+ 8e Linux LVM
Disk /dev/hdb: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 1985 1000408+ 8e Linux LVM
fdisk /dev/hdb
n
p
2
Command (m for help): n 新建分区
Command action
e extended
p primary partition (1-4) 分区类型为主分区(如果硬盘分区超过4个了,则选择扩展分区,再新建逻辑分区)
p
Partition number (1-4): 2 第几个分区
First cylinder (1986-8322, default 1986): 起始磁柱
Using default value 1986 这时选默认
Last cylinder or +size or +sizeM or +sizeK (1986-8322, default 8322): +1024M 这里我们将这个分区设成一G
Command (m for help): p 查看分区情况
Disk /dev/hdb: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 1985 1000408+ 8e Linux LVM
/dev/hdb2 1986 3970 1000440 83 Linux
Command (m for help): t 更改分区的类型
Partition number (1-4): 2 选择第二个
Hex code (type L to list codes): 8e 这里磁盘格式为 LINUX LVM ,可以使用L来进行查看
Command (m for help): p 再次查看
Disk /dev/hdb: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 1985 1000408+ 8e Linux LVM
/dev/hdb2 1986 3970 1000440 8e Linux LVM 可以看到 hdb2已经变成LVM格式了
Command (m for help): w 保存,切记要保存,不然上面分区,格式化的操作都不会执行,等于白做了
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks. 这里提示我们重启系统后分区表才会改变,其实用下面一个命令即可
partprobe
[root@el5test ~]# fdisk -l
Disk /dev/hda: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 522 4088542+ 8e Linux LVM
Disk /dev/hdb: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 1985 1000408+ 8e Linux LVM
/dev/hdb2 1986 3970 1000440 8e Linux LVM 可以看到hdb2格式化完成了
3.加入到LVM中
[root@el5test ~]# pvdisplay 先看下系统中PV
--- Physical volume ---
PV Name /dev/hda2
VG Name VolGroup00
PV Size 3.90 GB / not usable 24.72 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 124
Free PE 0
Allocated PE 124
PV UUID 0fxOi9-ZeOY-OlQf-QmIO-Gpb4-kaci-24ovGP
--- Physical volume ---
PV Name /dev/hdb1
VG Name VolGroup00
PV Size 976.96 MB / not usable 16.96 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 30
Free PE 5
Allocated PE 25
PV UUID dtNfYJ-31fK-5CxL-9Pxa-pYWb-GcQ5-Vt5011
[root@el5test ~]# pvcreate /dev/hdb2 建立物理卷(PV)
Physical volume "/dev/hdb2" successfully created
[root@el5test ~]# vgextend VolGroup00 /dev/hdb2 把新物理卷加入到卷组中去
/dev/cdrom: open failed: Read-only file system
Attempt to close device '/dev/cdrom' which is not open.
Volume group "VolGroup00" successfully extended 加入成功
[root@el5test ~]# lvextend -L+1G /dev/VolGroup00/LogVol00 把新的空间加到逻辑卷中去
Extending logical volume LogVol00 to 5.03 GB
Logical volume LogVol00 successfully resized
[root@el5test ~]# resize2fs -p /dev/VolGroup00/LogVol00 加上去之后,目前用df -h还看不到新的空间,需要激活
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 1318912 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 1318912 blocks long.
[root@el5test ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
4.9G 3.0G 1.7G 65% / 可以看到这个卷动态放大了
/dev/hda1 99M 14M 81M 15% /boot
tmpfs 132M 0 132M 0% /dev/shm
none 132M 104K 132M 1% /var/lib/xenstored
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |