查看文章 |
建立Software Raid 1 在已经运营的CentOS 5.3
2009年09月28日 星期一 15:45
FT越来越爱用软Raid,因为实在廉价性能与硬Raid差别不大。而且最重要的功能是监控磁盘的状况。呵呵~~ 这篇文章介绍如何在运营中的CentOS 5.3系统上安装上软Raid。 马上开始: 看看我们的磁盘结构
我想把以上的磁盘转换为 md0、md1、md2
Filesystem Size Used Avail Use% Mounted on /dev/sda3 9.1G 1.1G 7.6G 12% / /dev/sda1 190M 12M 169M 7% /boot tmpfs 252M 0 252M 0% /dev/shm # fdisk -l Disk /dev/sda: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 25 200781 83 Linux /dev/sda2 26 90 522112+ 82 Linux swap / Solaris /dev/sda3 91 1305 9759487+ 83 Linux Disk /dev/sdb: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sdb doesn't contain a valid partition table 安装需要用到的软件 #yum install mkinitrd mdadm 把模组到核心挂载 #modprobe linear #modprobe multipath #modprobe raid0 #modprobe raid1 #modprobe raid5 #modprobe raid6 #modprobe raid10 前期的功夫都准备好了!现在正式开始 1. 把磁盘挂上,分区。 #sfdisk -d /dev/sda | sfdisk /dev/sdb 把/dev/sda 的分区附到 /dev/sdb上 # sfdisk -d /dev/sda | sfdisk /dev/sdb Checking that no-one is using this disk right now ... OK Disk /dev/sdb: 1305 cylinders, 255 heads, 63 sectors/track sfdisk: ERROR: sector 0 does not have an msdos signature /dev/sdb: unrecognized partition table type Old situation: No partitions found New situation: Units = sectors of 512 bytes, counting from 0 Device Boot Start End #sectors Id System /dev/sdb1 * 63 401624 401562 83 Linux /dev/sdb2 401625 1445849 1044225 82 Linux swap / Solaris /dev/sdb3 1445850 20964824 19518975 83 Linux /dev/sdb4 0 - 0 0 Empty Successfully wrote the new partition table Re-reading the partition table ... If you created or changed a DOS partition, /dev/foo7, say, then use dd(1) to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1 (See fdisk(8).) 然后把/dev/sdb 3个分区改变id 为 fd [raid 设备] #fdisk /dev/sdb 按t 然后 1 然后 fd 按t 然后 2 然后 fd 按t 然后 fd 最后w 为安全起见,把/dev/sdb 上的raid设备初次化 #mdadm --zero-superblock /dev/sdb1 #mdadm --zero-superblock /dev/sdb2 #mdadm --zero-superblock /dev/sdb3 2 建立software Raid 1 #mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1 #mdadm --create /dev/md1 --level=1 --raid-disks=2 missing /dev/sdb2 #mdadm --create /dev/md2 --level=1 --raid-disks=2 missing /dev/sdb3 格式化 #mkfs.ext3 /dev/md0 #mkswap /dev/md1 #mkfs.ext3 /dev/md2 写入/etc/mdadm.conf #mdadm --examine --scan > /etc/mdadm.conf 建立临时目录 #mkdir /mnt/md0 #mkdir /mnt/md2 挂载 #mount /dev/md0 /mnt/md0 #mount /dev/md2 /mnt/md2 修改 /etc/fstab #vim /etc/fstab /dev/md2 / ext3 defaults 1 1 |
最近读者:

