本日学习课程简介:RAID,LVM,ip配置,
- 磁盘列阵
RAID 即为「Redundant Array of Independent Drives」或「Redundant Array of Inexpensive Drives (or Disks)」的简写,一般俗称「磁盘阵列」,就是以两台或更多的硬盘,组成一个或增加传输速度,或增大总容量,或增加文件备份的大磁盘。
NO RAID
正常的数据存储,一但磁盘损坏,数据丢失,无任何安全性
RAID0
将数据平均分散在所有硬盘内,传输速度快,但一台硬盘故障数据全部损毁。
优点:磁盘空间增大
缺点:无法保证数据安全性,一台故障,整个磁盘阵列全部损毁
RAID1
将数据同时存放于数组中的每一台硬盘中
优点:安全性能高
缺点:性能无提高,成本高
RAID5
将数据分散在所有硬盘内,但同时具有能够还原数据的容错信息,因此传输速度也会变快,总容量较大,可容许一台硬盘故障。
优点:容量增大,性能提升,有适当的故障容许程度
缺点:建置成本高,若两台硬盘故障,整个磁盘阵列中数据损毁
RAID 0+1
RAID 0 和 RAID 1的组合
先做RAID 0 在做RAID1
RAID 0+1是先把硬盘分成2组,每组的2台硬盘先构成RAID 0,再让两组RAID 0构成镜像的RAID 1
配置
关闭服务
[[email protected] ~]# service iptables stop
[[email protected] ~]# chkconfig iptables off
[[email protected] ~]# chkconfig NetworkManager off
配置ip
[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:BC:8B:03
TYPE=Ethernet
UUID=419ff445-a4a1-4231-8f12-d758f46148c7
ONBOOT=yes
NM_CONTROLLED=no
#BOOTPROTO=dhcp
IPADDR=192.168.23.22
NETMACK=255.255.255.0
GATEWAY=192.168.23.1
[[email protected] ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=prod
GAETGAY=192.168.23.1
[[email protected] ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.23.1 prod .us.oracle.com prod
重启网服务
[[email protected] ~]# service iptables restart
LVM基本术语
PV:是物理的磁盘分区
VG:LVM中的物理的磁盘分区,也就是PV,必须加入VG,可以将VG理解为一个仓库或者是几个大的硬盘。
LV:也就是从VG中划分的逻辑分区
如下图所示PV、VG、LV三者关系:
Linux LVM硬盘管理及LVM扩容
创建pv
[[email protected]prod ~]# fdisk -l
[[email protected] ~]# pvcreate /dev/sd
Physical volume "/dev/sdb" successfully created
[[email protected]prod ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name VolumeGroup01
PV Size 99.80 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 25549
Free PE 0
Allocated PE 25549
PV UUID 4DgD1d-p6LR-ZZ3H-SzA1-askJ-ZQvV-cdr3MK
"/dev/sdb" is a new physical volume of "20.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb
VG Name
PV Size 20.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID stXQjd-4oAo-O29R-0735-lHIo-Rh5E-kJfaN3
创建vg
[[email protected]prod ~]# vgcreate VolumeGroup01 /dev/sdb
Volume group "VolumeGroup01" successfully created
[[email protected]prod ~]# vgdisplay
--- Volume group ---
VG Name VolumeGroup01
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 20.00 GiB
PE Size 4.00 MiB
Total PE 5119
Alloc PE / Size 0 / 0
Free PE / Size 5119 / 20.00 GiB
VG UUID stk3yP-NcT3-dHh3-O3z0-KjGv-gqvg-UjT7Fx
--- Volume group ---
VG Name VolumeGroup01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 99.80 GiB
PE Size 4.00 MiB
Total PE 25549
Alloc PE / Size 25549 / 99.80 GiB
Free PE / Size 0 / 0
VG UUID mPL02J-912C-LK7M-00nz-50wB-Fm3f-5lxfmm
创建LV
创建了一个名字为LogVo100 ,容量大小是2048M的分区,其中:-L:指定LV的大小 -n:指定LV的名。Vo1Group01:表示从这个VG中划分LV;
[[email protected]prod ~]# lvcreate -L 2048M -n LogVo100 VolumeGroup01
Logical volume "LogVo100" created
LV格式化及挂载
(使用mksf进行格式化操作),然后LV才能存储资料
[[email protected] ~]# mkfs.ext4 /dev/VolumeGroup01/LogVo100
mke2fs 1.43-WIP (20-Jun-2013)
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
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
测试及挂载
[[email protected] ~]# mkdir /111
[[email protected] ~]# ls /111/
111
[[email protected] ~]# mount /dev/VolumeGroup01/LogVo100 /111
[[email protected] ~]# ll /111
total 16
drwx------. 2 root root 16384 Dec 2 02:59 lost+found]# touch /111/111
如果要在系统启动的时候启动LV,最好是将lvData写入fstable 文件中
使用Vim编辑器,打开/etc/fstab,在最后一行添加/dev/VolumeGroup01/LogVo100 /111 ext4 defaults 0 0,其中/dev/VolumeGroup01/LogVo100 指定需要挂载的分区LV,/111 指定要挂载的目录(挂载点),ext4分区文件系统格式,最后数字表示启动是否检查0代表不检查,其它使用默认即可