Primero tenemos que formatear los disk
lsblk -> ver los disk que tenemos en la maquina en total para este ejemplo son 6 dos para en Raid 0 y 4 para el Raid 1 (dos)
dnf install -y mdadm
n
p
enter (3 veces)
t
L
FD
p
w
Segundo creamos el raid md1 y md0
mdadm -C /dev/md0 -l 1 -n 2 /dev/nvme0n2p1 /dev/nvme0n3p1
-----------------------------------------------------------------
lsblk
mkfs.ext4 /dev/md0
cat /proc/mdstat
mkfs.ext4 /dev/md0
cat /proc/mdstat
mount /dev/md0 /mntls -lls -lhls -lh /mnt
mdadm -f /dev/md0 /dev/nvme0n3p1cat /proc/mdstat
mdadm -r /dev/md0 /dev/nvme0n3p1
tar zcf /mnt/backup2.tar.gz /etc
ls /mnt
lsblk
sfdisk -d /dev/nvme0n2p1 | sfdisk /dev/nvme03p1
mdadm -a /dev/md0 /dev/nvme0n3p1mdadm -f /dev/md0 /dev/nvme0n3p1cat /proc/mdstat
mdadm -r /dev/md0 /dev/nvme0n3p1
tar zcf /mnt/backup2.tar.gz /etc
ls /mnt
lsblk
sfdisk -d /dev/nvme0n2p1 | sfdisk /dev/nvme03p1
Como eliminar todo el raid
35:41umount /dev/md0
mdadm --stop /dev/md0
mdadm --zero-superblock /dev/nvme0n2p1
mdadm --zero-superblock /dev/nvme0n3p1
mdadm -C /dev/md1 -l 1 -n 2 /dev/nvme0n4p1 /dev/nvme0n5p1
3 Formateamos los raid md1 y md0
mkfs.xfs /dev/md0
mkfs.xfs /dev/md1
4 Solo cuando los raid estan separados o uno solo RAID 1 se monte automáticamente en cada reinicio, abre el archivo /etc/fstab con tu editor de texto preferido (como nano o vim):
/dev/md0 /mnt xfs defaults 0 0
/dev/md1 /mnt xfs defaults 0 0
6 Para el Raid 0 agregamos 2 discos mas de 1G y seguimos el mismo
procedimiento de formatear
fdisk /dev/nvme0n2 -> Formatear
n
enter (3 veces)
t
L
FD
p
--------->>>>>
instalamos
umount /mnt
7 Creamos el raid O md2 y debemos detener los raid 1
mdadm --stop /dev/md0
mdadm --stop /dev/md1
mdadm -C /dev/md2 -l 0 -n 4 /dev/md0 /dev/md1 /dev/nvme0n6p1 /dev/nvme0n7p1
enter and yes
8 Formateamos los raid md2
mkfs.xfs /dev/md2
9 montamos el raid
mount /dev/md2 /mnt
df -h ->
10 RAID 1 se monte automáticamente en cada reinicio, abre el archivo /etc/fstab con tu editor de texto preferido (como nano o vim):
sudo nano /etc/fstab
/dev/md2 /mnt xfs defaults 0 0
watch cat /proc/mdstat -> verificar el esta del Raid 0
entonces queda asi
[root@server admin]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sr0 11:0 1 1.7G 0 rom
nvme0n1 259:0 0 20G 0 disk
├─nvme0n1p1 259:1 0 800M 0 part /boot
└─nvme0n1p2 259:2 0 19.2G 0 part
├─almalinux-root 253:0 0 5.5G 0 lvm /
├─almalinux-swap 253:1 0 1G 0 lvm [SWAP]
├─almalinux-var 253:2 0 7.2G 0 lvm /var
├─almalinux-home 253:3 0 3.5G 0 lvm /home
└─almalinux-tmp 253:4 0 2G 0 lvm /tmp
nvme0n2 259:3 0 1G 0 disk
└─nvme0n2p1 259:4 0 1023M 0 part
└─md0 9:0 0 1022M 0 raid1
└─md2 9:2 0 4G 0 raid0 /mnt
nvme0n3 259:5 0 1G 0 disk
└─nvme0n3p1 259:6 0 1023M 0 part
└─md0 9:0 0 1022M 0 raid1
└─md2 9:2 0 4G 0 raid0 /mnt
nvme0n4 259:7 0 1G 0 disk
└─nvme0n4p1 259:8 0 1023M 0 part
└─md1 9:1 0 1022M 0 raid1
└─md2 9:2 0 4G 0 raid0 /mnt
nvme0n5 259:9 0 1G 0 disk
└─nvme0n5p1 259:10 0 1023M 0 part
└─md1 9:1 0 1022M 0 raid1
└─md2 9:2 0 4G 0 raid0 /mnt
nvme0n6 259:11 0 1G 0 disk
└─nvme0n6p1 259:12 0 1023M 0 part
└─md2 9:2 0 4G 0 raid0 /mnt
nvme0n7 259:13 0 1G 0 disk
└─nvme0n7p1 259:14 0 1023M 0 part
└─md2 9:2 0 4G 0 raid0 /mnt
Para tener una vista detallada de los Raid
[root@server admin]# cat /proc/mdstat
Personalities : [raid1] [raid0]
md1 : active raid1 nvme0n4p1[0] nvme0n5p1[1]
1046528 blocks super 1.2 [2/2] [UU]
md0 : active raid1 nvme0n2p1[0] nvme0n3p1[1]
1046528 blocks super 1.2 [2/2] [UU]
md2 : active raid0 md1[1] md0[0] nvme0n7p1[3] nvme0n6p1[2]
4179968 blocks super 1.2 512k chunks
unused devices: <none>
con bash
lsblk
y
mkdir -p /mnt/raid
mount /dev/md0 /mnt/raid
echo "/dev/md0 /mnt/raid ext4 defaults 0 0" >> /etc/fstab
mdadm --stop /dev/md0
mdadm --zero-superblock /dev/nvme0n2 /dev/nvme0n3
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>RAID Manager</title></head><body> <h1>RAID Manager</h1> <form method="POST"> <label for="raid-type">Choose RAID type:</label> <select name="raid-type" id="raid-type" required> <option value="1">RAID 1 (Mirroring)</option> <option value="0">RAID 0 (Striping)</option> </select> <br><br>
<label for="disk1">Disk 1:</label> <input type="text" name="disk1" id="disk1" placeholder="/dev/nvme0n2" required> <br><br>
<label for="disk2">Disk 2:</label> <input type="text" name="disk2" id="disk2" placeholder="/dev/nvme0n3" required> <br><br>
<label for="mount-point">Mount Point:</label> <input type="text" name="mount-point" id="mount-point" placeholder="/mnt/raid" required> <br><br>
<button type="submit" name="create">Create RAID</button> <button type="submit" name="clean">Clean Disks</button> </form>
<?php if ($_SERVER['REQUEST_METHOD'] === 'POST') { $raidType = $_POST['raid-type']; $disk1 = $_POST['disk1']; $disk2 = $_POST['disk2']; $mountPoint = $_POST['mount-point'];
if (isset($_POST['create'])) { echo "<h2>Creating RAID...</h2>"; $cmd = "mdadm --create --verbose /dev/md0 --level=$raidType --raid-devices=2 $disk1 $disk2 && mkfs.ext4 /dev/md0 && mkdir -p $mountPoint && mount /dev/md0 $mountPoint"; shell_exec($cmd); echo "<p>RAID created and mounted at $mountPoint</p>"; }
if (isset($_POST['clean'])) { echo "<h2>Cleaning Disks...</h2>"; $cmd = "mdadm --stop /dev/md0 && mdadm --zero-superblock $disk1 $disk2"; shell_exec($cmd); echo "<p>Disks cleaned successfully.</p>"; } } ?></body></html>
No hay comentarios.:
Publicar un comentario