chapter07

1、添加三块硬盘
2、为三块硬盘分区
[root@localhost ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0x7de40b4c 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-41943039,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-41943039,默认为 41943039):
将使用默认值 41943039
分区 1 已设置为 Linux 类型,大小设为 20 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@localhost ~]# fdisk /dev/sdc
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0x76aed428 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):
命令(输入 m 获取帮助):
命令(输入 m 获取帮助):n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-41943039,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-41943039,默认为 41943039):
将使用默认值 41943039
分区 1 已设置为 Linux 类型,大小设为 20 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@localhost ~]# fdisk /dev/sdd
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0x31d4f8d4 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-41943039,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-41943039,默认为 41943039):
将使用默认值 41943039
分区 1 已设置为 Linux 类型,大小设为 20 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.

3、创建RAID 5
[root@localhost ~]# mdadm -C /dev/md5 -l 5 -n 3 /dev/sd[bcd]1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md5 started.
[root@localhost ~]# mkfs.xfs /dev/md5
log stripe unit (524288 bytes) is too large (maximum is 256KiB)
log stripe unit adjusted to 32KiB
meta-data=/dev/md5               isize=256    agcount=16, agsize=654720 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=10475520, imaxpct=25
         =                       sunit=128    swidth=256 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=5120, version=2
         =                       sectsz=512   sunit=8 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost ~]# vi /etc/fstab
[root@localhost ~]# mkdir /xuexi
[root@localhost ~]# mount /dev/md5 /xuexi/
[root@localhost ~]# vi /etc/fstab 
[root@localhost ~]# mdadm -D -s > /etc/mdadm.conf
[root@localhost ~]# vi /etc/mdadm.conf
4、创建物理卷
[root@localhost ~]# pvcreate /dev/md5
WARNING: xfs signature detected on /dev/md5 at offset 0. Wipe it? [y/n]: y
  Wiping xfs signature on /dev/md5.
  Physical volume "/dev/md5" successfully created
[root@localhost ~]# pvscan
  PV /dev/sda2   VG centos   lvm2 [29.51 GiB / 44.00 MiB free]
  PV /dev/md5                lvm2 [39.97 GiB]
  Total: 2 [69.47 GiB] / in use: 1 [29.51 GiB] / in no VG: 1 [39.97 GiB]
5、创建卷组
[root@localhost ~]# vgcreate  vg /dev/md55
 [root@localhost ~]# vgcreate myvg /dev/md5
  Volume group "myvg" successfully created
[root@localhost ~]# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "centos" using metadata type lvm2
  Found volume group "myvg" using metadata type lvm2
6、创建逻辑卷
[root@localhost ~]# lvcreate -L 30G -n mylv myvg
  Logical volume "mylv" created.
[root@localhost ~]# lvscan
  ACTIVE            '/dev/centos/swap' [2.00 GiB] inherit
  ACTIVE            '/dev/centos/root' [27.46 GiB] inherit
  ACTIVE            '/dev/myvg/mylv' [30.00 GiB] inherit
7、格式化逻辑卷
[root@localhost ~]# mkfs.xfs /dev/myvg/mylv
log stripe unit (524288 bytes) is too large (maximum is 256KiB)
log stripe unit adjusted to 32KiB
meta-data=/dev/myvg/mylv         isize=256    agcount=16, agsize=491392 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=7862272, imaxpct=25
         =                       sunit=128    swidth=256 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=3840, version=2
         =                       sectsz=512   sunit=8 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
8、安装apache
[root@localhost ~]# yum -y install gcc gcc-c++
[root@localhost ~]#tar xf httpd-2.2.17.tar.gz -C /usr/src
[root@localhost ~]#cd /usr/src/httpd-2.2.17
[root@localhost httpd-2.2.17]#./configure --prefix=/usr/local/apache
[root@localhost httpd-2.2.17]#make
[root@localhost httpd-2.2.17]#make install
[root@localhost httpd-2.2.17]#cd /usr/local/apache/conf/
[root@localhost conf/]#set "s/#ServerName w/ServerName w"  /httpd.conf
[root@localhost ~]#/usr/local/apache/bin/apachectl start
[root@localhost ~]yum -y install lynx
[root@localhost ~]lynx 127.0.0.1
9、挂载[root@localhost ~]# mount -O usrquota,grpquota /dev/myvg/mylv /usr/local/apache/htdocs/
[root@localhost ~]# df -Th
文件系统                类型      容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root xfs        28G  4.8G   23G   18% /
devtmpfs                devtmpfs  481M     0  481M    0% /dev
tmpfs                   tmpfs     490M   80K  490M    1% /dev/shm
tmpfs                   tmpfs     490M  7.0M  483M    2% /run
tmpfs                   tmpfs     490M     0  490M    0% /sys/fs/cgroup
/dev/sda1               xfs       497M  107M  391M   22% /boot
/dev/mapper/myvg-mylv   xfs        30G   33M   30G    1% /usr/local/apache/htdocs
10、磁盘配额
[root@localhost ~]# quotacheck -auvg
quotacheck: Skipping /dev/mapper/myvg-mylv [/data]
quotacheck: Skipping /dev/mapper/vg-lv [/usr/local/apache/htdocs]
quotacheck: Cannot find filesystem to check or filesystem not mounted with quota option.
[root@localhost ~]# quotaon -avug
11、创建index.html[root@localhost ~]# cd /usr/local/apache/htdocs/
[root@localhost htdocs]# vim index.html
12、创建用户并对LVM配置磁盘配额
[root@localhost htdocs]# useradd -d /usr/local/apache/htdocs/wang     wang
[root@localhost htdocs]# edquota -u wang
Disk quotas for user wang (uid 1008):
  Filesystem                   blocks       soft       hard     inodes     soft     hard
  /dev/mapper/myvg-mylv            12       81920       102400          7     80     100
原文地址:https://www.cnblogs.com/wzy01/p/11301268.html