在linux下做RAID1试验

RAID1试验

试验要求:

  • 两块磁盘做raid1
  • 破坏其中一个硬盘(做删除操作)
  • 恢复破坏的磁盘及数据

                           

实现过程:

  1. 1.准备linux,配置IP,链接putty
  2. 2.查看系统信息

[[email protected]~]# uname -a

Linuxlocalhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013x86_64 x86_64 x86_64 GNU/Linux

  1. 3.选择两块30G硬盘

  1. 4.重启

 

[[email protected]~]# reboot

 

5.浏览硬盘

 

[[email protected]~]# fdisk –l

········下面出现新的硬盘信息

Disk /dev/sdb:32.2 GB, 32212254720 bytes

255 heads, 63sectors/track, 3916 cylinders

Units =cylinders of 16065 * 512 = 8225280 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Diskidentifier: 0x00000000

 

Disk /dev/sdc:32.2 GB, 32212254720 bytes

255 heads, 63sectors/track, 3916 cylinders

Units =cylinders of 16065 * 512 = 8225280 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Diskidentifier: 0x00000000

 

6.建立分区b   c

 

[[email protected]~]# fdisk /dev/sdb

Command (m forhelp): n

Command action

   e  extended

   p  primary partition (1-4)

p

Partitionnumber (1-4): 1

First cylinder(1-3916, default 1):

Using defaultvalue 1

Last cylinder,+cylinders or +size{K,M,G} (1-3916, default 3916):

Using defaultvalue 3916

 

Command (m forhelp): t

Selectedpartition 1

Hex code (typeL to list codes): fd

Changed systemtype of partition 1 to fd (Linux raid autodetect)

 

Command (m forhelp): w

The partitiontable has been altered!

 

Callingioctl() to re-read partition table.

Syncing disks.

建立c分区同上

 

7.查看sdb1  sdc

 

[[email protected]~]# fdisk -l /dev/sdb

 

Disk /dev/sdb:32.2 GB, 32212254720 bytes

255 heads, 63sectors/track, 3916 cylinders

Units =cylinders of 16065 * 512 = 8225280 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Diskidentifier: 0xaf9deeac

 

   Device Boot      Start        End      Blocks  Id  System

/dev/sdb1               1        3916   31455238+  fd  Linux raid autodetect

 

[[email protected]~]# fdisk -l /dev/sdc

 

Disk /dev/sdc:32.2 GB, 32212254720 bytes

255 heads, 63sectors/track, 3916 cylinders

Units =cylinders of 16065 * 512 = 8225280 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Diskidentifier: 0x8f842ede

 

   Device Boot      Start         End      Blocks  Id  System

/dev/sdc1               1        3916   31455238+  fd  Linux raid autodetect

 

8. 建立RAID1

 

[[email protected]~]# mdadm -C /dev/md0 -l 1 -n 2 /dev/sd[bc]1

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 ensurethat

    your boot-loader understands md/v1.xmetadata, or use

    --metadata=0.90

Continuecreating array? yes

mdadm:Defaulting to version 1.2 metadata

mdadm: array/dev/md0 started.

 

9.格式化该磁盘阵列

[[email protected]~]# mkfs.ext4 /dev/md0

 

10.创建data目录

[[email protected]~]# mkdir /data

 

11.挂载阵列到data目录下

 

[[email protected]~]# mount /dev/md0 /data

 

12.查看

 

[[email protected]~]# ll /data/

total 16

drwx------. 2root root 16384 Aug 15 04:36 lost+found

 

13.保存分区内容

 

[[email protected]~]# vi /etc/fstab

 

14.扫描系统阵列

 

[[email protected]~]# mdadm -Ds

ARRAY /dev/md0metadata=1.2 name=localhost.localdomain:0UUID=78520035:25e976fe:7411d793:5962601a

 

15.写入到配置文件

[[email protected]~]# mdadm -Ds >> /etc/mdadm.conf

 

16.重启查看

 

[[email protected]~]# reboot

 

17.查看挂载点

 

