软件磁盘阵列的自动挂载及关闭删除

[root@localhost ~]# mdadm -D /dev/md0 ##显示状态
[root@localhost ~]# mdadm -f /dev/md0 /dev/vdb1 ##建立一个分区至磁盘阵列中
[root@localhost ~]# mdadm -r /dev/md0 /dev/vdb1 ##从磁盘阵列中删除一个分区
[root@localhost ~]# mdadm -a /dev/md0 /dev/vdb1 ##从磁盘阵列中添加一个分区
[root@localhost ~]# mdadm -S /dev/md0 ##停止服务

自动挂载

[root@www ~]# mdadm --detail /dev/md0 | grep -i uuid
        UUID : 7c60c049:57d60814:bd9a77f1:57e49c5b
# 后面那一串数据,就是这个装置向系统注册的 UUID 识别码!

# 开始配置 mdadm.conf
[root@www ~]# vi /etc/mdadm.conf
ARRAY /dev/md0 UUID=7c60c049:57d60814:bd9a77f1:57e49c5b
#     RAID装置      识别码内容

# 开始配置启动自动挂载并测试
[root@www ~]# vi /etc/fstab
/dev/md0    /mnt/raid    ext3    defaults     1 2

[root@www ~]# umount /dev/md0; mount -a
[root@www ~]# df /mnt/raid
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/md0               2916920    188464   2580280   7% /mnt/raid
# 你得确定可以顺利挂载,并且没有发生任何错误!

关闭及删除

  1. 先卸载且删除配置档内与这个 /dev/md0 有关的配置:
    [root@www ~]# umount /dev/md0
    [root@www ~]# vi /etc/fstab
    /dev/md0 /mnt/raid ext3 defaults 1 2
    将这一行删除掉!或者是注解掉也可以!

  2. 直接关闭 /dev/md0 的方法!
    [root@www ~]# mdadm –stop /dev/md0
    mdadm: stopped /dev/md0 <==不罗唆!这样就关闭了!

[root@www ~]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
unused devices: <==看吧!确实不存在任何阵列装置!

[root@www ~]# vi /etc/mdadm.conf
ARRAY /dev/md0 UUID=7c60c049:57d60814:bd9a77f1:57e49c5b
一样啦!删除他或是注解他!

监控方
[root@localhost ~]# watch -n 1 ‘cat /proc/mdstat;echo ====;df -h’
这里写图片描述

操作方
[root@localhost ~]# mdadm -D /dev/md0  ##显示状态
/dev/md0:
        Version : 1.2
  Creation Time : Sat Apr 22 06:43:22 2017
     Raid Level : raid1
     Array Size : 102272 (99.89 MiB 104.73 MB)
  Used Dev Size : 102272 (99.89 MiB 104.73 MB)
   Raid Devices : 2
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Sat Apr 22 06:43:47 2017
          State : clean 
 Active Devices : 2
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 1

           Name : localhost:0  (local to host localhost)
           UUID : 2ff5d09a:a24cd459:c86113ee:f7b509bb
         Events : 17

    Number   Major   Minor   RaidDevice State
       0     253       17        0      active sync   /dev/vdb1
       1     253       18        1      active sync   /dev/vdb2

       2     253       19        -      spare   /dev/vdb3
[root@localhost ~]# mdadm -f /dev/md0 /dev/vdb1
mdadm: set /dev/vdb1 faulty in /dev/md0
[root@localhost ~]# mdadm -r /dev/md0 /dev/vdb1 ##删除
mdadm: hot removed /dev/vdb1 from /dev/md0
[root@localhost ~]# mdadm -a /dev/md0 /dev/vdb1  ##添加
mdadm: added /dev/vdb1
[root@localhost ~]# mdadm -D /dev/md0    ##查看状态
/dev/md0:
        Version : 1.2
  Creation Time : Sat Apr 22 06:43:22 2017
     Raid Level : raid1
     Array Size : 102272 (99.89 MiB 104.73 MB)
  Used Dev Size : 102272 (99.89 MiB 104.73 MB)
   Raid Devices : 2
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Sat Apr 22 06:55:47 2017
          State : clean 
 Active Devices : 2
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 1

           Name : localhost:0  (local to host localhost)
           UUID : 2ff5d09a:a24cd459:c86113ee:f7b509bb
         Events : 38

    Number   Major   Minor   RaidDevice State
       2     253       19        0      active sync   /dev/vdb3
       1     253       18        1      active sync   /dev/vdb2

       3     253       17        -      spare   /dev/vdb1


删除
[root@localhost ~]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/vda1       10473900 3151180   7322720  31% /
devtmpfs          927072       0    927072   0% /dev
tmpfs             942660      80    942580   1% /dev/shm
tmpfs             942660   17056    925604   2% /run
tmpfs             942660       0    942660   0% /sys/fs/cgroup
/dev/md0           98860    5272     93588   6% /mnt
[root@localhost ~]# umount /mnt
[root@localhost ~]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/vda1       10473900 3151180   7322720  31% /
devtmpfs          927072       0    927072   0% /dev
tmpfs             942660      80    942580   1% /dev/shm
tmpfs             942660   17056    925604   2% /run
tmpfs             942660       0    942660   0% /sys/fs/cgroup
[root@localhost ~]# mdadm -D /dev/md0  ##显示状态
/dev/md0:
        Version : 1.2
  Creation Time : Sat Apr 22 06:43:22 2017
     Raid Level : raid1
     Array Size : 102272 (99.89 MiB 104.73 MB)
  Used Dev Size : 102272 (99.89 MiB 104.73 MB)
   Raid Devices : 2
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Sat Apr 22 07:04:40 2017
          State : clean 
 Active Devices : 2
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 1

           Name : localhost:0  (local to host localhost)
           UUID : 2ff5d09a:a24cd459:c86113ee:f7b509bb
         Events : 38

    Number   Major   Minor   RaidDevice State
       2     253       19        0      active sync   /dev/vdb3
       1     253       18        1      active sync   /dev/vdb2

       3     253       17        -      spare   /dev/vdb1
[root@localhost ~]# mdadm -S /dev/md0    ##停止服务
mdadm: stopped /dev/md0
[root@localhost ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): d
Partition number (1-3, default 3): 1
Partition 1 is deleted

Command (m for help): d
Partition number (2,3, default 3): 2
Partition 2 is deleted

Command (m for help): d
Selected partition 3
Partition 3 is deleted

Command (m for help): d
No partition is defined yet!

Command (m for help): p

Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x9d727787

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# partprobe 
[root@localhost ~]# 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值