Archive | open source RSS for this section

Fix for running MySQL 5.5.8 under MacOS X 10.6.5 (Snow Leopard)

Oracle recently released the latest MySQL 5.5.x versions. Despite of having tones of fixes and supposedly running much faster and (finally) making InnoDB the default storage engine, it is always good to keep up to date with latest releases.

But, as in the past, MaxOS X users always have to battle with getting it run correctly on their platform of choice. With this release it is no difference. This time, we are hit by permission issues and wrong path settings that prohibits MySQL to start at all and also to make it automatically startup during boot time.

Fixing startup

After installing the preference pane, you should be able to simply click the button to start/stop the MySQL server. Point is that “it should”, but it wont. This is due to a wrong path setting in the startup file. In order to make it work you have to edit a file. Jump into your favorites tool (no, it is not iTunes), but the Terminal application and enter:

nano /usr/local/mysql/support-files/mysql.server

(Nano is a editor in your shell, you can also use “vi” or “emacs”, but I guess “nano” is easy to use)

Then hit “ctrl + W” (for search) and enter “basedir=”, then hit Enter”. This will search for the string entered. Once found, change it to:

basedir=/usr/local/mysql

Once changed, hit “ctrl + W” again and search for “mysqld_pid_file_path=$datadir/`hostname`.pid” and change it to:

mysqld_pid_file_path=$datadir/`/bin/hostname`.pid

After these two changes simply press “ctrl + X” and enter “y” and then enter. This will save the changes you just made and will close the editor.

Fixing Startupitem

During reboot you might have seen the error message:

“Insecure Startup Item disabled. /Library/StartupItems/MySQLCOM has not been started because it does not have the proper security settings.”

This is because the StartUpItem has been installed with the improper permission settings. This can simply be solved with the following commands you have to enter in the terminal:

chown -R root:wheel /Library/StartupItems/MySQLCOM

That’s it. After next reboot the MySQL server will startup as expected and you will also be able to start/stop the server from the preference panel.

Fun with Cron

For some of my Ubuntu Servers (10.04) the Cron jobs did not work or only sporadically executed. I’ve asked around, but none of my friends could explain why this is so. This happened on physical as also on virtual servers. Thus I set out today to finally figure out what caused this. To mention it upfront, I did not find the cause of it, but I got my Cron jobs working again. (and learned a lot along the way)

System Crontab and User Crontab

In the past I always set cron jobs in the /etc/crontab file. This is also the way I’ve used cron in the last couple of years. By switching to Ubuntu server 9.x this worked, but somehow since 10.04 they only worked sporadically. As explained, I don’t know why this is so, but moving those cron jobs into the user (in my case the root account) with “crontab -e” they started working again.

The only difference is that one does not need to pass the user the jobs has to run in with the command, since we edit the user crontab file with “crontab -e”, but everyting else works now as expected.

Getting cron to log

Under Ubuntu logging of any cron action is disabled by default. Since, I wanted to see if my jobs are running and execute successfully I had to enable it. Enabling logging of cron is done in the system default files with:

vim /etc/rsyslog.d/50-default.conf

Uncommenting the ‘#’ before the line that says cron and it will enable logging for cron:

cron.* /var/log/cron.log

and save the file. Now simply reload or restart the rsyslog utility with:

service rsyslog restart

Note: In my case, I had to create the file “/var/log/cron.log” manually in order for cron to write the log.

Enable or preventing cron to send eMails

I guess by default, cron will send eMails on errors or completed actions to the user. In my case, I got a lof of eMails with completed actions and more from cron shortly after. Controlling sending of eMails is done by the global variable ” MAILTO=”" “. One can also direct the output to null for disabling sending of emails.

To disable cron from sending for all jobs:

Add MAILTO=”" to the top of cour crontab file.

To disable sending of eMails for individual jobs:

0 1 5 10 * /path/to/script.sh &> /dev/null

Ubuntu 10.10 and grub menu

