Debian: MySQL stops working after upgrade from Lenny to Squeeze

MySQL installation gets upgraded during your OS upgrade as well… therefore a few different things could cause the server to not start. I’d start troubleshooting this way:

Incompatible configuration: simply backup your /etc/mysql/my.cnf and copy a new one from /etc/mysql/my.cnf.dpkg-dist and start the server.
cp /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
cp /etc/mysql/my.cnf.dpkg-dist /etc/mysql/my.cnf
/etc/init.d/mysql restart

 

Missing loopback interface: MySQL binds to your loopback interface by default and would not start if it is missing. Check yours and add if necessary:
nano /etc/network/interfaces
and add “lo” to lines with “auto”. If your interface line is “auto eth0” change it to read “auto lo eth0”. Also add “iface lo inet loopback” to the file if it is missing. Save config and restart the server.

 

2nd last resort: install MySQL: Install it again, see what happens.
aptitude install mysql-server-5.1
 

Last resort: completely purge the install and install again:
aptitude remove --purge mysql-server
aptitude install mysql-server

and if none of the above worked keep googling… good luck!

Debian: open-iscsi, use iSCSI initiator to connect to a SAN

It is actually quite easy as long as your kernel is 2.6.16 or newer. Debian supports fibre channel out of the box, and for iSCSI you only need to install the open-iscsi package (you can easily taylor this to your distro):
aptitude install open-iscsi
Once the package is installed restart the initiator:
/etc/init.d/open-iscsi restart
To find out the indentifier name take a look at initiatorname.iscsi file:
cat /etc/iscsi/initiatorname.iscsi
You can find the initiator identifier towards the bottom of the file… mine is InitiatorName=iqn.1993-08.org.debian:01:61ddbbf82a70. Once you found the name you should be able to discover the target with the following command (my LeftHandNetworks iSCSI SAN IP is 192.168.1.70):
iscsiadm -m discovery -t sendtargets -p 192.168.1.70
Make a note of the record ID (mine is iqn.2003-10.com.lefthandnetworks:sancrp:3139:debian) and connect to it using the following command:
iscsiadm --mode node --targetname iqn.2003-10.com.lefthandnetworks:sancrp:3139:debian --portal 192.168.1.70:3260 --login
Once you initiated the command your iSCSI target will become visible to the OS as an SCSI disk (/dev/sda). You can now partition, format and then mount the LUN just like any other storage device. Add the target to your fstab and it should be auto-mounted everytime your system boots.
nano /etc/fstab
and add:
/dev/sda1 /iscsi ext3 _netdev 0 0
To have the LUN mounted to /iscsi directory. It didn’t work that well in my case… fstab mounts devices early during startup and before iscsi init, and OS couldn’t find the target to mount. I ended up scripting the initiator and mount… created a file “initiscsi” in /etc/init.d directory and added the following lines:
iscsiadm --mode node --targetname iqn.2003-10.com.lefthandnetworks:sancrp:3139:debian --portal 192.168.1.70:3260 --login
sleep 5
mount -t ext3 /dev/sda1 /iscsi

I’m sure there is a proper way to have the session initiated before the mount, but I didn’t care enough to figure it out. Init and mount script will do just fine in my case since my LUN is just a storage device.

That sleep command is to make sure the LUN is visible to the OS before it’s mounted. I added the script to my startup sequence after making it executable:
chmod +x initiscsi
update-rc.d initiscsi defaults

This is of course for Debian startup.

If you are using CHAP you will need to edit your iscsid.conf file:
nano /etc/iscsi/iscsid.conf
and update it with correct authentication info:
node.startup = automatic
node.session.auth.username = username
node.session.auth.password = password
discovery.sendtargets.auth.username = username
discovery.sendtargets.auth.password = password

Save and close the file, then initiate discovery.

Added by Tim Rogers (thanks!):

If you wish to do this properly, you must change the boot order so that the disks are available when the iscsiadm daemon starts. To do this
mv /etc/rcS.d/S25open-iscsi /etc/rcS.d/S88open-iscsi
Check the etc/rcsS.d file first to check when open-iscsi is initiated. May have to change the command to relate to your particular setup. Then there is no need to set up the initiscsi file as described above if this is done.