Linux 软raid设置方法
来源:互联网 发布:hp清零软件 编辑:程序博客网 时间:2024/06/07 02:02
from:
http://www.flmnh.ufl.edu/linux/linux_software_raid.htm
Setting up Linux Software RAID on CentOS
* * RAID is not a substitute for data backups! Always backup your data! * * </>
This document describes how to configure your system for Software RAID1 (mirroring) during the CentOS 4.x clean install. We will mirror data between two hard drives to prevent data loss in the event of a single hard drive failure.
The first section shows how to do a basic setup without LVM. The second section shows how to do LVM on top of software RAID.
Software RAID setup during CentOS installation
For this procedure, we will go with a somewhat simplified setup that includes a single root filesytem and a swap partition. This is similar to the disk layout of a CentOS Automatic partitioning scheme.Steps 3 and 4 (below) will create the device that will hold the root filesystem.
Steps 5 and 6 (below) will create the swap partition.
Note: This document uses sda/sdb as the hard drive device names. On most GNU/Linux systems this will be true for SCSI or SATA drives. PATA IDE drives will be named hda/hdb.
- When you get to the Disk Partitioning Setup screen, select:
Manually partition with Disk Druid
- Highlight and Delete each partition, Logical Volume, and Volume Group until all of the existing partitions have been removed. When finished you should only have "Free Space" in the Type column.
- Add the first Software RAID member by clicking the "New" button.
- Select File System Type = software RAID
- uncheck the Allowable Drives until only the first hard drive is selected (probably sda)
- enter the size in MB. Must leave enough space for Swap partition (1000 MB), and probably want to leave a little fudge factor in case a replacment drive is not quite the same size. For example, an "80 GB" drive might actually have 76000 MB, but a future replacement drive from a different vendor might only have 75000 MB, so we create a software RAID partition of 73000 MB.
- check the box "Force to be a primary partition" because this helps Disk Druid remember to keep the root volume at the front of the hard drive. - Add the second Software RAID member by clicking the "New" button.
- Select File System Type = software RAID
- uncheck the Allowable Drives until only the second hard drive is selected (probably sdb)
- enter the size in MB. This should be the same size as entered in step 3 above. - Add the first Software RAID member that will be used as Swap partition by clicking the "New" button.
- Select File System Type = software RAID
- uncheck the Allowable Drives until only the first hard drive is selected (probably sda)
- enter the size in MB. My rule of thumb is to create a swap partition that is "twice the size of the amount of RAM in the system" plus 512 MB. If I have 512 MB of RAM, my swap partition would be 1 GB. - Add the second Software RAID member that will be used as Swap partition by clicking the "New" button.
- Select File System Type = software RAID
- uncheck the Allowable Drives until only the second hard drive is selected (probably sdb)
- enter the size in MB. This should be the same size as entered in step 5 above. - Create the first RAID device. Click the "RAID" button. Select "Create a RAID device [default=/dev/md0]."
Mount Point: / File System Type: ext3 RAID Device: md0 RAID Level: RAID1 RAID Members: sda1, sdb1 (these are the members created in steps 3 and 4) Number of spares: 0
- Create the second RAID device. Click the "RAID" button. Select "Create a RAID device [default=/dev/md1]."
Mount Point: File System Type: swap RAID Device: md1 RAID Level: RAID1 RAID Members: sda2, sdb2 (these are the members created in steps 5 and 6) Number of spares: 0
- Once the disks are formated and files are being copied from the CD, switch to a virtual console (CTRL-ALT-F1) to install grub on both disks. If you fail to do this, you will need to boot from the install disk and use rescue mode to make your system bootable.
grub> device (hd0) /dev/sda> root (hd0,0)> setup (hd0)> device (hd1) /dev/sdb> root (hd1,0)> setup (hd1)
This makes sure that the grub boot loader is installed on both physical drives and that the system will be bootable even if one of the drives fails.
- Done!
We have chosen to install linux in one big partition. Many people like to create smaller partitions (such as a separate partition for /usr). To do this, you would just need to create additional idential Software RAID members on each disk, and an additional RAID device.
Here is the finished setup:# cat /proc/mdstatPersonalities : [raid1]md1 : active raid1 sdb2[1] sda2[0] 4297280 blocks [2/2] [UU]md0 : active raid1 sdb1[1] sda1[0] 235520832 blocks [2/2] [UU] unused devices:
Failed Drives
In this case, we simulate a drive failure by forcing one of the software raid members into a failed state.# mdadm /dev/md0 --fail /dev/sda1mdadm: set /dev/sda1 faulty in /dev/md0A failed drive looks like this:
# cat /proc/mdstatPersonalities : [raid1]md1 : active raid1 sdb2[1] sda2[0] 4297280 blocks [2/2] [UU]md0 : active raid1 sdb1[1] 235520832 blocks [2/1] [_U]Get more info on the array by asking for details:
# mdadm --detail /dev/md0We then remove the failed member from the array.
# mdadm /dev/md0 --remove /dev/sda1mdadm: hot removed /dev/sda1
After replacing the failed drive, you add a "hot spare" and the system will automatically rebuild the failed md device(s).
# mdadm /dev/md0 --add /dev/sda1mdadm: hot added /dev/sda1# cat /proc/mdstatPersonalities : [raid1]md1 : active raid1 sdb2[1] sda2[0] 4297280 blocks [2/2] [UU]md0 : active raid1 sda1[2] sdb1[1] 235520832 blocks [2/1] [_U] [=>...................] recovery = 6.4% (15183872/235520832)finish=79.6min speed=46101K/secunused devices:
LVM on top of Linux Software RAID (coming in the future!)
* * * This section is under construction. * * *- Linux 软raid设置方法
- dell raid 设置方法
- Linux下通过mdadm进行软raid设置
- Linux as5安装及软raid设置教程
- Linux下通过mdadm进行软raid设置(rhel6.0)
- linux 软raid 配置
- linux 软raid实战
- Linux 软RAID---mdadm
- Linux 软RAID命令
- Linux软RAID实现
- Linux下查看软、硬raid信息的方法
- Linux下查看软、硬raid信息的方法
- Linux下查看软、硬raid信息的方法
- Linux下查看软、硬raid信息的方法
- Linux 系统做软raid
- linux下的软raid
- linux 软RAID配置1
- linux 下 删除软RAID
- 控件隐藏后但可以通过JS找到
- 用户控件如何得到页面里的值
- 文本文件打印类库(C#)
- spring 测试
- .NET中GET与SET的用法
- Linux 软raid设置方法
- linux shell学习笔记1
- C#中对于文件的操作
- 分析网站浏览信息的有用网站
- shell学习笔记2
- JSP语法简表
- JAVA技术:XML配置文件的读取处理
- 鼠标放在一个连接上,会显示图片(类似tooltip)
- Ultimate way to hide rootkit