Apr/090
GRUB Error 21 Dual Boot Raid
I was installing Ubuntu to dual boot onto a newly added drive on my workstation that already has Windows XP. After the installation, GRUB gives me error 21. I looked through all the forums and help and tried everything from reinstalling GRUB to modifying menu.lst. Nothing worked. Then I figured out what the problem was. My system before adding the new drive had three drives; one with XP OS and two in a Raid 1 array for data. The issue was the Raid 1 array. With the new drive I added for Ubuntu, the computer had four drives. During installation, Ubuntu saw four drives and when installing GRUB, it pointed Ubuntu to boot on hd3,0. However, when GRUB tried to load, the BIOS was showing only three drives and hd3 was non-existent resulting in error 21.
Then I decided to move my SATA cables around so the location of the Ubuntu install does not change no matter if we saw the Raid 1 as one drive or two. So I kept XP on hd0, moved Ubuntu to hd1, and then having the Raid 1 drives to follow with hd2 and hd3. At this point, I reinstalled GRUB and tried to boot up again with the Raid 1 configured in the BIOS. Now I get GRUB error 17! What the heck is that? I found that if I got rid of Raid on the BIOS, error 17 goes away and GRUB comes up without a problem.
I got tired of trying to debug this and decided to just go all Ubuntu and just VM XP for the few things I still need to do on Windows.
Dec/083
Update Delayed on Mysql and PHP
Wouldn’t it be nice if we could use UPDATE DELAYED in mysql just like we do use INSERT DELAYED? Unfortunately, the work around mysql created for this is to insert a record into the events table in order to separate UPDATE statement into another thread. There is a large overhead to inserting to then execute an update.
If you are using PHP with mysql, there is another work around. PHP has a function called, register_shutdown_function, which will execute a function during the shutdown of processing a script file. So if we add an UPDATE LOW_PRIORITY sql statement wrapped in a function that is passed to register_shutdown_function, we can allow the user to receive the page without delay while the UPDATE statement waits until all locks on the table has been release before proceeding.
function update_delayed()
{
$sql = "UPDATE LOW_PRIORITY table_name SET col1 = 'something'";
mysql_query($sql, $conn);
}
register_shutdown_function('update_delayed');
I wonder if there are even better ways to handle this problem.
Nov/081
Where to install Eclipse on Ubuntu
If you’re like me, accustomed to installing most packages via Ubuntu’s package manager, you might be a bit confused as to where to install Eclipse since it should be in a place thats accessible by every user on your system. Sure you can install it in your user home directory but that wouldn’t be very tidy.
I extracted part of these instructions from: http://flurdy.com/docs/eclipse/install.html
These instructions assume you’ve downloaded and extracted the Eclipse tarball:
sudo mv eclipse /opt/eclipse cd /opt sudo chown -R root:root eclipse
sudo mv eclipse /opt/eclipse cd /opt sudo chown -R root:root eclipse
sudo chmod -R +r eclipse
sudo chmod +x `sudo find eclipse -type d`Then create an eclipse executable in your path
sudo touch /usr/bin/eclipse
sudo chmod 755 /usr/bin/eclipsesudoedit /usr/bin/eclipse
With these contents:
#!/bin/sh
export ECLIPSE_HOME=”/opt/eclipse”
$ECLIPSE_HOME/eclipse $*
Now you can execute Eclipse from anywhere in your bash shell. Check out the original article for generating a desktop icon. In the tarball I downloaded, it didn’t come with the icon.xpm that contains the Eclipse icon but no worries for me.
The take-home lesson here is that /opt is meant as a place to install application software packages. The topic is Filesystem Heirarchy Standard (FHS) .. these folks seem to be the standard authority on it:
http://www.pathname.com/fhs/pub/fhs-2.3.html#OPTADDONAPPLICATIONSOFTWAREPACKAGES
However it’s not to say that this standard is the most progressive one we have today. I found GoboLinux to be particularly interesting: http://en.wikipedia.org/wiki/GoboLinux#The_GoboLinux_hierarchy
Nov/0812
Getting Android emulator working with Google Maps API Key
I was trying to get an Android app that uses Google Maps API to display a MapView running on the emulator. It took quite a bit of hair pulling to finally get it working.
First, I tried using a self-signed keystore instead of the the debug.keystore provided through the Android SDK. I created my keystore using keytool -genkey from JDK. Then I switch the app from using the default, debug.keystore, to my-new-self-signed.keystore. Using keytool -list, I got the MD5 of the certificate that is needed to obtain a Google Map API key. Then the API key was put into the MapView android:apikey attribute. When I brought up the app in the emulator, I got a blank map grid screen. The reason I wanted to use the self-signed keystore instead of the debug keystore is so I don’t have to obtain a new Map API key and change the code to reflect this upon releasing the app.
So, I decided to go with the debug.keystore and that worked fine. Here is what I had to do.
-
$ keytool -list -alias androiddebugkey -keystore <path_to_debug_keystore>.keystore -storepass android -keypass android
- Copy that MD5 and goto http://code.google.com/android/maps-api-signup.html
- Signup for an API key
- In my xml file that has the views for the activity, add
<com.google.android.maps.MapView android:layout_width="fill_parent" android:layout_height="fill_parent" android:enabled="true" android:clickable="true" android:apiKey="example_Maps_ApiKey_String" />
- In the Manifest.xml file, add the permissions needed
<uses-permission android:name=”android.permission.INTERNET”></uses-permission>
<uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION”></uses-permission> - In the Manifest.xml file, add the maps library
<uses-library android:name=”com.google.android.maps” />
within the application tag - The entire Manifest.xml looks like this
<?xml version=”1.0″ encoding=”utf-8″?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android”
package=”com.informationideas.mapapp”
android:versionCode=”1″
android:versionName=”1.0.0″>
<uses-permission android:name=”android.permission.INTERNET”></uses-permission>
<uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION”></uses-permission>
<application android:icon=”@drawable/icon” android:label=”@string/app_name”>
<uses-library android:name=”com.google.android.maps” />
<activity android:name=”.ShowDesktop”
android:label=”@string/app_name”>
<intent-filter>
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
</application>
</manifest> - The default activity file should look like this
package com.informationideas.mapapp;
import android.os.Bundle;
import com.google.android.maps.MapActivity;public class ShowDesktop extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Now off to building cool things with the map!
Oct/080
G1 Android Phone
I just received my G1 phone in the mail as it is spectacular. The touch screen works very well and the built-in GPS, wi-fi, and 3G network/ functionalities will allow developers build some very exciting new applications for these phones. It also has a compass that is demonstrated using the Street View of Google Maps. When viewing Street View, if you start spinning in one spot the image will rotate according to the direction the back of the phone is facing. It probably has a built-in level also that allows the Street View to pan up to the sky or down to the ground when the phone is moved in those directions.
The Android Market is where users can download application that runs on the phone built by developers (Google and other developers). It currently has about 50 applications from their Android Developer Challenge. On October 27, 2008, they will open up the Android Market to all developers to submit their applications. Currently, all applications in the market must be free of charge, but in the first quarter 2009 they will allow applications that charge a fee. It is interesting that Google has made the Android Market totally open and policed/ ranked by users. They will not require approval for any application and anyone can put applications on the market. That is very different form Apple’s iPhone App Store where they are gatekeepers to every application sold to iPhone users by using a review process. We will see how this pans out, but so far it seems promising.
Well, I’m going to start building Android Apps so that’s it for now.
May/080
Mysql on 32bit processor vs 64bit processor
Here is the continuation of the experiment done previously on Mysql on Windows vs Linux. After doing more analysis and observation, it appeared that the difference in speed for the benchmark tests were not related to Windows and Linux but were related to the processor. The previous test just happened to have AMD 64s on the Linux machines and Intel Xeon 32bits on Windows. We hypothesized that the increased throughput of the 64bit processors resulted in about half the time required to return the same query run on a 32bit machine.
So we decided to test the same query again on a Windows machine with an AMD 64 X2. This time the result for the query took 7.35 second, almost the same as the other AMD 64s running Linux.
One more test to run the query on a Windows Intel 64bit chip machine would better solidify our hypothesis.
May/080
Mysql server has gone away
I have a spider crawling the web written in PHP running constantly to insert and update data in a Mysql database. Today, it kept stopping on a records with the error message, “Mysql server has gone away”. It certainly did not time out as just starting the process again would result in this message immediately. The script did not close out the connection to the DB as it had worked just fine for over a year.
Finally, I found that the problem was max_allowed_packet setting in my.cnf was too small. It was set to 2MB and when Mysql receives a query larger than that, it assumes that something must have gone wrong and closes the connection. I increased that parameter to 4MB and everything is working fine now.
May/083
Mysql on Windows vs Linux
I was working on optimizing a Mysql database today and accidentally stumbled upon a benchmarking exercise. The original Mysql database is hosted on a Windows Server 2003. I develop on a Mysql database server running on Ubuntu Linux. The Linux server ran the same query twice as fast as the Windows server without using caching or anything. I know that Linux does I/O caching on its own as well so I even tried running the query after a fresh reboot to rule out that factor. Then I got help from a colleague and started tweaking with the my.cnf/my.ini to make sure they were the same and each time, the results came back about the same. Mysql on Windows was consistently slower than Mysql on Linux.
Then we decided to load the database onto other servers for more data points on this Mysql performance test. We ran the same query returning 429 rows of data with 13 table joins and a couple of sub-queries. All queries were run on the command line client on the servers themselves to avoid network lag. All servers are running Mysql 5.0.x.
Results
1. Ubuntu Linux: 0.70 seconds
2. CentOS: 0.78 seconds
3. Windows 2003 Server: 1.40 seconds
4. Windows 2003 Server: 1.42 seconds
Server hardware
1. Ubuntu Linux
AMD ATHLON 64 X2 4200+
2GB DDR400
200GB 7200RPM SATA/150
2. CentOS
Dual Opteron 240
2GB DDR ECC
120GB 7200RPM SATA/300
3. Windows 2003 Server
Dual Xeon
2GB DDR ECC
7200RPM PATA
4. Windows 2003 Server
2 Dual Xeon (4 CPUs)
8GB DDR ECC
3 73GB 10,000RPM SCSI in RAID 5
A followup to the benchmark that clarifies the cause of the differences
Feb/080
Mysql SQL_NO_CACHE Benchmark Problem
I have been trying to benchmark the sql calls to mysql from an application without success. Even when I set the SELECT statement to SQL_NO_CACHE, the results seemed to be still cached. Apparently, Linux does its own caching of disk reads also. That was giving me incorrect benchmark results if I hit the same data twice.
For those using Linux kernel 2.6.16 or higher, you can clear Linux cache with the following command.
echo 3 > /proc/sys/vm/drop_caches
Unfortunately for me, I am stuck on 2.5.xx and will have to figure out another method.