Disk read and write measuring and monitoring

The tools i need are in
apt-get install sysstat

this will give me the command

iostat -x 5

Where the 5 means tell mne about disk usage for all partitions and disks every 5 seconds…

When you stop the command, running it again will display data since the last run, there is much more that has to do with IOSTAT that i will come to in a bit, this one here is simply the basic command and usage for my referance

IO stat will display something like the following lines for the second disk that has 4 partitions, the first line is the totals

sdb 0.20 0.20 33.20 16.00 728.00 1392.00 43.09 3.87 41.01 3.04 14.96
sdb1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sdb2 0.20 0.00 7.00 0.00 502.40 0.00 71.77 0.06 8.46 7.54 5.28
sdb3 0.00 0.20 25.60 15.40 204.80 1384.00 38.75 3.79 47.41 2.85 11.68

Twinmos 4GB 10600 not compatible with GA-x58A-UD3R

So, when i got the TwinMOS rams, they were $141 each, making the total $846 for 24GBs of system ram, Sometimes the computer would work with no “Apparent” errors, other times, i would have to switch rams and reboot a bunch of times till i get a stable run !

The PC is a linux machine that runs MySQL, the result, i was always worried that i would have to update the database files because when i do, i usually strike that error and loose a day of work.

So the problem shows it’s ugly head again, but this time i am very fed up, i ran memory tests and the tests report errors, i move the TwinMOS ram’s to another computer, and they work like a dream.

So i went out and got some Kingstone rams (KVR1333D3N9/4G) and up to now no errors

The files i used to copy and get back MD5 sums for, now i copy and they arrive at destination with no errors in the copied files, everything seems to be fine up to now

So, the Ocean Blue and Piano Black sticks (With heatsinks) are no longer needed, i should now see if someone would take them off my back (Since i tested and they are working fine with all other motherboads)

disable apparmor

I usually use Debian, Lenny at the minute, but for a newer kernel and a newer out of the box MySQL Server, i downloaded the Ubuntu 10.10.

Since those are going to be MySQL machines, where DBs span multiple disks, the first thing i want to do is disable apparmor

You can disable the directory restricting software by issuing

/etc/init.d/apparmor stop
update-rc.d -f apparmor remove
aptitude remove apparmor apparmor-utils

Sendmail and Mail from PHP

While working on signing PHPs outgoing mail with a DKIM signature that Yahoo now considers a necessity if you want your email to arrive at the inbox, i came across a problem.

Whenever i add the fifth parameter to the mail function, -f mail@domain.com to change the default envelope sender, PHP mail returns a false meaning mail was not sent

After trying to change the sendmail line in php.ini to remove the -i then removed the -t then removed both, then checked the lists such as /etc/mail/trusted-users and so forth but with no change, i wrote a wrapper around sendmail to log what is coming in and what is going out, and to my surprise, it is not sendmail that says NAY, nothing is arriving at the wrapper when the fifth param is added, so it seems the problem is PHP itself and not sendmail

Simply turning off SAFE MODE resolved the issue, and here i am trying to spare you the need to look everywhere when the answer was something i should have checked before i start.

upgrading MySQL on debian lenny with apt-get or aptitude

To clarify things, the version currently on Debian lenny is 5.0.51, this DOES have the 4GB limit mentioned in the previous post, what you need is 5.0.52+ (See previous post)

To get that on debian lenny, You do not need to recompile or compile anything

Add the line below to your /etc/apt/sources.list

deb http://backports.debian.org/debian-backports lenny-backports main

apt-get update
apt-get -t lenny-backports install mysql-server-5.1

This should have you running with a key_buffer of any size you wish that your ram permits, and to overcome the 4GB limit on the MyISAM key buffer

Happy Databasing

how to mount a ram hard disk in Linux

In this post, i will show you how to create a very fast, 0 latency hard drive from the extra gigabyte or 2 on your system

1- You need to change the boot options to allow this…

Since i use debian lenny, my boot options look like this in /boot/grub/menu.lst

title        Debian GNU/Linux, kernel 2.6.26-2-686
root        (hd0,1)
kernel        /boot/vmlinuz-2.6.26-2-686 root=/dev/sda2 ro quiet
initrd        /boot/initrd.img-2.6.26-2-686

We need to append ramdisk_size=1572864 if we wanted a 1.5GB RAM drive, make sure you have 1.5GB EXTRA on your system, let’s say you must have a minimum of 2GB for the system to run using the 512MB you are leaving the system with

title        Debian 1.5GB Ramdisk, kernel 2.6.26-2-686
root        (hd0,1)
kernel        /boot/vmlinuz-2.6.26-2-686 root=/dev/sda2 ro quiet ramdisk_size=1572864
initrd        /boot/initrd.img-2.6.26-2-686

You are done for now, if you want to format and use it do this

/sbin/mkfs.ext2 /dev/ram0