[[email protected]~]# mount

/dev/mapper/VolGroup-lv_rooton / type ext4 (rw)

proc on /proctype proc (rw)

sysfs on /systype sysfs (rw)

devpts on/dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on/dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")

/dev/sda1 on/boot type ext4 (rw)

/dev/md0 on/data type ext4 (rw)

none on/proc/sys/fs/binfmt_misc type binfmt_misc (rw)

 

18.查看mdstat内容

 

[[email protected]~]# cat /proc/mdstat

Personalities: [raid1]

md0 : activeraid1 sdc1[1] sdb1[0]

      31438720 blocks super 1.2 [2/2] [UU]

 

unuseddevices: <none>

 

19.将其中一块30GB Linux6 64 标准模板的克隆-4.vmdkK删除。

 

 

20.重启后查看被删除的分区

[[email protected]~]# fdisk -l

Disk /dev/sda:21.5 GB, 21474836480 bytes

255 heads, 63sectors/track, 2610 cylinders

Units =cylinders of 16065 * 512 = 8225280 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Diskidentifier: 0x0004106c

 

   Device Boot      Start         End      Blocks  Id  System

/dev/sda1   *          1          64      512000  83  Linux

Partition 1does not end on cylinder boundary.

/dev/sda2              64        2611   20458496   8e  Linux LVM

 

Disk /dev/sdb:32.2 GB, 32212254720 bytes

255 heads, 63sectors/track, 3916 cylinders

Units =cylinders of 16065 * 512 = 8225280 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Diskidentifier: 0xaf9deeac

 

   Device Boot      Start         End      Blocks  Id  System

/dev/sdb1               1        3916   31455238+  fd  Linux raid autodetect

 

Disk /dev/sdc:32.2 GB, 32212254720 bytes

255 heads, 63sectors/track, 3916 cylinders

Units =cylinders of 16065 * 512 = 8225280 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Diskidentifier: 0x00000000

 

 

Disk/dev/mapper/VolGroup-lv_root: 16.8 GB, 16752050176 bytes

255 heads, 63sectors/track, 2036 cylinders

Units =cylinders of 16065 * 512 = 8225280 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Diskidentifier: 0x00000000

 

 

Disk/dev/mapper/VolGroup-lv_swap: 4194 MB, 4194304000 bytes

255 heads, 63sectors/track, 509 cylinders

Units =cylinders of 16065 * 512 = 8225280 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Diskidentifier: 0x00000000

 

 

Disk /dev/md0:32.2 GB, 32193249280 bytes

2 heads, 4sectors/track, 7859680 cylinders

Units =cylinders of 8 * 512 = 4096 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Diskidentifier: 0x00000000

 

21.raid1重建

 

模拟恢复,还是添加30GB的硬盘,重复6建立删除的分区c

 

[[email protected]~]# mdadm /dev/md0 -a /dev/sdc1

mdadm: added/dev/sdc1

 

22.查看日志

 

在linux下做RAID1试验

时间: 2024-07-29 08:12:37

在linux下做RAID1试验的相关文章

Linux下做软RAID

1.查看有多少块硬盘可用#fdisk -l嗯,一般而言,留下系统盘不动,其它的盘如果大小相同的话,统统合起来做一个raid. 2.决定做什么类型的raid.raid-0.raid-1.raid-5?如果有三块一样大小的盘(或者更多),那么极力推荐raid-5.否则请根据实际情况选择raid-0或者raid-1 3.卸载已挂载的数据盘首先查看下,要做raid的几块盘是不是已经被挂载过了#mount如果有,那么挨个删除数据.然后用umount卸载.然后,还有,打开/etc/fstab,注释掉那些刚卸

Linux下做磁盘阵列和各种热备份

