February 24, 2008 by sj
My hosting company (bluehost.com) updates their system software now and then without any e-mail notifications to their users. Unfortunately, if you host a Ruby on Rails application (in my case sharepdf.com) each time they upgrade Ruby on Rails, there is a good chance that something will break. Recently, they upgraded to the latest version of Rails (2.0.2) and needless to say, my Rails application stopped working. It turns out that the latest version of Rails has changed the default sessions store from a file store to a cookie store. The problem is that if you stored anything other than a simple data in your session, then to get your application to work, you have to spend a few days porting your application. The fact that Rails upgrade is not backwardly compatible is really annoying. But that is a separate issue.
So what is the easiest way to port your file backed sessions application to Rails 2? The answer is to use the database for your sessions. But keep in mind that Rails 2 no longer uses MySQL as its default database. Here is how I ported my sharepdf.com application to Rails 2.0.2:
- Create a brand new rails application using the command
rails -d mysql appname
- Edit environment.rb file and explicity state that you wish to use database for sessions: simply uncomment this line:
config.action_controller.session_store = :active_record_store.
- Use the command
rake db:sessions:create to create the database definition for the sessions.
- Use the command
rake db:migrate to actually create the database tables (I’m assuming that you have updated the database.yml with correct user name and password and have create the database in MySQL). The rake command will then create the sessions database table.
- Copy your controllers, models, views, … from the your current Rails application to this one.
- You should be good to go!
Posted in Programming, Ruby on Rails | 2 Comments »
February 19, 2008 by sj
By far the easiest way to create a Xen virtual machine is to use the Red Hat Virtual Machine Manager application. But before you can create any VMs you must disable SELinux. To fully disable SELinux, edit /etc/selinux/config file and set SELINUX to disabled. After you have set up your VMs you can re-enable SELinux. Now make sure that you’ve actually installed the Virtual Machine Manager. Run the yum install virt-manager command. After you’ve disabled SELinux and installed the Virtual Machine Manager, you’re ready to install your first Xen VM within a few minutes. Here is a screen-cast for creating a Fedora based VM.
Posted in Xen | 1 Comment »
February 16, 2008 by sj
After you’ve managed to configure GRUB to boot with Xen on domain 0, and you actually reboot your system, you’ll see a bunch of Xen log lines zip by before you’ll see the Fedora startup process. The Xen master command xm dmesg will list the Xen hypervisor boot process. Here are a few lines from the Xen boot log.
# xm dmesg
__ __ _____ _ ___ _____
\ \/ /___ _ __ |___ / / | / _ \ _ __ __|___ |
\ // _ \ 47_ \ |_ \ | || | | |__| 47__/ __| / /
/ \ __/ | | | ___) || || |_| |__| | | (__ / /
/_/\_\___|_| |_| |____(_)_(_)___/ |_| \___/_/
http://www.cl.cam.ac.uk/netos/xen
University of Cambridge Computer Laboratory
Xen version 3.1.0-rc7 (mockbuild@(none)) (gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)) Tue Feb 12 13:01:02 EST 2008
Latest ChangeSet: unavailable
(XEN) Command line: /xen.gz-2.6.21-2957.fc8
(XEN) 0000000000000000 - 000000000009f000 (usable)
(XEN) 000000000009f800 - 00000000000a0000 (reserved)
(XEN) 00000000000ca000 - 00000000000cc000 (reserved)
Posted in Xen | No Comments »
February 16, 2008 by sj
To run a guest unmodified (e.g., Windows) on Xen, you’ll need a CPU that supports hardware virtualization (Intel VT or AMD SVM). But how can your CPU supports virtualization or not? On you can boot the system and use the BIOS to see the hardware spec., alternatively if you run Linux, you can take a look at the/proc/cpuinfo file and see if the field vms (for Intel) or vmx (for AMD) is defined as one of the flags.
Posted in Xen | No Comments »
February 16, 2008 by sj
Every once in while I need to log slow queries using the JDBC logging parameters and it always takes me a while to find this information. So here it is (line breaks for readability):
?profileSQL=true&
slowQueryThresholdMillis=100&
autoSlowLog=true&
explainSlowQueries=true&
gatherPrefMetrics=true&
logSlowQueries=true
Simply add the above parameters to your JDBC connection string.
Posted in Java, MySql | No Comments »
February 15, 2008 by sj
Each time you update the Fedora kernel, e.g., by using yum update, the file /boot/grub/grub.conf gets updated to use this kernel. This may result in you being unable to boot with Xen. The solution is to modify the grub.conf file and move the Xen kernel to the top of the file, e.g. tonight when I updated Fedora 8, the new kernel was placed a head of the Xen kernel. So you’ll need to edit this file and put the Xen kernel ahead of the latest Fedora update.
title Fedora (2.6.21-2957.fc8xen)
root (hd0, 0)
...
title Fedora (2.6.23.15-137.fc
root (hd0,0)
…
Posted in Xen | No Comments »
February 15, 2008 by sj
Use the Xen master command (xm) with the create option to create a domain on which you’ll run a new instance of your virtual operating system (aka guest OS). First, however, you’ll need to create a domain configuration file: simply clone and edit of the Xen canned config files in /etc/xen folder, e.g., xmexample1 or xmexample2.
xm create -c mydomainconfigfile
After you’ve created the domain, you can run xm list to check that it has been started properly (if there is an issue, you’ll see it on the terminal from which you started the xm create command)
Posted in Xen | No Comments »
February 10, 2008 by sj
Xen is a virtualization system originally developed by the University of Cambridge and is now an open source project with contributions from IBM, HP, Intel, RedHat and XenSource (Citrix). You can install Xen 3 on Fedora and thus run multiple operating systems on the same machine. The best documentation that I’ve found on how to get going is the chapter two of a book on Xen by Prabhakar Chaganti.
yum intall kernel-xen xenUsing yum will be a lot easier than downloading the RPMs and then trying to make it work. I tried to get the latest experimental RPM version Xen 3.2 to work, and I gave up and used yum instead which installs the latest stable version 3.1.2.
- Edit
/boot/grub/grub.conf and set the default kernel to 0 instead 1 (0 is for Xen and 1 is for Fedora kernel)
- After a reboot, you’ll be using the Xen kernel (
uname -rm will confirm that you’re running with Xen) and you should be able to use the xen tools, e.g., xm list
Posted in Xen | 2 Comments »
January 28, 2008 by sj
When you start an ActiveMQ broker, it creates two “data” folders in its home directory called activemq-data and data. The former is used for temporary storage and the data folder is where it keeps its log — activemq.log — file.
Posted in ActiveMQ | No Comments »
January 26, 2008 by sj
The slave ActiveMQ broker in a JDBC Master/Slave set up requires that the lock table be of the type InnoDB. MyISAM table can lead to real problems including effectively brining your database down where the only way out would be to kill the slave or reboot your database. For a description of the bug, see here. Basically, you must ensure that the default table creation for your mysql is set to InnoDB, or after you start ActiveMQ, alter its tables in the database (your other options is to modify the ActiveMQ org.apache.activemq.store.jdbc.Statements class and rebuild ActiveMQ).
By default MySQL will create MyISAM based tables. You can alter a table type so that its storage engine is set to InnoDB. For ActiveMQ, you’ll need to alter the three tables that it creates:
ALTER TABLE ACTIVEMQ_LOCK ENGINE = InnoDB;
ALTER TABLE ACTIVEMQ_ACKS ENGINE = InnoDB;
ALTER TABLE ACTIVEMQ_MSGS ENGINE = InnoDB;
Posted in ActiveMQ | No Comments »