Remember that you need to format as ext2 and not ext3, i have seen people format the hard drive as EXT3, why would you ever need Journaling on a RAM disk that is already volatile (Deleted when you reboot)

mkdir /ramdisk
mount /dev/ram0 /ramdisk

You can now get creative and format or load a disk image at boot time, in any case, the RAM is only allocated to the disk when you use it, but you really don’t need to know that to use your new RAM hard disk

NOTE: I chose to explain RAM disk because later on i will show you what advantages we can get from having a block level device, you can surely do this without modifying boot options by simply using tempfs or RAMFS that give you an instant ram disk, but it is not a block level device in that case

Testing Speed

So, you want to see how fast it is, but for that we need a data source that can push this thing to the maximum, the answer is /dev/zero that responds with a stream of zeros, so let us write a 1.3GB file to our new volatile hard disk

dd if=/dev/zero of=/ramdisk/pathtoimage.img bs=1M count=1300

On my computer, this took about 4.54006 seconds.

installing Debian Lenny extra steps

This is how i install Debian lenny at the office on all computers

NOTE: (192.168.2.133) has apt-cacher, my PC 192.168.2.106 has a php script that responds with the caller’s IP

1- Put the Lenny Mini-CD into the computer
2- Follow instructions, when asked about a proxy, the address is http://192.168.2.133:3142/
3-Once done, run

apt-get update

apt-get install ssh openssh-server

4- Finding out our Network IP address, you can simply issue the command

ifconfig

The above will give us the IP address of this pc

5- Now we can go back to the Windows PC and start WinSCP and PUTTY to edit files and do stuff, i use sourceedit as the editor because i want to save any edited file as linux text (Line break is different)

6- connect via putty and WinSCP to the computer so we can edit some files…

7- Fix /etc/apt/sources.list to have the apt-cacher … and comment out the CD

so deb “http://ftp.us.debian.org/debian/ lenny main” becomes “deb http://192.168.2.133:3142/ftp.us.debian.org/debian/ lenny main”

The above lines save internet bandwidth by caching the files on the network

8- Now, we want the PC to request the same IP every time so that we always know how to connect to it.

edit /etc/network/interfaces,

——————————
initially it looks like this
——————————

auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp

——————————-
But we want it to look like this
——————————–

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
address 192.168.2.112
netmask 255.255.255.0
gateway 192.168.2.1

auto eth0

———————————–

—-DONE—

And now we are probably set to connect to this PC every time (Static Network IP), and to use aptitude without waiting for ages to download the packages from the internet

MySQL Windows VS MySQL on Linux

Comming across Robin Schumacher’s “MySQL on Windows? Absolutely!” i have some stuff to say

First, I absolutly LOVE windows on my Desktop, and i LOVE Linux on my servers, and i have nothing against windows servers or Linux Desktops, i like Operating systems that get the Job done faster and with least effort, so what suits a job suits me, having never used a mac, i would jump to a mac if they tell me it can help you develop application X faster, why not, but the article here http://dev.mysql.com/tech-resources/articles/mysql_on_windows.html does not seem to make sense to me. Here is why

In the comparison of number of downloads, it clearly reads that windows has 600K downloads VS linux that has 200K downloads, but are you serious ?

On Linux, MySQL is hardly if ever downloaded from mysql.com , while on Windows it is always downloaded from MySQL.COM and therefore i beg an explanation on why you say this statistic tells anything, Also, most developers are like me, they use the Windows edition for development on there development PCs, and then deploy the actual application on a Linux server.

For example, on a debian system i would simply issue

apt-get install mysql-client mysql-server

this will get MySQL binaries from Debian, not from MySQL, and therefore making the statistic not available to you.

Then the article talks about how insignificant the differences between the Linux and Windows edition is, to tell you the truth, this is not the case at least for me, here are SOME examples

Most of my applications can not make good use of RAID because RAID does not help with disk seek time (And therefore latency), My answer to this is usually separating tables to more than 1 hard disk , and although having databases moved to other hard drives is supported in windows by creating a text file, moving individual tables on windows is not, On linux, i simply create a symbolic link to the MYD file, and one to the MYI file, i can even split a single table to 2 hard drives with the indexes on 1 drive and the actual data on the other.

Clustering anyone ??

For a longer list check out http://dev.mysql.com/doc/refman/5.0/en/windows-vs-unix.html , this is certainly is inferior to the Linux counterpart for something like a shared hosting environment (See number of open files and connection timeouts etc..)

Now to add more to that, Linux is a free OS, you install and upgrade it for free, and MySQL is also free, if your business uses many many MySQL servers, your savings on Windows Server licenses can be significant.

The bottom line is, when a company like Oracle (Since it has acquired SUN) gets hold of an open source database engine, you can rest assured objectivity will still be there only when it supports the paying product.

Thanks for listening.