磁盘阵列分为: 具有冗余功能的阵列:raid0 raid4 raid5 raid6 raid10 raid01.... 读写速度优势的阵列:raid1 raid4 raid5 raid6 raid10 raid01.... 怎么制作磁盘阵列呢,分别列举: 1.具有冗余功能的阵列raid0 1.1至少需要两块磁盘,sdb和sdc,从两个磁盘中分别划出一个分区分别为:sdb1和sdc1, 1.2在分区的时候需要改变分区号-fd,然后w退出. 1.3制作raid0,在制作该磁盘阵列之前,需要安装mda

LINUX下创建RAID1

实验 添加两块30G硬盘 在不重新启动的情况下,让Linux系统识别到新添加的磁盘 使用putty连接linux操作服务器 [[email protected] ~]# fdisk –l 没有识别到新添加的两块磁盘 [[email protected] ~]# echo "- - -" >/sys/class/scsi_host/host0/scan [[email protected] ~]# echo "-- -" > /sys/class/scsi

linux下做图工具——graphviz安装配置

今天给大家介绍一个很好的流程图制作工具--graphviz 其安装方法很多,可以通过deb包,源码,以及命令安装 本人使用的源码安装,在这里下载其源码包,之后依次输入: ./configure make make install (理论上是没有错误的) 当然还有一个最简单的方法是输入:apt-get install graphviz 直接安装(没有亲测过,应该是可以的) 在安装好了之后就开始了配置(这里由于技术有限,没办法陪的和大牛一样好,请见谅) 由于本人使用的是vim所以这里只能介绍一下vi

Linux 下安装 Redis 服务器

本文简单介绍了 Linux 下安装 Redis 服务器的步骤,同时简要介绍服务器的配置.启动以及状态检测.另外还介绍了 32 位 CentOS 下安装 Redis 时遇到的一些问题的解决.        一. 查看 Linux 相关信息        版本查看cat /etc/issueCentOS release 5.5 (Final)        位数查看getconf LONG_BIT32        二. 安装 tcl        先装好 tcl,不然 redis 的 make t

二十八、Linux下Vim工具常用命令

在linux下做开发,甚至是只做管理维护工作,也少不了Vim的使用.作为一个新手,我也是刚刚接触,本节将我日常使用或收集的Vim常用命令记录下来. 当然,直接在命令行上输入:vimtutor,就可以学习到Vim的所有命令了.Vim很强大,很多牛人在vim里集成很多插件什么的,但这里只介绍基本vim命令 移动命令 h "左 j "下 k "上 l "右 w "光标移动到下一个单词的首字符 a word forward b "光标移动到上一个单词的首

一次有趣的Linux下.Net Core与C语言的合作开发体验:生成Linux标准的用户密码串

最近在项目进程中遇上了Linux用户验证的问题,想着怎么样通过Linux本地用户进行安全校验,于是去查了些资料. Linux的密码存储 查阅资料后发现早期的Linux存储在/etc/password文件中,因为/etc/password权限控制较弱,现在已经不使用了,所以我们这里就不讨论这个文件了,较新的Linux发行版,密码都是存储在/etc/shadow文件中,因为/etc/shadow是管理员权限访问,安全性高出许多,我们可以使用命令来查看文件: $ sudo cat /etc/shado

vmware虚拟机环境下linux网卡做bond配置

vmware workstation 12 常规真机环境下,给网卡做bond配置如下(假设是bond0): 1.ifcfg-eth0 DEVICE=eth0 ONBOOT=yes MASTER=bond0 BOOTPROTO=none SLAVE=yes 2.ifcfg-eth1 DEVICE=eth1 BOOTPROTO=none MASTER=bond0 SLAVE=yes ONBOOT=yes 3.ifcfg-bond0 DEVICE=bond0 BOOTPROTO=static IPAD

快速建立linux下的vpn服务器做加密代理

原文出处: http://www.xfocus.net/articles/200610/893.html 创建时间:2006-10-27文章属性:原创文章提交:fatb (fatb_at_security.zz.ha.cn) 作者:baoz日期:2006-10-26http://baoz.nethttp://xsec.org1妹儿:perlish(*)gmail.com or [email protected] (有时gmail收不到信或者会被当垃圾邮件过滤掉)欢迎转载任何人任何时候转载到任何地