I just upgraded one my Ubuntu server from 10.04 to 10.10 (works flawlessly) and realized that I was prompted with the grub menu during a reboot. Since this is a cloud server and it being managed over SSH, I surely wanted that Grub automatically selects the latest kernel and does not wait for an input.

To be honest, I don’t know why this changed (well the only grief with the move from 10.04 to 10.10). Luckily, this is a easy task. All there is to do is to change a value in one of the grub conf files. Edit the file “/etc/grub.d/00_header” and search for “recordfail”. This should bring you to the line;

if [ \${recordfail} = 1 ]; then
  set timeout=-1
else
  set timeout=${GRUB_TIMEOUT}
fi

Now, all there is to change is the value “-1″. The value 0 will bypass the menu and any greater value is the time of countdown after a unsuccessful boot. (I changed it to 3).

After you saved the change you need to run “sudo update-grub2″ to apply the change. If all goes well, you should boot directly with the configured kernel during next reboot.

A solution to MySQL ERROR 2006 (HY000): MySQL server has gone away

Having just moved quite a large installation to a MySQL database I have encountered the following error when connecting to the MySQL server:

ERROR 2006 (HY000): MySQL server has gone away

After looking at countless solutions and none working (many say that the max_packet value has to be increased), I found a MySQL engineer stating that is has to do with the timeout values which could be 10 or 20 (by default).

Indeed, the problem was solved on our servers with a higher value for interactive_timeout and wait_timeout. You can set these values (and many others) in the my.cnf file.

From iPhone to Android – Samsung Galaxy i9000

Ok, so I did it. I went from my truly lovely iPhone (3G) to a Android phone. My choice is the Samsung Galaxy i9000 (some call it GT-9000). So, how is the experience so far?

Actually, I can say nothing else then just good thing about it. The Android OS feels just like…. natural. You realize quickly, that Google has put in a lot of efforts into this system. Actually, they put in a lot of efforts in their latest products (Chrome, Picasa, etc.). In any case, I could get everything running in short time.

If you have a Google (or Google Apps) account then synching and setting up the phone is a breeze. All you have to do is to enter your eMail address and password and your phone pulls all the eMail, Calendar and Contacts from Google. Nothing else to do there. I actually had a funny thing with Contact synching. That is, that one contact wouldn’t sync at all and I also received a lot of “sync has a problem right now” with the Contacts. In the end I removed the contact in question and entered it again. But otherwise, everything runs fine.

You can feel that Android was build for working with Google Apps. eMails come in almost as instantly as on any desktop app. GTalk is integrated also and you get notification going all over the place. One thing that Android has definitely gotten right, are the notification in general. They don’t only work for some applications, but work for about everything. This is especially useful if you are on Twitter (who isn’t? btw: follow me at @thenitai) and someone mentions you or is sending you a message. This works with Seesmic or Hootsuite and any other app. Very nice.

Another thing is the geo location functionality. Google Maps with direction just blows aways about everything you have seen before. Did you ever try to use Directions on the iPhone? The last time in London, I ended up in a total different place. Anyhow, all I’m saying is that Android is really a good system and if they continue like this, they will give everyone a run for their money (yes, Apple I mean you).

Not being a “game” guy, I did not play one game on it yet, but can imagine that the Galaxy screen just screams for it :-) Talking about the screen. WOW. This Super Alomed screen is just marvelous. The phone itself is bigger then the iPhone (3g and 4G) but just a little. Since it is lighter then the iPhone 4G you actually don’t feel a difference at all. Actually, you won’t even notice a big difference between the iPhone and the Samsung, until you start working with it and realize that Android is not just a “Linux” and “Geek” system, but a grown up operating system for the phone. And a fun one as well. Turn on “Live Wallpaper” and you know what I mean…

At the end, I recommend the phone wholeheartedly to everyone who is thinking of switching from the iPhone.

Below are some tips for connecting to MacOS X and setting up the phone with Swisscom.

Mounting the phone in MacOS X

The good thing is that you can simply hook up the phone by USB to the Mac and it starts charging the battery. Of course, there is no iTunes synching or alike, but if you need that you can get “The Missing Sync for Android” application. I haven’t used it but heard good things about it, especially since you can use it over Wi-FI and Bluetooth.

But if you want to simply mount the phone and the HSDC card (if any) then you have to go trough some setting. There are somehow “hidden”, so here they are:

1. Go to “Settings”, then to “About Phone” and click on “USB settings”. Since the default is set to Samsung Kies it will never connect to a Mac. So choose either “mass storage” or “Ask on connection” (my choice).

2. After you have set the above you need enable USB debugging (strange but true or else you can’t connect to the Mac). Go to “Settings” again and choose “Applications”. Then click on “Development” and enable “USB debugging”.

Once you have done the above two steps you can connect your phone per USB to the Mac. The phone and if any SDHC card installed will show up as hard disk drives.

Setup GPRS and MMS for Swisscom network

If you, like me, have not bought the phone from Swisscom directly you have to setup the phone manually to be able to connect to any Internet service on 3G. Swisscom offers a “setup your device” website which will send you a SMS and will automatically configure the phone, but unfortunately the Samsung Galaxy can not be configured this way. Thus we have to do some hand work here.

Go to “Settings”, click on “Wireless and network” and then on “Mobile networks”. Within click on “Access Point Names”. You will probably see a black screen. Thus we will have to add a APN now. Click on the menu key and “New APN” (do it once for GPRS and one time for MMS). Then simply enter all the required paramaters according to the list below:

For GPRS:
Name: Swisscom GPRS
APN: gprs.swisscom.ch
Proxy:
Port:
User name: gprs
Password: gprs
Server:
MMSC:
MMS-Proxy:
MMS-Port:
MCC: 228
MNC: 01
Authentication type:
APN-Typ: Internet + MMS

For GPRS:
Name: Swisscom MMS
APN: event.swisscom.ch
Proxy:
Port:
User name:
Password:
Server:
MMSC: http://mms.natel.ch:8079
MMS-Proxy: 192.168.210.2
MMS-Port: 8080
MCC: 228
MNC: 01
Authentication type:
APN-Typ: MMS

That’s it. Now you should be able to see the “3G” sign in the upper menu bar and will be able to connect to Twitter et all on your mobile network.

Hope this helps anyone. If you have questions or want to know something just leave a comment.

On my way to Linux – Part One

Right, so here is the scope. I’ve been a MacOS X user for many years, not that I have been a fanatic one but I simply used what works best for me. In any case, I own 3 Mac Mini’s and mostly got a new MacBook Pro every year. I also converted quite a lot of people over the Mac. Recently, I’ve even got a iPhone (well, 1 1/2 years ago) after many years of using a BlackBerry. I have to say, the “Apple way” has worked very well for me.

That being said, I have always followed how Linux has been developing, especially on the desktop side (all of our servers run Linux). Actually, with Ubuntu 8, I seriously was thinking of using Linux on the desktop, but back then some application were missing. Later with Ubuntu 9, I took another try, but it still wasn’t ready for me. Now, with Ubuntu 10, the distro is not only very mature, but also, the applications I need are mostly up to date and work well for me.

So, today I set out to see if I will be able to replace my workplace which is based on MacOS X to Linux Ubuntu. My current setup is a MacBook Pro 15″ as my main machine hooked up to a 23″ Cinema screen. I was thinking to replace this setup with a desktop machine and have a netbook (the Asus EeePC 1201PN looks very sweat) as well. Since I still have a older MacMini lying around I set out to get Ubuntu 10 running on it.

Installing Ubuntu on a MacMini

Installing Ubuntu 10 on the MacMini was easy and surprisingly Ubuntu found every bit of hardware, it even found my Bluetooth Logitech Mouse within seconds.WIFI, Ethernet and external hard drives were also found without problems. For those wondering how to install Ubuntu on MacMini all you have to do is to partition your drives with BootCamp, insert the Ubuntu CD and then reboot the Mac (hold down the ALT key). Select the “Window” partition and it will start up from the Ubuntu CD and will start to install it.

