Adding a new disk
Before doing this in production, make sure you practice this on a non-production system!
There are at least 3 different ways to do this:
Method 1: LVM (Logical Volume Management)
Method 2: Mount a separate drive to /nsm
This can be done in the Ubuntu installer, or after installation is
complete. If doing this after running Setup, then you’ll need to copy
the existing data in /nsm to the new drive using something like
this:
Comment out the cron job in /etc/cron.d/nsm-watchdog
Restart cron
sudo service cron restartStop all services
sudo service nsm stopsudo service syslog-ng stopsudo service apache2 stopsudo service mysql stopCheck for any ELSA perl processes which may need to be killed manually
ps aux |grep perlDetermine your new drive’s path
sudo fdisk -lPartition the new drive using fdisk or parted
Format the new partition using mkfs
Mount the new drive to a temporary location in the filesystem
sudo mount /dev/sdb2 /mntCopy the existing data from
/nsmto the temporary locationsudo cp -av /nsm/* /mnt/Unmount the new drive from the temporary location
sudo umount /mntRename the existing
/nsmsudo mv /nsm /nsm-backupUpdate
/etc/fstabto mount the new drive to/nsmsudo vi /etc/fstab(You can use blkid to find your drive’s UUID to write in /etc/fstab)sudo blkid /dev/sdb2Re-create nsm directory after it was renamed
mkdir /nsmMount the new
/nsmsudo mount /nsmStart all services
sudo service mysql startsudo service apache2 startsudo service syslog-ng startsudo service nsm startUncomment the cron job in /etc/cron.d/nsm-watchdog
Restart cron
sudo service cron restartTest and verify that everything works
Reboot
sudo rebootTest and verify that everything works
Method 3: Make /nsm a symlink to the new logging location
If you do this, you’ll need to do something like the following to avoid AppArmor issues:
sudo service nsm stop/nsm to new mount point:sudo cp -av /nsm/* /mnt/nsm/nsm:sudo mv /nsm /nsm-backup/nsm a symlink to the new logging location:sudo ln -s /mnt/nsm /nsm/etc/apparmor.d/local/:cd /etc/apparmor.d/local/usr.sbin.mysqld, copy the /nsm line(s), and change
/nsm to the new location:sudo vi usr.sbin.mysqldusr.sbin.tcpdump, copy the /nsm line(s), and change
/nsm to the new location:sudo vi usr.sbin.tcpdumpsudo service apparmor restartsudo service nsm startMoving the MySQL Databases
Synopsis:
In this article I’m going to show how you can move the MySQL databases
containing all of your important alert and event data to another place.
I will be moving the databases to a large external drive I have mounted
as /nsm, though, any other location will do.
Procedure:
/var/lib/mysql. We will need
to move this foldersudo service nsm stopsudo service mysql stopsudo service sphinxsearch stoplsof on the nsm mount point to list any processes that have
open file descriptors. Kill everything,lsof /nsmcp or rsyncsudo cp -rp /var/lib/mysql /nsmsudo rsync -avpr var/lib/mysql /nsmsudo mv /var/lib/mysql /var/lib/mysql.bak/var/lib/mysql to the new
location:sudo ln -s /nsm/mysql /var/lib/mysqlsudo service apparmor stop/etc/apparmor.d/usr.sbin.mysqld to reflect the following
patch which adds the new location:sudo vim /etc/apparmor.d/usr.sbin.mysqld--- a/apparmor.d/usr.sbin.mysqld
+++ b/apparmor.d/usr.sbin.mysqld
@@ -19,8 +19,8 @@
/etc/hosts.allow r,
/etc/hosts.deny r,
+ /nsm/mysql/ r,
+ /nsm/mysql/** rwk,
+ /nsm/elsa/data/mysql/ r,
+ /nsm/elsa/data/mysql/** rwk,
/etc/mysql/*.pem r,
/etc/mysql/conf.d/ r,
/etc/mysql/conf.d/* r,
sudo service apparmor startsudo service mysql startsudo service sphinxsearch startsudo service nsm start