Monthly Archives: November 2007

Notes / MySQL Transactions

Why should you not use your notepad as a coaster? This is why:

Notes
The notes did say this, before my lovely hot black coffee destroyed them:

“begin” == Start transaction
“commit” == End transaction, saving all changes
“rollback” == Undo all changes that you’ve made in the transaction

What are they? In mySQL 5, with a table storage type of “innodb” you can use transactions. This means, that you can make a set of changes together, like recording the removal of a credit, and the adding of an advert to a website, at one instance, even if it’s multiple mysql transactions within one connection.

You do that, by sending the command (literally “BEGIN;” or “begin;”) to start a transaction, run all the queries you need to run, and then run the commit if you want the all the changes to take, or rollback if you don’t. If any one of the sql queries fails after you’ve made a begin, and it shouldn’t have, you can rollback *all* the changes you’ve made to the database. Obviously, this needs one mySQL connection, but if you’re using more than one each run of the program you’re using, I’d be very surprised.

Xen Gutsy Links

A post full of links and unsorted info about using Xen on Ubuntu Gutsy Gibbon, so that I don’t forget. (This lot has taken ~2 days to collect…) May make a full howto sometime… probably not though, as my boss knows this stuff better than I. Xen is pretty cool though…

https://help.ubuntu.com/community/Xen (useless for gutsy…)

The Xen console doesn’t work (xm console <domU>), network works once, and then never again… Going to paste this here as its in a pastebin, not sure when it will expire… (Have tweaked slightly, snipped a couple of things out, added couple of things in)
http://rafb.net/p/49Ku5e10.html

>> OK, I have made a little progress on this.  I mounted my VM image on a
>> loopback and chroot'd to it.  I opened /etc/init.d/hwclock.sh
>> and /etc/init.d/hwclockfirst.sh and added the following to the top of each
>> file:
>>
>>   exit 0

ALSO SEE: http://lists.cvsrepository.org/xen-tools/Jul07/0332.html

sudo xm create -c </path/to/config/file>

-----------------

# Ever-increasing network device names?

# Just disable the correspondent udev rules by deleting/renaming your
/etc/udev/rules.d/<NUMBER>persistant-net.rules. (number was 70 for us...)

guest# mv /etc/udev/rules.d/{,.}z25_persistent-net.rules

# And then make sure your vif (in your instance config file) contains your mac
# address like:
vif = ['ip=192.168.0.45,mac=<random valid mac addy>']

Just be sure to stop the instance (domU), and then restart (re-create) it again when needs be…

Also, when in the Xen console, try hitting enter before using the escape sequence (CTL +]) if it’s not working. Sometimes it enters into the console after the “login:” prompt has been printed, and doesn’t seem to pick up that its just had a new connection…
The ALSO SEE link: http://lists.cvsrepository.org/xen-tools/Jul07/0332.html

Using Serial console & xen console (serial console conflicts with xen console):
http://phaq.phunsites.net/2007/06/30/xen-console-grabbded-devttys0

/boot/grub/menu.lst stuff, to enable us to use a serial console as well as xen:

serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
terminal --timeout=2 serial console

Goes in the top of your menu.lst, outside the automagic sections…

## additional options to use with the default boot option, but not with the
## alternatives (These options are not used with the Xen Kernel!)
# defoptions=quiet splash console=ttyS0,115200n8

For the default kernel, (NOT the xen kernel).
Goes inside the AUTOMAGIC section of your menu.lst, adding to the options already there.

## Xen Linux kernel options to use with the default Xen boot option
# xenkopt=console=tty0 console=ttyS0,115200n8 xencons=ttyS9

Note the xencons=ttyS9. Use a serial port (ttyS<No.>) that doesn’t already exist.

Your Xen kernel definition should look something like this, after you’ve run “update-grub”:

title           Xen 3.1 / Ubuntu 7.10, kernel 2.6.22-14-xen
root            (hd0,0)
kernel          /xen-3.1.gz
module          /vmlinuz-2.6.22-14-xen root=/dev/mapper/volume-root ro console=tty0 console=ttyS0,115200n8 xencons=ttyS9
module          /initrd.img-2.6.22-14-xen
quiet

The guys on irc ##xen @ freenode are really helpful…