So, how is it working with Ubuntu 10?

What can I say, except that the people over at Canonical (the company behind Ubuntu) has fulfilled the promise to bring the best Linux experience to the desktop. I have had no driver problems, could immediately connect to the WIFI network and installing new software even easier then on the Mac.

But we already knew that Ubuntu is good, right? So the real thing for me is to see if I can get my workspace going under Ubuntu. In short, this means that all my applications and workflow will be available and doable with Ubuntu. Thus the rest of this blog post and part two and maybe even part three will be about finding and using the equalivant of of the Linux app to the Mac ones.

I won’t go into the obvious applications that are the same on each operating system like browsers or file explorer systems. The good thing to know is that Firefox and Google Chrome and all their extensions work the same under any operating system. One thing I noted so far, is that Firefox does not seam to have the memory leak problems like the one on the Mac.

Eclipse

I’ve used Eclipse for a long time and recently switched to Coda on the Mac, since Eclipse just eat away all the RAM I had and even crashed many times a day. I’m happy to see that Eclipse under Linux is rock solid and I can use my favorite development environment again.

Mail / Calendar / Contacts / iCal / Address Book

This is a no brainer for me, since I have been using Google Apps for some time and thus my Mail and Calendar already resides in the cloud I can simply continue using my browser without any OS worries. I never used Mail.app (instead used the Browser or Mailplane) and used Spanning Sync for keeping iCal and my Address Book in sync with Google Apps. Since, I don’t like any Mail apps or Calendar under Linux I simply opted to use the browser for Mail, Calendar and Address Book (this will keep it in sync with the iPhone/Android).

Word / Excel / Powerpoint

Right, so much has been said, about using OpenOffice instead of iWork or Microsoft Office. In my testing I have to say that OpenOffice 3.x works fine, but maybe it is just me or does OpenOffice on Linux look like Word 98? Feels like flying back in time… I have to say, that I haven’t tested this part in depth and so I can’t really give any verdict on this.

I have some other apps I need to work with like Aperture, TextExpander, 1Password, etc. and will write on these on the second part.

I hope this helps anyone that is wanting to switch over to Ubuntu. I haven’t made up my mind, if I should switch full time to Ubuntu. At the current state, the MacOS X with its Unix root feels like the grown up Linux, just more polished and with all the apps in the right place.

Please let me know your thoughts in the comment section.

Getting SUN Java 6 JRE installed on Ubuntu 10

So far, installing SUN Java versions have always been a bit of a “pain” under Linux. Well, as I said, when you need SUN’s Java version that is. Most of the time you need to go to their intuitive (fun intended) download page and think very hard which version to download.

Ubuntu has made this step a bit easier. Actually, all there is to it, is the following:

1. Add the required partner repository

Under Ubuntu 10 you have to edit the file “/etc/apt/sources.list” and uncomment the partner entires (See screen shot below).

2. Update your repository

This is a simple one. Issue the command “apt-get update” and off you go.

3. Install Java

Now all there is for you to do is to install Java with “apt-get install sun-java6-jre”.

Now, anyone please tell me that Linux is hard to handle :-)

Synching folder with Amazon S3

The other day I set out to finally start synching one of my backup folders on one of our Ubuntu Servers with Amazon S3. The reasons for this, are obvious. Amazon S3 is very cheap and reliable and is a good fit for keeping “smaller” chunks of files as a backup storage. So, apart from writing a script that runs trough crontab, which was easy to write, I’ve spent far more time to get the S3 script running. So, here are the steps to sync any folder with Amazon S3.

First off, I created a additional bucket on S3. Let’s call this backup “mybackup”.

Since, I did not wanted to install anything additionally to run the S3 scripts (there is a very popular S3Rsync for Ruby out there) I wanted to get it running with the “bash” shell itself. Why install another language, if you got everything already, right?

