mdadm用iscsi硬碟和本機硬碟建立raid
1,硬碟環境
[root@rac1 /]# fdisk -l
...
Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
[root@rac2 ~]# fdisk -l
...
Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
[root@rac2 ~]#
2,在rac2上配置 iscsi-target
在rac2上設定/etc/ietd.conf配置檔案為:
Target iqn.2001-04.com.example:storage.disk2.sys1.idisk
Lun 4 Path=/dev/sdb,Type=fileio
Alias sdb
3,啟動iscsi-target服務:
[root@rac2 ~]# /etc/init.d/iscsi-target start
Starting iSCSI target service: [ OK ]
4,在rac1上配置/etc/iscsi.conf
修改下面3項:
DiscoveryAddress=
This needs to be set to the Group IP Address of your UIT Array.
SendAsyncText=yes
For the initiator to receive Vendor Specific async events from the target.
Continuous=yes
To globally specify that all discovery sessions be kept open.
5,啟動服務
[root@rac1 /]# /etc/init.d/iscsi start
Checking iscsi config: [ OK ]
Loading iscsi driver: [ OK ]
mknod: `/dev/iscsictl': File exists
Starting iscsid: [ OK ]
[root@rac1 /]#
6,此時fdisk結果為:
[root@rac1 /]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 892 7164958+ 83 Linux
/dev/sda2 893 1274 3068415 82 Linux swap
/dev/sda3 1275 2610 10731420 83 Linux
Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
Disk /dev/sdc: 536 MB, 536870912 bytes
17 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 1037 * 512 = 530944 bytes
Device Boot Start End Blocks Id System
[root@rac1 /]#
rac1增加一個盤sdc,用/dev/sdb,/dev/sdc做映象。
7,使用mdadm建立RAID1
[root@rac1 /]# mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/sdb /dev/sdc
mdadm: size set to 524224K
mdadm: array /dev/md0 started.
[root@rac1 /]#
每個mdadm的選項都有一個所寫的形式,例如,上面的命令可以縮寫為:
mdadm -Cv /dev/md0 -l1 -n2 /dev/sdb /dev/sdc
此時fdisk顯示:
[root@rac1 /]# fdisk -l
......
Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
Disk /dev/md0: 536 MB, 536805376 bytes
2 heads, 4 sectors/track, 131056 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Device Boot Start End Blocks Id System
Disk /dev/sdc: 536 MB, 536870912 bytes
17 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 1037 * 512 = 530944 bytes
Device Boot Start End Blocks Id System
[root@rac1 /]#
8,檢視raid資訊:
使用cat /proc/mdstat命令來檢視一下RAID的狀態,我們也可以利用watch命令來每隔一段時間重新整理/proc/mdstat的輸出。使用CTRL+C可以取消。
使用mdadm --detail /dev/md0(或mdadm -D /dev/md0)命令以及cat /proc/mdstat命令可以檢視RAID裝置的狀態:
[root@rac1 /]# cat /proc/mdstat
Personalities : [raid1] [raid5]
md0 : active raid1 sdc[1] sdb[0]
524224 blocks [2/2] [UU]
unused devices:
[root@rac1 /]# mdadm -D /dev/md0
/dev/md0:
Version : 00.90.01
Creation Time : Thu Oct 25 15:28:07 2007
Raid Level : raid1
Array Size : 524224 (511.94 MiB 536.81 MB)
Device Size : 524224 (511.94 MiB 536.81 MB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Thu Oct 25 15:30:24 2007
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Number Major Minor RaidDevice State
0 8 16 0 active sync /dev/sdb
1 8 32 1 active sync /dev/sdc
UUID : 081c04ac:6cb9278e:35bade9d:49098be4
Events : 0.34
[root@rac1 /]#
[root@rac1 /]# mdadm --detail /dev/md0
...
9,為陣列建立檔案系統
[root@rac1 /]# mkfs.ext3 /dev/md0
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
131072 inodes, 524224 blocks
26211 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
64 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@rac1 /]# mkdir /mnt/md0
[root@rac1 /]# mount /dev/md0 /mnt/md0
[root@rac1 /]# cd /mnt/md0
[root@rac1 md0]# ls
lost+found
[root@rac1 md0]# touch test
[root@rac1 md0]# ls
lost+found test
[root@rac1 md0]#
10,建立/etc/mdadm.conf配置檔案
一個新陣列被建立後我們最好建立一個/etc/mdadm.conf檔案。沒有該檔案在啟用陣列時我們就得指定更詳細的資訊,為方便,我們使用下列命令:
[root@rac1 /]# mdadm --detail --scan
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=081c04ac:6cb9278e:35bade9d:49098be4
devices=/dev/sdb,/dev/sdc
[root@rac1 /]# mdadm --detail --scan > /etc/mdadm.conf
[root@rac1 /]# cat /etc/mdadm.conf
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=081c04ac:6cb9278e:35bade9d:49098be4
devices=/dev/sdb,/dev/sdc
[root@rac1 /]#
11,啟動停止RAID
使用--stop或-S命令選項可以停止執行的陣列(注意: 停止前必須先umount):
[root@rac1 /]# umount /mnt/md0
[root@rac1 /]# mdadm -S /dev/md0 (或mdadm --stop /dev/md0)
重新啟動可以使用:
[root@rac1 /]# mdadm -As /dev/md0
mdadm: no devices found for /dev/md0
啟動時報錯,
新的配置檔案應該這樣建立:
[root@rac1 ~]# echo DEVICE /dev/sd* > /etc/mdadm.conf
[root@rac1 ~]# mdadm --detail --scan >> /etc/mdadm.conf
[root@rac1 ~]# cat /etc/mdadm.conf
DEVICE /dev/sda /dev/sda1 /dev/sda2 /dev/sda3 /dev/sdb /dev/sdc
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=081c04ac:6cb9278e:35bade9d:49098be4
devices=/dev/sdb,/dev/sdc
[root@rac1 ~]#
然後重新測試關閉啟動
[root@rac1 ~]# mdadm --stop /dev/md0
[root@rac1 ~]# mdadm -As /dev/md0
mdadm: /dev/md0 has been started with 2 drives.
[root@rac1 ~]#
當沒有配置檔案的時候可以用如下方式啟動:
[root@rac1 /]# umount /dev/md0
[root@rac1 /]# mdadm -S /dev/md0
[root@rac1 /]# mdadm -A /dev/md0 /dev/sdb /dev/sdc
mdadm: /dev/md0 has been started with 2 drives.
[root@rac1 /]#
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/312079/viewspace-245788/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 接上一篇(測試--mdadm用iscsi硬碟和本機硬碟建立raid)硬碟AI
- 用mdadm建立raid10AI
- AS4U6認iscsi硬碟硬碟
- 機械硬碟與固態硬碟的適用場景硬碟
- IBM小型機內建RAID更換故障硬碟IBMAI硬碟
- HDD機械硬碟和SSD固態硬碟怎麼樣硬碟
- 筆記本記憶體和硬碟選購攻略 筆記本如何選擇記憶體和硬碟?筆記記憶體硬碟
- 固態硬碟和機械硬碟哪個好?DIY電腦裝機之電腦硬碟選購指南硬碟
- 行動硬碟和二手筆記本硬碟筆記
- 如何檢測機械硬碟和固態硬碟的健康狀況?硬碟
- 伺服器硬碟和普通硬碟區別 伺服器硬碟比普通硬碟貴在哪?伺服器硬碟
- raid5硬碟同步過程中另一塊硬碟掉線怎麼辦AI硬碟
- 建立Azure DS 虛擬機器並附加SSD硬碟虛擬機硬碟
- 為solaris新增硬碟後用format找不到硬碟硬碟ORM
- 伺服器硬碟和普通硬碟的區別伺服器硬碟
- linux下用mdadm命令實現軟raid(zt)LinuxAI
- 機械硬碟和固態硬碟有什麼不同之處?哪個更耐用?硬碟
- 膝上型電腦光碟機怎麼改換硬碟?筆記本光碟機改裝固態硬碟圖文教程硬碟筆記
- 機械硬碟完全拆解硬碟
- 固態硬碟與機械硬碟的概念與區別硬碟
- raid1 raid2 raid5 raid6 raid10的優缺點和做各自raid需要幾塊硬碟AI硬碟
- 筆記本光碟機改裝固態硬碟圖文教程 膝上型電腦怎麼將光碟機位換硬碟?筆記硬碟
- 用bonnie測試硬碟硬碟
- 如何計算硬碟、RAID組與Ceph的IOPS!!!硬碟AI
- raid5硬碟故障資料恢復過程AI硬碟資料恢復
- RAID 損壞後對物理硬碟做完整映象方法AI硬碟
- Debian12 兩塊硬碟組raid1硬碟AI
- 如何使用linux程式mdadm建立軟體RAID1軟陣列LinuxAI陣列
- 對機械硬碟和SSD固態硬碟IOPS、吞吐量的壓測對比硬碟
- 硬碟硬碟
- 【知識分享】伺服器硬碟和普通硬碟的區別伺服器硬碟
- SATA硬碟和一般的硬碟有什麼區別硬碟
- raid5儲存池已損毀硬碟資料AI硬碟
- SATA硬碟與ATA硬碟區別硬碟
- 硬碟韌體升級-希捷硬碟硬碟希捷
- windows怎麼檢視是否是固態硬碟還是機械硬碟Windows硬碟
- 使用mdadm在Linux中配置RAID(轉)LinuxAI
- raid5硬碟掉線但熱備盤未啟用如何恢復資料AI硬碟