设为首页 收藏本站
查看: 587|回复: 0

[经验分享] Linux下创建软RAID1实战

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-8-19 10:39:50 | 显示全部楼层 |阅读模式
[iyunv@RHEL7 ~]# date

Thu Aug 18 20:45:34 CST 2016
[iyunv@RHEL7 ~]# fdisk /dev/sdc
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.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xe1f55a32.
Command (m for help): p
Disk /dev/sdc: 5368 MB, 5368709120 bytes, 10485760 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: 0xe1f55a32
   Device Boot      Start         End      Blocks   Id  System
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-10485759, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759):
Using default value 10485759
Partition 1 of type Linux and of size 5 GiB is set
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): fd     #fd:linux raid mode
Changed type of partition 'Linux' to 'Linux raid autodetect'
Command (m for help): p
Disk /dev/sdc: 5368 MB, 5368709120 bytes, 10485760 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: 0xe1f55a32
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048    10485759     5241856   fd  Linux raid autodetect
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[iyunv@RHEL7 ~]# partprobe /dev/sdb
[iyunv@RHEL7 ~]# partprobe /dev/sdc
[iyunv@RHEL7 ~]# ls /dev/sdb*
/dev/sdb  /dev/sdb1
[iyunv@RHEL7 ~]# ls /dev/sdc*
/dev/sdc  /dev/sdc1
检查磁盘是 否可以创建RAID1
[iyunv@RHEL7 ~]# mdadm -E /dev/sd[b-c]
/dev/sdb:
   MBR Magic : aa55
Partition[0] :     10483712 sectors at         2048 (type fd)
/dev/sdc:
   MBR Magic : aa55
Partition[0] :     10483712 sectors at         2048 (type fd)
创建RAID1
[iyunv@RHEL7 ~]# mdadm -C -v /dev/md1 -l 1 -n 2 /dev/sdb1 /dev/sdc1
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
mdadm: size set to 5237696K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.
查看RAID状态
[iyunv@RHEL7 ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdc1[1] sdb1[0]
      5237696 blocks super 1.2 [2/2] [UU]
      [============>........]  resync = 60.6% (3175232/5237696) finish=0.1min speed=211682K/sec
unused devices: <none>
[iyunv@RHEL7 ~]# watch cat /proc/mdstat
查看两块盘的状态
[iyunv@RHEL7 ~]# mdadm -E /dev/sdb1 /dev/sdc1
/dev/sdb1:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : b3f8134a:abc56378:c6498702:55215f10
           Name : RHEL7.2:1  (local to host RHEL7.2)
  Creation Time : Thu Aug 18 20:49:27 2016
     Raid Level : raid1
   Raid Devices : 2
Avail Dev Size : 10475520 (5.00 GiB 5.36 GB)
     Array Size : 5237696 (5.00 GiB 5.36 GB)
  Used Dev Size : 10475392 (5.00 GiB 5.36 GB)
    Data Offset : 8192 sectors
   Super Offset : 8 sectors
          State : clean
    Device UUID : 4cb9ba13:784b2294:29e78967:d93d8a94
    Update Time : Thu Aug 18 20:49:54 2016
       Checksum : 595f46a0 - correct
         Events : 17
   Device Role : Active device 0
   Array State : AA ('A' == active, '.' == missing)
/dev/sdc1:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : b3f8134a:abc56378:c6498702:55215f10
           Name : RHEL7.2:1  (local to host RHEL7.2)
  Creation Time : Thu Aug 18 20:49:27 2016
     Raid Level : raid1
   Raid Devices : 2
Avail Dev Size : 10475520 (5.00 GiB 5.36 GB)
     Array Size : 5237696 (5.00 GiB 5.36 GB)
  Used Dev Size : 10475392 (5.00 GiB 5.36 GB)
    Data Offset : 8192 sectors
   Super Offset : 8 sectors
          State : clean
    Device UUID : 841e8e8c:b3ffe403:a487475c:c899e735
    Update Time : Thu Aug 18 20:49:54 2016
       Checksum : d8105c7d - correct
         Events : 17
   Device Role : Active device 1
   Array State : AA ('A' == active, '.' == missing)

查看RAID1状态
[iyunv@RHEL7 ~]# mdadm -D /dev/md1
/dev/md1:
        Version : 1.2
  Creation Time : Thu Aug 18 20:49:27 2016
     Raid Level : raid1
     Array Size : 5237696 (5.00 GiB 5.36 GB)
  Used Dev Size : 5237696 (5.00 GiB 5.36 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent
    Update Time : Thu Aug 18 20:49:54 2016
          State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
  Spare Devices : 0
           Name : RHEL7.2:1  (local to host RHEL7.2)
           UUID : b3f8134a:abc56378:c6498702:55215f10
         Events : 17
    Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync   /dev/sdb1
       1       8       33        1      active sync   /dev/sdc1
[iyunv@RHEL7 ~]#
格式化
[iyunv@RHEL7 ~]# mkfs.xfs -f /dev/md1
meta-data=/dev/md1               isize=256    agcount=4, agsize=327356 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=1309424, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[iyunv@RHEL7 ~]# mkdir /raid1
[iyunv@RHEL7 ~]# mount /dev/md1 /raid1/
[iyunv@RHEL7 ~]# cd /raid1/
[iyunv@RHEL7 raid1]# dd if=/dev/zero of=/raid1/aa bs=2M count=100
100+0 records in
100+0 records out
209715200 bytes (210 MB) copied, 1.7897 s, 117 MB/s
[iyunv@RHEL7 raid1]# ls
aa
[iyunv@RHEL7 raid1]# du /raid1
204800    /raid1


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-259978-1-1.html 上篇帖子: Linux 修改主机名 下篇帖子: quota+samba实现共享配额 Linux
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表