BIND MySQL DLZ 64 bit Linux compile 

No Comments

When trying to compile the Bind MySQL DLZ driver on a 64-bit Linux server, you need to specify the following environment variables in order to get it to work:

export CPPFLAGS=”-I/usr/lib64/mysql $CPPFLAGS”
export LDFLAGS=”-L/usr/lib64/mysql $LDFLAGS”
export LD_LIBRARY_PATH=”/usr/lib64/mysql”

Happy compiling!

Removing a LVM Volume Group in Linux 

No Comments

What if you created a volume group in LVM and no longer need it? Well, to properly clean everything up follow the steps below.

First, let’s identify the target.  In this case, I made a temporary /u2 partition, that I now no longer need:

# df -h /u2
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup02-LogVol00
148G 88G 53G 63% /u2

Of course, we need to unmount the drive:

# umount /u2

Let’s take a look at the volume we will be removing.  Notice there is a logical volume and a corresponding physical volume:

# vgdisplay /dev/mapper/VolGroup02
— Volume group —
VG Name VolGroup02
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 150.00 GB
PE Size 4.00 MB
Total PE 38399
Alloc PE / Size 38399 / 150.00 GB
Free PE / Size 0 / 0
VG UUID 7tVffs-U3id-Nksb-Yoqk-37Qg-JptR-bJYCy7

Next, we’ll deactivate the logical volume, then remove it:

# lvchange -an /dev/mapper/VolGroup02-LogVol00
# lvremove /dev/mapper/VolGroup02-LogVol00
Logical volume “LogVol00″ successfully removed

If you look at the volume group now, you can see the logical volume has been removed.

# vgdisplay /dev/mapper/VolGroup02
— Volume group —
VG Name VolGroup02
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 150.00 GB
PE Size 4.00 MB
Total PE 38399
Alloc PE / Size 0 / 0
Free PE / Size 38399 / 150.00 GB
VG UUID 7tVffs-U3id-Nksb-Yoqk-37Qg-JptR-bJYCy7

Let’s take a look at the physical volume before changing it:

# pvdisplay /dev/sdc1
— Physical volume —
PV Name /dev/sdc1
VG Name VolGroup02
PV Size 150.00 GB / not usable 2.00 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 38399
Free PE 38399
Allocated PE 0
PV UUID B9zc6s-BvKl-TkWn-YTX9-lsBY-tstd-wQZFY3

Now we will go ahead and remove the volume group from the system, which also clears the physical volume for removal:

# vgremove /dev/mapper/VolGroup02
Volume group “VolGroup02″ successfully removed

You can see that the physical volume is no longer tied to a volume group:

# pvdisplay /dev/sdc1
“/dev/sdc1″ is a new physical volume of “150.00 GB”
— NEW Physical volume —
PV Name /dev/sdc1
VG Name
PV Size 150.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID B9zc6s-BvKl-TkWn-YTX9-lsBY-tstd-wQZFY3

We no longer need this hard drive, so we can now remove it:

# pvremove /dev/sdc1
Labels on physical volume “/dev/sdc1″ successfully wiped

One last item of cleanup, remove the corresponding line in /etc/fstab:

# vi /etc/fstab

Sending mail from command line using Mutt 

1 Comment

I use this to attach reports (pdfs, etc) to emails in my scripts. Small Perl snippet:

system("/usr/bin/mutt -i $file_with_body_content -a $file_to_attach -s "Some Random Report $report_date" $mailto < /dev/null");

And since this has now bitten me twice, make sure that there are no variables with carriage returns at the end. In my case, both times I forgot to chomp($report_date) and could not figure out why the attachments were displaying inline instead of as proper attachments when I received the email.

Useful Networker Commands 

No Comments

For use with EMC (Legato) Networker…

Move everything off of a specific volume onto another pool (Careful, does not take into account possible clones – add /cloneid somehow to the end. I haven’t been able to automate that yet):
# for i in `/usr/sbin/mminfo -q “volume=OLDVOLUME” -r “ssid”`; do /usr/sbin/nsrstage -v -b NEWPOOL -s NETWORKERSERVERNAME -m -S $i; done

Remove everything off of a specific volume (again does not take into account clones):
# for i in `/usr/sbin/mminfo -q “volume=OLDVOLUME” -r “ssid”`; do /usr/sbin/nsrmm -e now -d -v -y -S $i; done

Clone all savesets from the last 24 hours to the “Tape” pool:
# /usr/sbin/nsrclone -S -e now -C 1 -b Tape -y month

Clone all savesets from the last 24 hours from a specific pool to the “Tape” pool and set retention to a month:
# /usr/sbin/nsrclone -S -e now -C 2 -B SOMEPOOL -b Tape -y month

Random Useful Scripts 

No Comments

Convert plain text to passwd crypt:

#!/usr/bin/perl

print "Enter the password you would like to use:  ";
$pass1 = <STDIN>;

if ($pass1) {
	my $salt =
	   join('', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]);
	my $cryptpw = crypt($pass1, $salt);
	print "The encrypted password suitable for passwd is $cryptpwn";
}

Convert base64 encoded to plain text:

#!/usr/bin/perl

use MIME::Base64;

print "Enter the encoded data:  ";
$code = <STDIN>;

if ($code) {
	my $decrypted = decode_base64($code);
	print "The decrypted data is:n"$decrypted"n";
}

Create 10 random passwords:

#!/usr/bin/perl

sub randomPassword {
 my $password;
 my $_rand;

 my $password_length = $_[0];
 if (!$password_length) {
  $password_length = 10;
 }

 my @chars = split(" ",
 "a b c d e f g h i j k l m n o
  A B C D E F G H I J K L M N O
  p q r s t u v w x y z 
  P Q R S T U V W X Y Z 
  0 1 2 3 4 5 6 7 8 9");

 srand;

 for (my $i=0; $i <= $password_length ;$i++) {
  $_rand = int(rand 62);
  $password .= $chars[$_rand];
 }
 return $password;
}

for ($i=0; $i < 10; $i++){
	print randomPassword(8) . "n";
}