So, I went ahead and downloaded the S3-bash scripts. As the name implies, these are scripts that work in the bash shell and nothing else is needed for it. Unfortunately, the documentation lacks big time, so I had to run all over the net to find some. Since they are very sparse, here are the steps to get it running.

After you have unpacked the scripts you get three scripts called;

  • s3-get – for getting files from S3
  • s3-put – for putting files on S3
  • s3-delete – for deleting files on S3

Since we want to put files on S3, we are going to focus on the “s3-put” script. Here is a example how the commands for the s3-put script would look like:

s3-put -k {yourkey} -s awssecretfile -T /backup/myfile.zip /s3-backup/myfile.zip

The explanation of the params is as follows:

  • -k
    The “-k” parameter is your Amazon S3 key
  • -s
    The “-s” parameter is a path to a file (which you have to write) which contains your Amazon S3 secret key. Please read further down, in order to avoid any errors with this.
  • -T
    The “-T” parameter should be the absolute path to your file that you want to out on Amazon S3
  • file bucket and path on S3
    Last but not least, you have to pass the path to your S3 bucket and the file name to the command string.

Now, that wasn’t so hard right? Well, there is one small thing that drove me crazy during my initial setup. That is that the file with my Amazon S3 secret key kept on throwing an error. Somehow the length was not matching and some other errors. After some digging around I figured that one has to write to the file again in order to get rid of the 41 bytes error message. To do that issue the following command:

cat awssecretfile | tr -d '\n' >> awssecretfile-new

Right, so I’m hoping this helps anyone out there. Have fun.

Nginx error with Tomcat – upstream sent too big header while reading response header from upstream

Nginx is our favorite web server currently as it is fast, lean and easy to configure. Performance is just outstanding and if you haven’t take a look at it.

One thing that I noticed while we deployed Nginx with Tomcat is that their default size for the buffers are very low. Don’t know why a 4K buffer size would be sufficient. If you keep it at their default size and might have a heavy duty Tomcat app then it could be that you will see error messages like:

upstream sent too big header while reading response header from upstream

The remedy for this error is to set the parameters for higher values for the proxy_buffer* parameters as we have done and now all is back to normal. Here are the current settings that worked well for us;

proxy_buffer_size   128k;
proxy_buffers   4 256k;
proxy_busy_buffers_size   256k;

Setting up Apache2, PHP and MySQL on MacOS X – the easy way

Today I set out to get MySQL and PHP setup on my MacBook Pro. Since Apache2 already comes with MacOS X (mine is Snow Leopard and yours should be too!). Now, the funny thing is that I first searched on the web how to best install PHP and MySQL.

Surely, I came across MAMP (a package that gets you Apache2, PHP, MySQL and a couple libraries) in a nice one click application and some others. Being the guy who rather has things separated and controllable, I quickly shined away from those. Thought, I gave MAMP a try, but could not get MySQL to listen to anything else then the internal Apache2 server from the MAMP package (but guess that is another story and I’m really not doing this the first time.). Anyhow…

I then looked into getting Apache2, MySQL and PHP with MacPorts. Thought MacPorts has proven to be perfect in such circumstances, I had a hard time (and it took very long) to get this setup up and running. I’m sure, some of you have had successful installs and all works great, but at the end it did not work for me. There are even more instructions to get PHP running, with a lot of tweaking and such, but to be honest in the end…

Really the simplest and most straightforward method to get Apache2, MySQL and PHP running on MacOS X is;

MySQL

Now, this is really no brainer. All you need to do is to go to http://www.mysql.com and download the recent release. Within the download image you will find a nice installer and Preference pane which lets you start/stop MySQL. If you want to go all GUI, then also download the GUI tools from MySQL.

Apache2/PHP

The probably easiest of it all. Since MacOS X already comes with Apache2 and PHP all you need to do is to enable it. Thought, PHP is disabled in the httpd.conf, all there is to do is to edit httpd.conf and uncomment the mod for the php library.

That’s it!

Nothing to install, (almost) nothing to configure. Simple and easy.