zoukankan      html  css  js  c++  java
  • Linux系统管理上机作业7

    1.系统管理09-磁盘管理综合测试题

    实验需求:
    1、用户需把/dev/myvg/mylv逻辑卷以支持磁盘配额的方式挂载到网页目录下
    2、在网页目录下创建测试文件index.html,内容为用户名称,通过浏览器访问测试
    3、创建用户账户,对LVM配置磁盘配额限制用户磁盘容量为软限制80M;硬限制100M、文件数量软限制为80个;硬限制为100个。
     
    实验拓扑:
     
     
     实验步骤:

    [root@localhost ~]# fdisk /dev/sde
    欢迎使用 fdisk (util-linux 2.23.2)。

    更改将停留在内存中,直到您决定将更改写入磁盘。
    使用写入命令前请三思。

    Device does not contain a recognized partition table
    使用磁盘标识符 0xedfc6961 创建新的 DOS 磁盘标签。

    命令(输入 m 获取帮助):n
    Partition type:
    p primary (0 primary, 0 extended, 4 free)
    e extended
    Select (default p): 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/sdf
    欢迎使用 fdisk (util-linux 2.23.2)。

    更改将停留在内存中,直到您决定将更改写入磁盘。
    使用写入命令前请三思。

    Device does not contain a recognized partition table
    使用磁盘标识符 0x79b09a7e 创建新的 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/sdg
    欢迎使用 fdisk (util-linux 2.23.2)。

    更改将停留在内存中,直到您决定将更改写入磁盘。
    使用写入命令前请三思。

    Device does not contain a recognized partition table
    使用磁盘标识符 0x44c88f9e 创建新的 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/sdh
    欢迎使用 fdisk (util-linux 2.23.2)。

    更改将停留在内存中,直到您决定将更改写入磁盘。
    使用写入命令前请三思。

    Device does not contain a recognized partition table
    使用磁盘标识符 0x78d13f59 创建新的 DOS 磁盘标签。

    命令(输入 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 ~]# mdadm -C /dev/md6 -l 5 -n 3 /dev/sd[efg]1
    mdadm: unreconised word on DEVICE line: ARRAY
    mdadm: unreconised word on DEVICE line: metadata=1.2
    mdadm: unreconised word on DEVICE line: name=localhost.localdomain:0
    mdadm: unreconised word on DEVICE line: UUID=3443d6d1:96c46c1a:f79282a4:b7ead418
    mdadm: unreconised word on DEVICE line: auto=yes
    mdadm: unreconised word on DEVICE line: ARRAY
    mdadm: unreconised word on DEVICE line: metadata=1.2
    mdadm: unreconised word on DEVICE line: name=localhost.localdomain:1
    mdadm: unreconised word on DEVICE line: UUID=34e7c431:7422320b:c39462be:1c97c408
    mdadm: unreconised word on DEVICE line: auto=yes
    mdadm: unreconised word on DEVICE line: ARRAY
    mdadm: unreconised word on DEVICE line: metadata=1.2
    mdadm: unreconised word on DEVICE line: name=localhost.localdomain:2
    mdadm: unreconised word on DEVICE line: UUID=ecd7e648:cd6cb04e:90b34504:0d073f89
    mdadm: unreconised word on DEVICE line: auto=yes
    mdadm: Defaulting to version 1.2 metadata
    mdadm: array /dev/md6 started.
    [root@localhost ~]# pvcreate /dev/md6
    Physical volume "/dev/md6" successfully created
    [root@localhost ~]# vgcreate myvg /dev/md6
    Volume group "myvg" successfully created

    [root@localhost ~]# lvcreate -L 30G -n mylv myvg
    Logical volume "mylv" created.
    [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

    [root@localhost ~]# mount /dev/myvg/mylv /usr/local/httpd/htdocs
    mount: 挂载点 /usr/local/httpd/htdocs 不存在

    [root@localhost ~]# ls -R /usr/local

    /usr/local/apache/htdocs:
    index.html

    [root@localhost ~]# mount /dev/myvg/mylv /usr/local/apache/htdocs

    [root@localhost ~]# echo "yaoyiyi" >> /usr/local/apache/htdocs
    -bash: /usr/local/apache/htdocs: 是一个目录
    [root@localhost ~]# echo "yaoyiyi" >> /usr/local/apache/htdocs/index.html
    [root@localhost ~]# cat /usr/local/apache/htdocs/index.html
    yaoyiyi

    [root@localhost ~]# /usr/local/apache/bin/apachectl start

    [root@localhost ~]# df -Th
    文件系统 类型 容量 已用 可用 已用% 挂载点
    /dev/mapper/centos-root xfs 38G 4.9G 33G 13% /
    devtmpfs devtmpfs 985M 0 985M 0% /dev
    tmpfs tmpfs 994M 84K 994M 1% /dev/shm
    tmpfs tmpfs 994M 9.0M 985M 1% /run
    tmpfs tmpfs 994M 0 994M 0% /sys/fs/cgroup
    /dev/md5 xfs 8.0G 33M 8.0G 1% /data
    /dev/sda1 xfs 497M 107M 391M 22% /boot
    /dev/sr0 iso9660 4.1G 4.1G 0 100% /run/media/root/CentOS 7 x86_64
    /dev/md5 xfs 7.8G 36M 7.3G 1% /data10
    /dev/mapper/myvg-mylv xfs 30G 33M 30G 1% /usr/local/apache/htdocs

    [root@localhost ~]# umount /dev/myvg/mylv /usr/local/apache/htdocs
    umount: /usr/local/apache/htdocs:未挂载
    [root@localhost ~]# mkfs.ext4 /dev/myvg/mylv
    mke2fs 1.42.9 (28-Dec-2013)
    文件系统标签=
    OS type: Linux
    块大小=4096 (log=2)
    分块大小=4096 (log=2)
    Stride=128 blocks, Stripe width=256 blocks
    1966080 inodes, 7864320 blocks
    393216 blocks (5.00%) reserved for the super user
    第一个数据块=0
    Maximum filesystem blocks=2155872256
    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: 完成
    正在写入inode表: 完成
    Creating journal (32768 blocks): 完成
    Writing superblocks and filesystem accounting information: 完成

    [root@localhost ~]# mount /dev/myvg/mylv /usr/local/apache/htdocs

    [root@localhost ~]# mount -o remount,usrquota,grpquota /usr/local/apache/htdocs/
    [root@localhost ~]# mount |grep /apache
    /dev/mapper/myvg-mylv on /usr/local/apache/htdocs type ext4 (rw,relatime,quota,usrquota,grpquota,stripe=256,data=ordered)
    [root@localhost ~]# vim /etc/fstab

    /dev/mapper/myvg-mylv on /usr/local/apache/htdocs  ext4  defauls    0 0

    [root@localhost ~]# quotacheck -avug
    quotacheck: Your kernel probably supports journaled quota but you are not using it. Consider switching to journaled quota to avoid running quotacheck after an unclean shutdown.
    quotacheck: Scanning /dev/mapper/myvg-mylv [/usr/local/apache/htdocs] done
    quotacheck: Cannot stat old user quota file /usr/local/apache/htdocs/aquota.user: 没有那个文件或目录. Usage will not be subtracted.
    quotacheck: Cannot stat old group quota file /usr/local/apache/htdocs/aquota.group: 没有那个文件或目录. Usage will not be subtracted.
    quotacheck: Cannot stat old user quota file /usr/local/apache/htdocs/aquota.user: 没有那个文件或目录. Usage will not be subtracted.
    quotacheck: Cannot stat old group quota file /usr/local/apache/htdocs/aquota.group: 没有那个文件或目录. Usage will not be subtracted.
    quotacheck: Checked 2 directories and 1 files
    quotacheck: Old file not found.
    quotacheck: Old file not found.
    [root@localhost ~]# quotaon -avug
    /dev/mapper/myvg-mylv [/usr/local/apache/htdocs]: group quotas turned on
    /dev/mapper/myvg-mylv [/usr/local/apache/htdocs]: user quotas turned on

    [root@localhost ~]# useradd user1

    [root@localhost ~]# edquota -u user1
    Disk quotas for user user1 (uid 1002):
    Filesystem blocks soft hard inodes soft hard
    /dev/mapper/myvg-mylv 0 81920 102400 0 80 100

    [root@localhost ~]# chmod -R 777 /usr
    chmod: 更改"/usr/local/apache/htdocs/aquota.group" 的权限: 不允许的操作
    chmod: 更改"/usr/local/apache/htdocs/aquota.user" 的权限: 不允许的操作
    [root@localhost ~]# su - user1
    上一次登录:一 8月 5 13:44:22 CST 2019pts/1 上
    [user1@localhost ~]$ dd if=/dev/zero of=/usr/local/apache/htdocs/ceshi bs=1M count=90
    dm-2: warning, user block quota exceeded.
    记录了90+0 的读入
    记录了90+0 的写出
    94371840字节(94 MB)已复制,0.809267 秒,117 MB/秒

     [user1@localhost ~]$ touch /usr/local/apache/htdocs/{1..90}.xls

    dm-2: warning, user file quota exceeded.

    2.配置软件RAID 5

    加一个硬盘20G,分四个区,每个区4G

    命令(输入 m 获取帮助):p

    磁盘 /dev/sdb:21.5 GB, 21474836480 字节,41943040 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):512 字节 / 512 字节
    磁盘标签类型:dos
    磁盘标识符:0x77fca4ccL

    设备 Boot Start End Blocks Id System
    /dev/sdb1 2048 8390655 4194304 83 Linux
    /dev/sdb2 8390656 16779263 4194304 83 Linux
    /dev/sdb3 16779264 25167871 4194304 83 Linux
    /dev/sdb4 25167872 33556479 4194304 83 Linux

    [root@localhost ~]# partprobe /dev/sdb

    [root@localhost ~]# mdadm -C /dev/md5 -l 5 -n 3 -x 1 /dev/sdb[1234]   //创建RAID5
    mdadm: Defaulting to version 1.2 metadata
    mdadm: array /dev/md5 started.

    [root@localhost ~]# mkfs.xfs /dev/md5  //对创建的RAID5进行文件系统创建并挂载
    log stripe unit (524288 bytes) is too large (maximum is 256KiB)
    log stripe unit adjusted to 32KiB
    meta-data=/dev/md5 isize=256 agcount=8, agsize=261760 blks
    = sectsz=512 attr=2, projid32bit=1
    = crc=0 finobt=0
    data = bsize=4096 blocks=2094080, imaxpct=25
    = sunit=128 swidth=256 blks
    naming =version 2 bsize=4096 ascii-ci=0 ftype=0
    log =internal log bsize=4096 blocks=2560, version=2
    = sectsz=512 sunit=8 blks, lazy-count=1
    realtime =none extsz=4096 blocks=0, rtextents=0
    [root@localhost ~]# mkdir /data
    mkdir: 无法创建目录"/data": 文件已存在
    [root@localhost ~]# mount /dev/md5 /data

    [root@localhost ~]# mdadm -D /dev/md5  //查看磁盘陈列的信息
    /dev/md5:
    Version : 1.2
    Creation Time : Sat Aug 3 14:45:59 2019
    Raid Level : raid5
    Array Size : 8380416 (7.99 GiB 8.58 GB)
    Used Dev Size : 4190208 (4.00 GiB 4.29 GB)
    Raid Devices : 3
    Total Devices : 4
    Persistence : Superblock is persistent

    Update Time : Sat Aug 3 15:46:44 2019
    State : clean
    Active Devices : 3
    Working Devices : 4
    Failed Devices : 0
    Spare Devices : 1

    Layout : left-symmetric
    Chunk Size : 512K

    Name : localhost.localdomain:5 (local to host localhost.localdomain)
    UUID : c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    Events : 18

    Number Major Minor RaidDevice State
    0 8 17 0 active sync /dev/sdb1
    1 8 18 1 active sync /dev/sdb2
    4 8 19 2 active sync /dev/sdb3

    3 8 20 - spare /dev/sdb4

    [root@localhost ~]# cat /proc/mdstat  /查看
    Personalities : [raid6] [raid5] [raid4]
    md5 : active raid5 sdb3[4] sdb4[3](S) sdb2[1] sdb1[0]
    8380416 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]

    unused devices: <none>

    [root@localhost ~]# mdadm -D -s
    ARRAY /dev/md5 metadata=1.2 spares=1 name=localhost.localdomain:5 UUID=c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    [root@localhost ~]# mdadm -D -s> /etc/mdadm.conf

    [root@localhost ~]# vim /etc/mdadm.conf 

    DEVICE /dev/sdb1 /dev/sdb2 /dev/sdb3 /dev/sdb4 ARRAY /dev/md5 metadata=1.2 spares=1 name=localhost.locald
    omain:5 UUID=c6fb2f7e:840719ea:3eca8ffd:4f5859aa auto=yes

    [root@localhost ~]# df -Th /data
    文件系统 类型 容量 已用 可用 已用% 挂载点
    /dev/md5 xfs 8.0G 33M 8.0G 1% /data

    [root@localhost ~]# vim /etc/fstab 

    /dev/md5                          /data         xfs      defaults      0 0   

    [root@localhost ~]# echo "raid test" > /data/test.txt
    [root@localhost ~]# cat /data/test.txt
    raid test

    维护软RAID (模拟磁盘故障)

    [root@localhost ~]# mdadm -D /dev/md5
    mdadm: unreconised word on DEVICE line: ARRAY
    mdadm: unreconised word on DEVICE line: metadata=1.2
    mdadm: unreconised word on DEVICE line: spares=1
    mdadm: unreconised word on DEVICE line: name=localhost.localdomain:5
    mdadm: unreconised word on DEVICE line: UUID=c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    mdadm: unreconised word on DEVICE line: auto=yes
    /dev/md5:
    Version : 1.2
    Creation Time : Sat Aug 3 14:45:59 2019
    Raid Level : raid5
    Array Size : 8380416 (7.99 GiB 8.58 GB)
    Used Dev Size : 4190208 (4.00 GiB 4.29 GB)
    Raid Devices : 3
    Total Devices : 4
    Persistence : Superblock is persistent

    Update Time : Sat Aug 3 16:05:17 2019
    State : clean
    Active Devices : 3
    Working Devices : 4
    Failed Devices : 0
    Spare Devices : 1

    Layout : left-symmetric
    Chunk Size : 512K

    Name : localhost.localdomain:5 (local to host localhost.localdomain)
    UUID : c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    Events : 18

    Number Major Minor RaidDevice State
    0 8 17 0 active sync /dev/sdb1
    1 8 18 1 active sync /dev/sdb2
    4 8 19 2 active sync /dev/sdb3

    3 8 20 - spare /dev/sdb4

    [root@localhost ~]# mdadm /dev/md5 --fail /dev/sdb2
    mdadm: unreconised word on DEVICE line: ARRAY
    mdadm: unreconised word on DEVICE line: metadata=1.2
    mdadm: unreconised word on DEVICE line: spares=1
    mdadm: unreconised word on DEVICE line: name=localhost.localdomain:5
    mdadm: unreconised word on DEVICE line: UUID=c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    mdadm: unreconised word on DEVICE line: auto=yes
    mdadm: set /dev/sdb2 faulty in /dev/md5
    [root@localhost ~]# mdadm -D /dev/md5
    mdadm: unreconised word on DEVICE line: ARRAY
    mdadm: unreconised word on DEVICE line: metadata=1.2
    mdadm: unreconised word on DEVICE line: spares=1
    mdadm: unreconised word on DEVICE line: name=localhost.localdomain:5
    mdadm: unreconised word on DEVICE line: UUID=c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    mdadm: unreconised word on DEVICE line: auto=yes
    /dev/md5:
    Version : 1.2
    Creation Time : Sat Aug 3 14:45:59 2019
    Raid Level : raid5
    Array Size : 8380416 (7.99 GiB 8.58 GB)
    Used Dev Size : 4190208 (4.00 GiB 4.29 GB)
    Raid Devices : 3
    Total Devices : 4
    Persistence : Superblock is persistent

    Update Time : Sat Aug 3 16:07:39 2019
    State : clean, degraded, recovering
    Active Devices : 2
    Working Devices : 3
    Failed Devices : 1
    Spare Devices : 1

    Layout : left-symmetric
    Chunk Size : 512K

    Rebuild Status : 44% complete

    Name : localhost.localdomain:5 (local to host localhost.localdomain)
    UUID : c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    Events : 27

    Number Major Minor RaidDevice State
    0 8 17 0 active sync /dev/sdb1
    3 8 20 1 spare rebuilding /dev/sdb4
    4 8 19 2 active sync /dev/sdb3

    1 8 18 - faulty /dev/sdb2

    [root@localhost ~]# cat /proc/mdstat
    Personalities : [raid6] [raid5] [raid4]
    md5 : active raid5 sdb3[4] sdb4[3] sdb2[1](F) sdb1[0]
    8380416 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]

    unused devices: <none>

    [root@localhost ~]# mdadm -D /dev/md5
    mdadm: unreconised word on DEVICE line: ARRAY
    mdadm: unreconised word on DEVICE line: metadata=1.2
    mdadm: unreconised word on DEVICE line: spares=1
    mdadm: unreconised word on DEVICE line: name=localhost.localdomain:5
    mdadm: unreconised word on DEVICE line: UUID=c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    mdadm: unreconised word on DEVICE line: auto=yes
    /dev/md5:
    Version : 1.2
    Creation Time : Sat Aug 3 14:45:59 2019
    Raid Level : raid5
    Array Size : 8380416 (7.99 GiB 8.58 GB)
    Used Dev Size : 4190208 (4.00 GiB 4.29 GB)
    Raid Devices : 3
    Total Devices : 4
    Persistence : Superblock is persistent

    Update Time : Sat Aug 3 16:08:25 2019
    State : clean
    Active Devices : 3
    Working Devices : 3
    Failed Devices : 1
    Spare Devices : 0

    Layout : left-symmetric
    Chunk Size : 512K

    Name : localhost.localdomain:5 (local to host localhost.localdomain)
    UUID : c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    Events : 37

    Number Major Minor RaidDevice State
    0 8 17 0 active sync /dev/sdb1
    3 8 20 1 active sync /dev/sdb4
    4 8 19 2 active sync /dev/sdb3

    1 8 18 - faulty /dev/sdb2

    [root@localhost ~]# mdadm /dev/md5 -r /dev/sdb2
    mdadm: unreconised word on DEVICE line: ARRAY
    mdadm: unreconised word on DEVICE line: metadata=1.2
    mdadm: unreconised word on DEVICE line: spares=1
    mdadm: unreconised word on DEVICE line: name=localhost.localdomain:5
    mdadm: unreconised word on DEVICE line: UUID=c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    mdadm: unreconised word on DEVICE line: auto=yes
    mdadm: hot removed /dev/sdb2 from /dev/md5
    [root@localhost ~]# mdadm -D /dev/md5
    mdadm: unreconised word on DEVICE line: ARRAY
    mdadm: unreconised word on DEVICE line: metadata=1.2
    mdadm: unreconised word on DEVICE line: spares=1
    mdadm: unreconised word on DEVICE line: name=localhost.localdomain:5
    mdadm: unreconised word on DEVICE line: UUID=c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    mdadm: unreconised word on DEVICE line: auto=yes
    /dev/md5:
    Version : 1.2
    Creation Time : Sat Aug 3 14:45:59 2019
    Raid Level : raid5
    Array Size : 8380416 (7.99 GiB 8.58 GB)
    Used Dev Size : 4190208 (4.00 GiB 4.29 GB)
    Raid Devices : 3
    Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Sat Aug 3 16:17:11 2019
    State : clean
    Active Devices : 3
    Working Devices : 3
    Failed Devices : 0
    Spare Devices : 0

    Layout : left-symmetric
    Chunk Size : 512K

    Name : localhost.localdomain:5 (local to host localhost.localdomain)
    UUID : c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    Events : 38

    Number Major Minor RaidDevice State
    0 8 17 0 active sync /dev/sdb1
    3 8 20 1 active sync /dev/sdb4
    4 8 19 2 active sync /dev/sdb3
    [root@localhost ~]# mdadm /dev/md5 -a /dev/sdb2
    mdadm: unreconised word on DEVICE line: ARRAY
    mdadm: unreconised word on DEVICE line: metadata=1.2
    mdadm: unreconised word on DEVICE line: spares=1
    mdadm: unreconised word on DEVICE line: name=localhost.localdomain:5
    mdadm: unreconised word on DEVICE line: UUID=c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    mdadm: unreconised word on DEVICE line: auto=yes
    mdadm: added /dev/sdb2
    [root@localhost ~]# mdadm -D /dev/md5
    mdadm: unreconised word on DEVICE line: ARRAY
    mdadm: unreconised word on DEVICE line: metadata=1.2
    mdadm: unreconised word on DEVICE line: spares=1
    mdadm: unreconised word on DEVICE line: name=localhost.localdomain:5
    mdadm: unreconised word on DEVICE line: UUID=c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    mdadm: unreconised word on DEVICE line: auto=yes
    /dev/md5:
    Version : 1.2
    Creation Time : Sat Aug 3 14:45:59 2019
    Raid Level : raid5
    Array Size : 8380416 (7.99 GiB 8.58 GB)
    Used Dev Size : 4190208 (4.00 GiB 4.29 GB)
    Raid Devices : 3
    Total Devices : 4
    Persistence : Superblock is persistent

    Update Time : Sat Aug 3 16:17:44 2019
    State : clean
    Active Devices : 3
    Working Devices : 4
    Failed Devices : 0
    Spare Devices : 1

    Layout : left-symmetric
    Chunk Size : 512K

    Name : localhost.localdomain:5 (local to host localhost.localdomain)
    UUID : c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    Events : 39

    Number Major Minor RaidDevice State
    0 8 17 0 active sync /dev/sdb1
    3 8 20 1 active sync /dev/sdb4
    4 8 19 2 active sync /dev/sdb3

    5 8 18 - spare /dev/sdb2

    [root@localhost ~]# cat /data/test.txt   /挂载包里面的文件都是正常的
    raid test

    3.配置RAID 10

    [root@localhost ~]# fdisk /dev/sdc
    欢迎使用 fdisk (util-linux 2.23.2)。

    更改将停留在内存中,直到您决定将更改写入磁盘。
    使用写入命令前请三思。

    Device does not contain a recognized partition table
    使用磁盘标识符 0x01f8d8ce 创建新的 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):+4G
    分区 1 已设置为 Linux 类型,大小设为 4 GiB

    命令(输入 m 获取帮助):n
    Partition type:
    p primary (1 primary, 0 extended, 3 free)
    e extended
    Select (default p):
    Using default response p
    分区号 (2-4,默认 2):
    起始 扇区 (8390656-41943039,默认为 8390656):
    将使用默认值 8390656
    Last 扇区, +扇区 or +size{K,M,G} (8390656-41943039,默认为 41943039):+4G
    分区 2 已设置为 Linux 类型,大小设为 4 GiB

    命令(输入 m 获取帮助):n
    Partition type:
    p primary (2 primary, 0 extended, 2 free)
    e extended
    Select (default p):
    Using default response p
    分区号 (3,4,默认 3):
    起始 扇区 (16779264-41943039,默认为 16779264):
    将使用默认值 16779264
    Last 扇区, +扇区 or +size{K,M,G} (16779264-41943039,默认为 41943039):+4G
    分区 3 已设置为 Linux 类型,大小设为 4 GiB

    命令(输入 m 获取帮助):n
    Partition type:
    p primary (3 primary, 0 extended, 1 free)
    e extended
    Select (default e): p
    已选择分区 4
    起始 扇区 (25167872-41943039,默认为 25167872):
    将使用默认值 25167872
    Last 扇区, +扇区 or +size{K,M,G} (25167872-41943039,默认为 41943039):+4G
    分区 4 已设置为 Linux 类型,大小设为 4 GiB

    命令(输入 m 获取帮助):p

    磁盘 /dev/sdc:21.5 GB, 21474836480 字节,41943040 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):512 字节 / 512 字节
    磁盘标签类型:dos
    磁盘标识符:0x01f8d8ce

    设备 Boot Start End Blocks Id System
    /dev/sdc1 2048 8390655 4194304 83 Linux
    /dev/sdc2 8390656 16779263 4194304 83 Linux
    /dev/sdc3 16779264 25167871 4194304 83 Linux
    /dev/sdc4 25167872 33556479 4194304 83 Linux

    命令(输入 m 获取帮助):w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.
    正在同步磁盘。
    [root@localhost ~]# partprobe /dev/sdb

    [root@localhost ~]# mdadm -C /dev/md0 -l 1 -n 2 -x 0 /dev/sdd[12]
    mdadm: unreconised word on DEVICE line: ARRAY
    mdadm: unreconised word on DEVICE line: metadata=1.2
    mdadm: unreconised word on DEVICE line: spares=1
    mdadm: unreconised word on DEVICE line: name=localhost.localdomain:5
    mdadm: unreconised word on DEVICE line: UUID=c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    mdadm: unreconised word on DEVICE line: auto=yes
    mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device. If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
    Continue creating array? yes
    mdadm: Defaulting to version 1.2 metadata
    mdadm: array /dev/md0 started.
    [root@localhost ~]# mdadm -C /dev/md1 -l 1 -n 2 -x 0 /dev/sdd[34]
    mdadm: unreconised word on DEVICE line: ARRAY
    mdadm: unreconised word on DEVICE line: metadata=1.2
    mdadm: unreconised word on DEVICE line: spares=1
    mdadm: unreconised word on DEVICE line: name=localhost.localdomain:5
    mdadm: unreconised word on DEVICE line: UUID=c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    mdadm: unreconised word on DEVICE line: auto=yes
    mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device. If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
    Continue creating array? yes
    mdadm: Defaulting to version 1.2 metadata
    mdadm: array /dev/md1 started.
    [root@localhost ~]# cat /proc/mdstat
    Personalities : [raid6] [raid5] [raid4] [raid10] [raid1]
    md1 : active raid1 sdd4[1] sdd3[0]
    4190208 blocks super 1.2 [2/2] [UU]
    [==========>..........] resync = 51.1% (2145408/4190208) finish=0.2min speed=112916K/sec

    md0 : active raid1 sdd2[1] sdd1[0]
    4190208 blocks super 1.2 [2/2] [UU]

    md10 : active raid10 sdc4[3] sdc3[2] sdc2[1] sdc1[0]
    8380416 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]

    md5 : active raid5 sdb4[3] sdb2[5](S) sdb3[4] sdb1[0]
    8380416 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]

    unused devices: <none>
    [root@localhost ~]# mdadm -D /dev/md0
    mdadm: unreconised word on DEVICE line: ARRAY
    mdadm: unreconised word on DEVICE line: metadata=1.2
    mdadm: unreconised word on DEVICE line: spares=1
    mdadm: unreconised word on DEVICE line: name=localhost.localdomain:5
    mdadm: unreconised word on DEVICE line: UUID=c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    mdadm: unreconised word on DEVICE line: auto=yes
    /dev/md0:
    Version : 1.2
    Creation Time : Mon Aug 5 10:01:00 2019
    Raid Level : raid1
    Array Size : 4190208 (4.00 GiB 4.29 GB)
    Used Dev Size : 4190208 (4.00 GiB 4.29 GB)
    Raid Devices : 2
    Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Mon Aug 5 10:01:39 2019
    State : clean
    Active Devices : 2
    Working Devices : 2
    Failed Devices : 0
    Spare Devices : 0

    Name : localhost.localdomain:0 (local to host localhost.localdomain)
    UUID : 3443d6d1:96c46c1a:f79282a4:b7ead418
    Events : 17

    Number Major Minor RaidDevice State
    0 8 49 0 active sync /dev/sdd1
    1 8 50 1 active sync /dev/sdd2
    [root@localhost ~]# mdadm -D /dev/md1
    mdadm: unreconised word on DEVICE line: ARRAY
    mdadm: unreconised word on DEVICE line: metadata=1.2
    mdadm: unreconised word on DEVICE line: spares=1
    mdadm: unreconised word on DEVICE line: name=localhost.localdomain:5
    mdadm: unreconised word on DEVICE line: UUID=c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    mdadm: unreconised word on DEVICE line: auto=yes
    /dev/md1:
    Version : 1.2
    Creation Time : Mon Aug 5 10:02:15 2019
    Raid Level : raid1
    Array Size : 4190208 (4.00 GiB 4.29 GB)
    Used Dev Size : 4190208 (4.00 GiB 4.29 GB)
    Raid Devices : 2
    Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Mon Aug 5 10:02:52 2019
    State : clean
    Active Devices : 2
    Working Devices : 2
    Failed Devices : 0
    Spare Devices : 0

    Name : localhost.localdomain:1 (local to host localhost.localdomain)
    UUID : 34e7c431:7422320b:c39462be:1c97c408
    Events : 17

    Number Major Minor RaidDevice State
    0 8 51 0 active sync /dev/sdd3
    1 8 52 1 active sync /dev/sdd4
    [root@localhost ~]# mdadm -C /dev/md2 -l 0 -n 2 /dev/md{0,1}
    mdadm: unreconised word on DEVICE line: ARRAY
    mdadm: unreconised word on DEVICE line: metadata=1.2
    mdadm: unreconised word on DEVICE line: spares=1
    mdadm: unreconised word on DEVICE line: name=localhost.localdomain:5
    mdadm: unreconised word on DEVICE line: UUID=c6fb2f7e:840719ea:3eca8ffd:4f5859aa
    mdadm: unreconised word on DEVICE line: auto=yes
    mdadm: Defaulting to version 1.2 metadata
    mdadm: array /dev/md2 started.
    [root@localhost ~]# mdadm -Ds /dev/md0 > /etc/mdadm.conf
    [root@localhost ~]# mdadm -Ds /dev/md1 >> /etc/mdadm.conf
    [root@localhost ~]# mdadm -Ds /dev/md2 >> /etc/mdadm.conf
    [root@localhost ~]# cat /etc/mdadm.conf
    ARRAY /dev/md0 metadata=1.2 name=localhost.localdomain:0 UUID=3443d6d1:96c46c1a:f79282a4:b7ead418
    ARRAY /dev/md1 metadata=1.2 name=localhost.localdomain:1 UUID=34e7c431:7422320b:c39462be:1c97c408
    ARRAY /dev/md2 metadata=1.2 name=localhost.localdomain:2 UUID=ecd7e648:cd6cb04e:90b34504:0d073f89
    [root@localhost ~]# mkfs.ext4 /dev/md2
    mke2fs 1.42.9 (28-Dec-2013)
    文件系统标签=
    OS type: Linux
    块大小=4096 (log=2)
    分块大小=4096 (log=2)
    Stride=128 blocks, Stripe width=256 blocks
    524288 inodes, 2094080 blocks
    104704 blocks (5.00%) reserved for the super user
    第一个数据块=0
    Maximum filesystem blocks=2145386496
    64 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

    Allocating group tables: 完成
    正在写入inode表: 完成
    Creating journal (32768 blocks): 完成
    Writing superblocks and filesystem accounting information: 完成

    [root@localhost ~]# mkdir /data10
    [root@localhost ~]# mount /dev/md2 /data10
    [root@localhost ~]# df -h
    文件系统 容量 已用 可用 已用% 挂载点
    /dev/mapper/centos-root 38G 4.9G 33G 13% /
    devtmpfs 985M 0 985M 0% /dev
    tmpfs 994M 84K 994M 1% /dev/shm
    tmpfs 994M 9.0M 985M 1% /run
    tmpfs 994M 0 994M 0% /sys/fs/cgroup
    /dev/md5 8.0G 33M 8.0G 1% /data
    /dev/sda1 497M 107M 391M 22% /boot
    /dev/sr0 4.1G 4.1G 0 100% /run/media/root/CentOS 7 x86_64
    [root@localhost ~]# lsblk /dev/sdd
    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    sdd 8:48 0 20G 0 disk
    ├─sdd1 8:49 0 4G 0 part
    │ └─md0 9:0 0 4G 0 raid1
    │ └─md2 9:2 0 8G 0 raid0
    ├─sdd2 8:50 0 4G 0 part
    │ └─md0 9:0 0 4G 0 raid1
    │ └─md2 9:2 0 8G 0 raid0
    ├─sdd3 8:51 0 4G 0 part
    │ └─md1 9:1 0 4G 0 raid1
    │ └─md2 9:2 0 8G 0 raid0
    └─sdd4 8:52 0 4G 0 part
    └─md1 9:1 0 4G 0 raid1
    └─md2 9:2 0 8G 0 raid0
    [root@localhost ~]# mdadm --detail /dev/md2
    /dev/md2:
    Version : 1.2
    Creation Time : Mon Aug 5 10:05:47 2019
    Raid Level : raid0
    Array Size : 8376320 (7.99 GiB 8.58 GB)
    Raid Devices : 2
    Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Mon Aug 5 10:05:47 2019
    State : clean
    Active Devices : 2
    Working Devices : 2
    Failed Devices : 0
    Spare Devices : 0

    Chunk Size : 512K

    Name : localhost.localdomain:2 (local to host localhost.localdomain)
    UUID : ecd7e648:cd6cb04e:90b34504:0d073f89
    Events : 0

    Number Major Minor RaidDevice State
    0 9 0 0 active sync /dev/md0
    1 9 1 1 active sync /dev/md1
    [root@localhost ~]# vi /etc/mdadm.conf
    DEVICE /dev/sd1 /dev/sdb2 /dev/sdb3 /dev/sdb4 ARRAY /dev/md0 metadata=1.2 name=localhost.localdomain:0 U
    UID=3443d6d1:96c46c1a:f79282a4:b7ead418
    DEVICE /dev/sdd1 /dev/sdd2 ARRAY /dev/md0 metadata=1.2 name=localhost.localdomain:0 UUID=3443d6d1:96c46c1a:f79282a4:b7ead418 auto=yes
    DEVICE /dev/sdd3 /dev/sdd4 ARRAY /dev/md1 metadata=1.2 name=localhost.localdomain:1 UUID=34e7c431:7422320b:c39462be:1c97c408 auto=yes
    DEVICE /dev/sdd1 /dev/sdd2 /dev/sdd3 /dev/sdd4 ARRAY /dev/md2 metadata=1.2 name=localhost.localdomain:2 UUID=ecd7e648:cd6cb04e:90b34504:0d073f89 auto=yes
    ~

    ~
    "/etc/mdadm.conf" 3L, 425C written
    [root@localhost ~]# vi /etc/fstab

    #
    # /etc/fstab
    # Created by anaconda on Sat Aug 3 09:18:03 2019
    #
    # Accessible filesystems, by reference, are maintained under '/dev/disk'
    # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
    #
    /dev/mapper/centos-root / xfs defaults 0 0
    UUID=06eeb661-cf76-46a8-ad98-07ff0fb8edb7 /boot xfs defaults 0 0
    /dev/mapper/centos-swap swap swap defaults 0 0
    /dev/md5 /data xfs defaults 0 0
    /dev/md2 /data10 ext4 defauls 0 0
    ~
    ~
    ~
    "/etc/fstab" 13L, 619C written
    [root@localhost ~]# ls /media
    [root@localhost ~]# mount /dev/md5 /data10
    mount: /dev/md5 已经挂载或 /data10 忙
    /dev/md5 已经挂载到 /data 上
    /dev/md5 已经挂载到 /data10 上
    [root@localhost ~]# mount /dev/md2 /data10
    [root@localhost ~]# ls /media
    [root@localhost ~]# df -h
    文件系统 容量 已用 可用 已用% 挂载点
    /dev/mapper/centos-root 38G 4.9G 33G 13% /
    devtmpfs 985M 0 985M 0% /dev
    tmpfs 994M 84K 994M 1% /dev/shm
    tmpfs 994M 9.0M 985M 1% /run
    tmpfs 994M 0 994M 0% /sys/fs/cgroup
    /dev/md5 8.0G 33M 8.0G 1% /data
    /dev/sda1 497M 107M 391M 22% /boot
    /dev/sr0 4.1G 4.1G 0 100% /run/media/root/CentOS 7 x86_64
    /dev/md5 7.8G 36M 7.3G 1% /data10

  • 相关阅读:
    Java中Date及Timestamp时间相关内容
    Struts2标签<s:select>显示List<String>的设置
    JOffice协同办公开发平台
    asp.net单点登录设想与构思
    JQuery 常用方法基础教程
    一个很好的Jquery学习的网站
    分页存储过程(提高性能)
    _EMIT伪指令
    一键清理源码目录
    MACBOOK安装WIN7(单系统)
  • 原文地址:https://www.cnblogs.com/bbhymy/p/11294836.html
Copyright © 2011-2022 走看看