Cài đặt RAID 1 trên hệ thống LVM trong Ubuntu 10.4 (phần I) ppt

10 794 0
Cài đặt RAID 1 trên hệ thống LVM trong Ubuntu 10.4 (phần I) ppt

Đang tải... (xem toàn văn)

Thông tin tài liệu

Cài đặt RAID 1 trên hệ thống LVM trong Ubuntu 10.4 (phần I) Bài viết sau sẽ hướng dẫn và giải thích với các bạn cách thiết lập, cài đặt phần mềm theo chuẩn RAID1 trên hệ thống LVM đang hoạt dộng trong nền tảng Ubuntu 10.04. Và GRUB2 bootloader sẽ được thiết lập để hệ thống không thể khởi động khi 1 trong 2 ổ cứng có vấn đề. Lưu ý sơ bộ Trong thí nghiệm này sử dụng hệ điều hành Ubuntu 10.04 và 2 ổ cứng (/dev/sda và /dev/sdb), trong đó /dev/sdb không sử dụng, /dev/sda có các phân vùng sau: /dev/sda1: phân vùng boot - ext2 /dev/sda2: là phân vùng extended, có chứa /dev/sda5 /dev/sda5: được sử dụng cho LVM (volume group server1) và có ký tự / (root) và swap (swap_1) Và đến khi kết thúc, chúng ta sẽ có được kết quả như sau: /dev/md0 (tạo ra từ /dev/sda1 và /dev/sdb1): phân vùng /boot - ext2 /dev/md1 (tạo ra từ /dev/sda5 và /dev/sdb5): LVM (volume group server1) có ký tự / (root) và swap (volume swap_1) Còn đây là hiện tại: df -h root@server1:~# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/server1-root 4.5G 809M 3.5G 19% / none 243M 176K 242M 1% /dev none 247M 0 247M 0% /dev/shm none 247M 36K 247M 1% /var/run none 247M 0 247M 0% /var/lock none 247M 0 247M 0% /lib/init/rw /dev/sda1 228M 17M 199M 8% /boot root@server1:~# fdisk -l root@server1:~# fdisk -l Disk /dev/sda: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 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 Disk identifier: 0x0006b7b7 Device Boot Start End Blocks Id System /dev/sda1 * 1 32 248832 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 32 653 4990977 5 Extended Partition 2 does not end on cylinder boundary. /dev/sda5 32 653 4990976 8e Linux LVM Disk /dev/sdb: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 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 Disk identifier: 0x00000000 Disk /dev/sdb doesn't contain a valid partition table root@server1:~# pvdisplay root@server1:~# pvdisplay Physical volume PV Name /dev/sda5 VG Name server1 PV Size 4.76 GiB / not usable 2.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 1218 Free PE 3 Allocated PE 1215 PV UUID bsF5F5-s2RN-ed1h-zjeb-4mAJ-aktq-kEn86r root@server1:~# vgdisplay root@server1:~# vgdisplay Volume group VG Name server1 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 4.76 GiB PE Size 4.00 MiB Total PE 1218 Alloc PE / Size 1215 / 4.75 GiB Free PE / Size 3 / 12.00 MiB VG UUID hMwXAh-zZsA-w39k-g6Bg-LW4W-XX8q-EbyXfA root@server1:~# lvdisplay root@server1:~# lvdisplay Logical volume LV Name /dev/server1/root VG Name server1 LV UUID b5A1R5-Zhml-LSNy-v7WY-NVmD-yX1w-tuQVUW LV Write Access read/write LV Status available # open 1 LV Size 4.49 GiB Current LE 1149 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 251:0 Logical volume LV Name /dev/server1/swap_1 VG Name server1 LV UUID 2UuF7C-zxKA-Hgz1-gZHe-rFlq-cKW7-jYVCzp LV Write Access read/write LV Status available # open 1 LV Size 264.00 MiB Current LE 66 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 251:1 root@server1:~# Cài đặt mdadm Một trong những công cụ quan trọng nhất để thiết lập chế độ RAID là mdadm. Sử dụng câu lệnh sau để cài đặt: aptitude install initramfs-tools mdadm Sau đó, tiến hành tải thêm 1 vài module kernel khác (để tránh phải khởi động lại hệ thống): modprobe linear modprobe multipath modprobe raid0 modprobe raid1 modprobe raid5 modprobe raid6 modprobe raid10 Tiếp theo chạy câu lệnh sau: cat /proc/mdstat Và kết quả trả về sẽ có dạng như sau: root@server1:~# cat /proc/mdstat Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] unused devices: <none> root@server1:~# Chuẩn bị cho phân vùng /dev/sdb Để tạo RAID1 array trên hệ thống đang hoạt động sẵn, chúng ta cần chuẩn bị phân vùng /dev/sdb cho RAID1, sau đó copy toàn bộ nội dung của /dev/sda tới phân vùng đó, và cuối cùng thêm /dev/sda tới RAID1 array. Trước tiên ta copy toàn bộ bảng phân vùng từ /dev/sda tới /dev/sdb, vì vậy cả 2 ổ đĩa đều có kết quả như nhau: sfdisk -d /dev/sda | sfdisk force /dev/sdb Và kết quả trả về sẽ có dạng như sau: root@server1:~# sfdisk -d /dev/sda | sfdisk force /dev/sdb Checking that no-one is using this disk right now Warning: extended partition does not start at a cylinder boundary. DOS and Linux will interpret the contents differently. OK Disk /dev/sdb: 652 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 * 2048 499711 497664 83 Linux /dev/sdb2 501758 10483711 9981954 5 Extended /dev/sdb3 0 - 0 0 Empty /dev/sdb4 0 - 0 0 Empty /dev/sdb5 501760 10483711 9981952 8e Linux LVM Warning: partition 1 does not end at a cylinder boundary 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).) root@server1:~# Sử dụng câu lệnh sau: fdisk -l và cả 2 ổ cứng sẽ như thế này: root@server1:~# fdisk -l Disk /dev/sda: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 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 Disk identifier: 0x0006b7b7 Device Boot Start End Blocks Id System /dev/sda1 * 1 32 248832 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 32 653 4990977 5 Extended Partition 2 does not end on cylinder boundary. /dev/sda5 32 653 4990976 8e Linux LVM Disk /dev/sdb: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 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 Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sdb1 * 1 32 248832 83 Linux Partition 1 does not end on cylinder boundary. /dev/sdb2 32 653 4990977 5 Extended Partition 2 does not end on cylinder boundary. /dev/sdb5 32 653 4990976 8e Linux LVM root@server1:~# Tiếp theo, tiến hành chuyển đổi định dạng của 3 phân vùng trên /dev/sdb thành Linux raid autodetect: fdisk /dev/sdb root@server1:~# fdisk /dev/sdb WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): < gõ m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): < gõ t Partition number (1-5): < gõ 1 Hex code (type L to list codes): < gõ L 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT- 2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT- 4 FAT16 <32M 41 PPC PReP Boot 85 Linux extended c7 Syrinx 5 Extended 42 SFS 86 NTFS volume set da Non-FS data 6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / . 7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility 8 AIX 4f QNX4.x 3rd part 8e Linux LVM df BootIt 9 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT f W95 Ext'd (LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/ 10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b 11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor 12 Compaq diagnost 61 SpeedStor a9 NetBSD f4 SpeedStor 14 Hidden FAT16 <3 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary 16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS 17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE 18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto 1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep 1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT 1e Hidden W95 FAT1 Hex code (type L to list codes): < gõ fd Changed system type of partition 1 to fd (Linux raid autodetect) Command (m for help): < gõ t Partition number (1-5): < gõ 5 Hex code (type L to list codes): < gõ fd Changed system type of partition 5 to fd (Linux raid autodetect) Command (m for help): < gõ w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. root@server1:~# Dùng lệnh sau: fdisk -l để chỉ ra rằng /dev/sdb1 và /dev/sdb5 đã trở thành Linux raid autodetect: root@server1:~# fdisk -l Disk /dev/sda: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 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 Disk identifier: 0x0006b7b7 Device Boot Start End Blocks Id System /dev/sda1 * 1 32 248832 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 32 653 4990977 5 Extended Partition 2 does not end on cylinder boundary. /dev/sda5 32 653 4990976 8e Linux LVM Disk /dev/sdb: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 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 Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sdb1 * 1 32 248832 fd Linux raid autodetect Partition 1 does not end on cylinder boundary. /dev/sdb2 32 653 4990977 5 Extended Partition 2 does not end on cylinder boundary. /dev/sdb5 32 653 4990976 fd Linux raid autodetect root@server1:~# Để chắc chắn rằng không còn gì sót lại từ quá trình cài đặt RAID trước trên /dev/sdb, thực hiện câu lệnh sau: mdadm zero-superblock /dev/sdb1 mdadm zero-superblock /dev/sdb5 Nếu không còn gì sót lại từ RAID trước kia, mỗi câu lệnh bên trên sẽ trả lại thông báo lỗi như sau (không có gì phải lo lắng): root@server1:~# mdadm zero-superblock /dev/sdb1 mdadm: Unrecognised md component device - /dev/sdb1 root@server1:~# Còn lại với các trường hợp khác, câu lệnh sẽ không hiển thị bất kỳ thông báo nào. . Cài đặt RAID 1 trên hệ thống LVM trong Ubuntu 10 .4 (phần I) Bài viết sau sẽ hướng dẫn và giải thích với các bạn cách thiết lập, cài đặt phần mềm theo chuẩn RAID1 trên hệ thống LVM đang. /dev/mapper/server1-root 4. 5G 809M 3.5G 19 % / none 243 M 17 6K 242 M 1% /dev none 247 M 0 247 M 0% /dev/shm none 247 M 36K 247 M 1% /var/run none 247 M 0 247 M 0% /var/lock none 247 M 0 247 M 0% /lib/init/rw. situation: Units = sectors of 512 bytes, counting from 0 Device Boot Start End #sectors Id System /dev/sdb1 * 2 048 49 9 711 49 76 64 83 Linux /dev/sdb2 5 017 58 10 48 3 711 99 819 54 5 Extended /dev/sdb3

Ngày đăng: 11/07/2014, 23:20

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan