Make a fresh Install with raid1 software enabled

Problems/questions regarding MailCleaner installation

Moderators: FlorianB, Pascal, bourgeois, mentor

Lupraen
Posts: 5
Joined: Thu Nov 16, 2017 2:16 pm
How did you hear about Mailcleaner: I am using enterprise version in Espace RDI.

Make a fresh Install with raid1 software enabled

Postby Lupraen » Wed Dec 13, 2017 4:47 pm

Hello,

Please, excuse me if your eyes is bleeding because of my bad English :)

First, you need to deploy your VM to your virtual environnement.
And Add a second disk drive to your VM

Don't try this on production server without a full backup of your VM. You can loose everything even with a small failure.

!!! This make sense only if your second VM drive is stored on a second datastore on a different physical drive than the first datastore drive !!!

This is more a memo than a real guide. But i share with you what i did.

Boot your VM on a LIVE unbuntu ISO (tested with lubuntu-16.04.3-desktop-amd64.iso )
And open a terminal Console

Current partition from the VM :
/dev/sda1: / partition, ext4;
/dev/sda2: swap;
/dev/sda3: /var partition, ext4

To work in superuser :

Code: Select all

sudo su -


Some check :

Code: Select all

df -h
cat /etc/fstab
cat /etc/mtab
fdisk -l
mount


Enable linux softraid :

Code: Select all

apt-get udpate
apt-get install mdadm
check mdstat is running :
cat /proc/mdstat


clone sda partitions table to sdb :

Code: Select all

sfdisk -d /dev/sda| sfdisk /dev/sdb


Configure sdb partitions 1 and 3 as raid member type

Code: Select all

fdisk /dev/sdb
t
1
fd
t
3
fd
w


clean previous raid (if clean you should get an error, it's normal) :

Code: Select all

mdadm --zero-superblock /dev/sdb1
mdadm --zero-superblock /dev/sdb3


Create the raid with sdb only :

Code: Select all

mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1
mdadm --create /dev/md1 --level=1 --raid-disks=2 missing /dev/sdb3


Check raid status :

Code: Select all

cat /proc/mdstat


Code: Select all

mkfs.ext4 /dev/md0
mkfs.ext4 /dev/md1
mkswap /dev/sdb2


Code: Select all

mkdir /mnt/md0
mkdir /mnt/md1
mount /dev/md0 /mnt/md0
mount /dev/md1 /mnt/md1


Code: Select all

mkdir /mnt/sda1
mkdir /mnt/sda3
mount /dev/sda1 /mnt/sda1
mount /dev/sda3 /mnt/sda3


Code: Select all

cp /mnt/sda1/etc/mdadm/mdadm.conf /mnt/sda1/etc/mdadm/mdadm.conf_orig
mdadm --examine --scan >> /mnt/sda1/etc/mdadm/mdadm.conf


check result

Code: Select all

cat /mnt/sda1/etc/mdadm/mdadm.conf


Note UUID from sdb2 part

Code: Select all

blkid


In /mnt/sda1/etc/fstab, replace UUID FROM "/" and "/var" with "/dev/md0" and "/dev/md1" respectively
It should looks like this :

Code: Select all

...
/dev/md0        /       ext4    rw,noatime,errors=remount-ro    0       1
/dev/md1        /var    ext4    rw,noatime      0       2
...


Duplicate Data from drive sda to drive md. !!! be sure to be in right folder and well type all next four command lines !!! :

Code: Select all

cd /mnt/sda1
cp -dpRx . /mnt/md0
cd /mnt/sda3
cp -dpRx . /mnt/md1

It may take some times to complete.

Code: Select all

umount /mnt/sda1
umount /mnt/sda3


Code: Select all

fdisk /dev/sda
t
1
fd
t
3
fd
w


Code: Select all

partprobe


Add sda to raid drives :

Code: Select all

mdadm --add /dev/md0 /dev/sda1
mdadm --add /dev/md1 /dev/sda3


Survey raid reconstruction upon completion :

Code: Select all

watch cat /proc/mdstat

Check raid grapp status :

Code: Select all

mdadm --detail /dev/mdX


When raid reconstruction is finished :

Code: Select all

umount /mnt/md0
umount /mnt/md1


GRUB
Now it's time to make grub working on newly created raid :

Code: Select all

mount /dev/md0 /mnt
mount /dev/md1 /mnt/var
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
chroot /mnt

CTRL-C to abort mailcleaner configuration

Code: Select all

update-initramfs -u


Install Grub on the two disk

Code: Select all

grub-install /dev/sda
grub-install /dev/sdb
update-grub


Exit chroot and reboot

Code: Select all

exit
reboot


Now boot on your fresh mailcleaner with raid enabled :
default login : root
default password : MCPassw0rd
CTRL-C to abort mailcleaner configuration

Updating mailcleaner before first configuration attempt :

Code: Select all

/usr/mailcleaner/bin/resync_db.sh
apt update && apt upgrade
aptitude install -y open-vm-tools
reboot

CTRL-C to abort mailcleaner configuration

Code: Select all

cd && git clone https://github.com/MailCleaner/Updater4MCBeta.git && cd Updater4MCBeta && ./updater4mcbeta.sh
reboot

CTRL-C to abort mailcleaner configuration

Code: Select all

/usr/mailcleaner/bin/resync_db.sh
echo 'show slave status\G' |/usr/mailcleaner/bin/mc_mysql -s mc_config


If all seems OK start configuration :

Code: Select all

/usr/mailcleaner/scripts/installer/installer.pl
Regards,
Yannick

Return to “Installation”

Who is online

Users browsing this forum: No registered users and 1 guest