BigDiver

Dive away, explore the net…

Archive for the ‘Snow Leopard’ Category

Cassandra Development Environment in Mac OS Snow Leopard

with 4 comments

I just started working with Cassandra so I am no expert on the subject, and this post is more about self documentation of what I did to get it working on my laptop, running Snow Leopard, than an expert’s How to guide. If it helps you out all the better, and leave your comments.

Getting Cassandra to run on Mac OSX is very easy just download the latest binary from http://cassandra.apache.org/. At the time of this writing the version was 0.6.3, but I updated the important parts to 0.7rc3 so it should work with that version as well.

Create the directories Cassandra needs to work:


sudo mkdir -p /opt/cassandra
sudo chown -R `whoami` /opt/cassandra
sudo mkdir -p /var/log/cassandra
sudo chown -R `whoami` /var/log/cassandra
sudo touch /var/log/cassandra/system.log
sudo mkdir -p /var/lib/cassandra
sudo chown -R `whoami` /var/lib/cassandra

Get Cassandra and copy it to /opt/cassandra. In this example I used wget. Notice that the version numbers may change so use the correct link for your version from http://cassandra.apache.org/download/


wget http://apache.opensourceresources.org/cassandra/0.6.3/apache-cassandra-0.6.3-bin.tar.gz
tar xzf apache-cassandra-0.6.3-bin.tar.gz
cd apache-cassandra-0.6.3/bin
./cassandra -f

If all is ok you should now see


INFO 22:01:15,273 Auto DiskAccessMode determined to be mmap
INFO 22:01:15,887 Saved Token not found. Using 114412163776176127313248360017471199843
INFO 22:01:15,888 Saved ClusterName not found. Using Test Cluster
INFO 22:01:15,898 Creating new commitlog segment /var/lib/cassandra/commitlog/CommitLog-1278036075898.log
INFO 22:01:15,937 LocationInfo has reached its threshold; switching in a fresh Memtable at CommitLogContext(file='/var/lib/cassandra/commitlog/CommitLog-1278036075898.log', position=419)
INFO 22:01:15,946 Enqueuing flush of Memtable-LocationInfo@1373164447(169 bytes, 4 operations)
INFO 22:01:15,954 Writing Memtable-LocationInfo@1373164447(169 bytes, 4 operations)
INFO 22:01:16,262 Completed flushing /var/lib/cassandra/data/system/LocationInfo-1-Data.db
INFO 22:01:16,295 Starting up server gossip
INFO 22:01:16,406 Binding thrift service to localhost/127.0.0.1:9160
INFO 22:01:16,414 Cassandra starting up...

Now lets test Cassandra. Open a new Terminal window, or tab, and:


cd /opt/cassandra/bin
./cassandra-cli --host localhost --port 9160

Cassandra 0.7rc3 output and testing is a bit different so check with the comments bellow.

At the prompt (for 0.6.x)


cassandra> set Keyspace1.Standard2['jsmith']['first'] = 'John'
Value inserted.
cassandra> set Keyspace1.Standard2['jsmith']['last'] = 'Smith'
Value inserted.
cassandra> set Keyspace1.Standard2['jsmith']['age'] = '42'
Value inserted.
cassandra> get Keyspace1.Standard2['jsmith']
(column=age, value=42; timestamp=1249930062801)
(column=first, value=John; timestamp=1249930053103)
(column=last, value=Smith; timestamp=1249930058345)
Returned 3 rows.
cassandra> quit

If you’re able to get the values out of Keyspace1 all is good and Cassandra is up and running.
If you are installing 0.7 or higher the test Keyspace1 is not loaded automatically and you need to run jconsole to load the “schema”. And go to MBeans -> org.apache.cassandra.service -> StorageService -> Operations -> loadSchemaFromYAML as documented on LiveSchemaUpdates

Please note that jconsole needs to connect to localhost on port 8080, to talk to Cassandra. Do not use the Thrift port 9160.

Now lets install Chiton, a GTK GUI written in Python that will allow us to view the data stored in Cassandra.


mkdir chiton-temp
cd chiton-temp
git clone git://github.com/driftx/chiton.git
export VERSIONER_PYTHON_PREFER_32_BIT=yes

In order to fulfill a Chiton dependecies we also need

  • Twisted 8.1.0 or later
  • Thrift (latest svn)
  • PyGTK 2.14 or later
  • simplejson
  • Telephus

First download and install Apple’s Xcode if you don’t have it already then, get a PyGTK Mac OS build  from http://www.daimi.au.dk/%7Emadsk/files/

Copy PyGTK to /Develper as instructed in the README.txt of the PyGTK package.

Now for each of the packages, except Thrift run


cd
sudo python setup.py install

If you want to use Python 2.6 run

sudo python2.6 setup.py install

Compiling thrift. Go to the directory to which you checked out Thrift from the SVN
Because of the time it may take to compile all the updates, you may skip the
port selfupdate and port upgrade outdated. But if you start getting compilation errors you MUST do them and wait :(
My iMac took 5 hours!!!


cd
sudo port selfupdate
sudo port upgrade outdated
sudo port install boost pkgconfig libevent
cp /opt/local/share/aclocal/pkg.m4 ./aclocal
aclocal --acdir=./aclocal
./bootstrap.sh
./configure --with-boost=/opt/local --with-libevent=/opt/local --prefix=/opt/local
sudo make install
cd /opt/cassandra/apache-cassandra-0.6.3/interface/
thrift --gen py:new_style cassandra.thrift
cp -a ./gen-py/cassandra ~/chiton-temp/

(thank you Rich for the configure details

Almost done!!!
All we need to do is add the PYTHONPATH to our ~/.profile. Using your favorite editor open ~/.profile and add:


export PYTHONPATH=/usr/lib/python2.6/site-packages/:/Developer/MacPyGTK/inst/lib/python2.6/site-packages:/usr/lib/python2.6/site-packages/thrift:/Library/Python/2.6/site-packages/telephus:~/chiton-temp/chiton
export JAVA_HOME=$(/usr/libexec/java_home)
export VERSIONER_PYTHON_PREFER_32_BIT=yes

The directories in your PYTHONPATH may be a bit different, but the idea is to add all the directories where all the packages we just installed are located. If you miss one you will get import errors when running chiton-client.

Reconfigure Cassandra to allow the Thrift connections from Chiton, you need to set ThriftFramedTransport to true in cassandra’s storage-conf.xml. In my system


vi /opt/cassandra/apache-cassandra-0.6.3/conf/storage-conf.xml
<
ThriftFramedTransport>true</ThriftFramedTransport>

Done!!!!

If all is well you should now be able to run chiton-client. Login to localhost on port 9160. Don’t forget to have Cassandra daemon running (cassandra -f).

Since we changed the Thrift access to framed, from now on if you want to use the cassandra-cli don’t forget the –framed command line option. Cassandra 0.6.3 daemon crashes with:


ERROR 23:50:24,264 Uncaught exception in thread Thread[pool-1-thread-5,5,main]
java.lang.OutOfMemoryError: Java heap space

if you don’t use –framed.

Hope this guide helps you get your development machine ready to work with Cassandra.

Written by bigdiver

July 2, 2010 at 3:13 am

Gave up on Snow Leopard on the Mac Book Air

with 4 comments

After fighting with Snow Leopard for a couple of months on my Mac Book Air, and experiencing two serious data corruption problems, I have officially given up on Snow Leopard.

Here is the summary of my experience with Snow Leopard.

  1. Snow Leopard came out. I upgraded both my Macs (iMAC, and MacBook Air)
  2. iMac works with a few quirks, but after the first update from Apple things are stable and all seems to be working. A few applications needed to be updated, but no major issues.
  3. MacBook Air upgrade did not work initially as documented in a previous post.
  4. Got everything to work but it was so very slooooow…. NONE of the “faster” claims by Apple verified.
  5. MacBook crawling, it got so bad that I decided to do a clean install. So I formated my HDD and installed SL from scratch.
  6. Same thing, slow, slow, slow….
  7. Found some fixes as documented in another post. This did work, especially the Terminal fix.
  8. The MacBook Air was not hibernating or sleeping properly, was hanging constantly and finally I suffered data corruption when the laptop ran out of battery while stuck, and not going to sleep after I closed it and stowed it.
  9. Tried to recode HDD but all data recovery tools complained an said they could not recover the data.
  10. Second reinstallation, same thing happened after three weeks

Fed up, went back to Leopard, all is working to perfection…

Written by bigdiver

December 21, 2009 at 12:27 am

Mount a Time Machine Backup Disk

with 2 comments

Time Machine backup images can be mounted as regular disks using the hdiutil command.

All you need to do is

sudo hdiutil attach <time_machine_file.sparsebundle>

If your Time Machine backup file is on a network share you need to connect to the server and mount the share before you can run the hdiutil command.

It may take some time especially on slow networks or big image files.

Mounted image of Time Machine Backup disk

Written by bigdiver

November 26, 2009 at 3:18 am

Posted in Apple, Snow Leopard

Tagged with , ,

Snow Leopard too Slow Fix

with one comment

I did a fresh install of Snow Leopard on my first generation Mac Book Air and it is still toooooooo slow. Digging around I found a couple of solutions that really helped.

General slowness due to lack of memory (from Apple Forum)

sudo rm /System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist

Then if the Terminal application takes for ever to show you a prompt, delete the logs like so:

sudo rm -f /private/var/log/asl/*

Thanks Webapper for the slow Terminal fix!

Written by bigdiver

November 25, 2009 at 6:24 am

Posted in Apple, Snow Leopard

Tagged with

Skype Error: Unable to mount database

with 3 comments

I started getting a lot of Skype database errors during login. I would type my password and during the login process I always got the “Unable to mount database” error on Skype for Mac version 2.8.0.722.

To solve it delete the Skype’s user directory doing

rm -fr ~/Library/Application\ Support/Skype/<username>

using the Terminal application, then login to Skype.

Please pay attention to the “~” at the beginning of the file path. This is not a mistake it actually represents your home directory.

Written by bigdiver

November 25, 2009 at 5:56 am

Restoring Time Machine Backups on a Different Computer even Over SMB or AFP

with 7 comments

There are many situations that require you to restore backups to different computers, other than the one from where the data was originally backed up from. In the case of Apple’s Time Machine the restore procedure to different machines is not very intuitive. You have to use the “secret” option key…

There is a supported way to restore Time Machine backups of other computers using the “option-key” click on the Time Machine menu. If you want to use it just do the following:

  1. Connect the Time Machine disk to the Mac you want to restore the files to
  2. Set the “Show time machine status in the menu bar” In System Preferences -> Time Machine.
  3. Click the Time Machine icon in the menu bar and keeping the mouse button pressed, press the “Option” key.
  4. Select “Browse Other Time Machine Disks”
  5. Select the disk you want
  6. click Use Selected Disk

The Time Machine will open with the selected disk and you can use it to restore the files.

Time Machine with mounted disk

If, like me, you are using a non supported Time Machine configuration, where the backup disk is mounted using SMB or AFP (see this post on how to enable that) then the procedure above will not work directly. In my case I backup to my Buffalo TeraStation NAS, and the “Browse Other Time Machine Disks” window shows up empty, with no disk to select.

Empty Browse Other Time Machine Disks

In order for this to work you need to first mount the Time Machine disk by hand in using the command line.

  1. Mount the shared folder where your Time Machine backups are stored
  2. Open a Terminal window and cd to the Time Machine volume. in my case I called it backups
    sudo cd /Volumes/backups
  3. use hdiutil to mount the specific Time Machine .sparsebundle file
    sudo hdiutil attach <time_machine_file.sparsebundle>

Now you should be able to see the mounted volume in Finder, with all the backups listed as folders, and you can copy any files directly from it. Remember that mounting the disk may take some time due to the size of the disk and network connection speed, especially If you do this over a WiFi network.

Mounted image of Time Machine Backup disk

Another option is to repeat the supported Time Machine procedure  outlined in the beginning of this post. You should now see the mounted disk as a Time Machine disk. Select the the disk and click “Use Selected Disk” and Time Machine will open on the selected disk just like with a Time Machine supported back up disk.

Time Machine Browse Disk

Personally I like to copy them directly from the Finder but your preference may vary so I document both ways of achieving this goal. Hope this helps.

Written by bigdiver

November 24, 2009 at 7:42 pm

Update your Mac Ports for Snow Leopard

leave a comment »

After upgrading to Snow Leopard you will need to update your Mac Ports. Please download and install the new Snow Leopard version of Mac Ports open a Terminal window and change to the /opt/local/bin directory, then run the commands

./port -v selfupdate
./port -f uninstall p5-xml-parser
./port clean --all p5-xml-parser
./port install p5-xml-parser
./port -f uninstall libxml2
./port clean --all libxml2
./port install libxml2
./port upgrade outdated
./port -f -p clean --all all

If a particular package gives you trouble just remove it and install it again.

Written by bigdiver

October 22, 2009 at 5:22 am

Posted in Snow Leopard

Configure Home/End Key Bidings on Mac OS X

with 7 comments

Hi I feel that this  a prety common request: Bind the Home/End keys to move to the beginning and end of lines respectively.

In Mac OS X (10.5 and 10.6) some applications use the Cmd-Rigt and Cmd-Left to perform these actions but, call me old fashioned, I like to use Home and End instead.

It is actually very easy to change the Cocoa Key bindings for any user under Mac OS. Just follow these steps:

  1. Create a file called DefaultKeyBinding.dict in ~/Library/KeyBindings directory
    mkdir ~/Library/KeyBindings
    cd ~/Library/KeyBindings
    touch DefaultKeyBinding.dict
  2. Edit your DefaultKeyBinding.dict file so it contains:
    {
    /* home */
    "\UF729"  = "moveToBeginningOfLine:";
    "$\UF729" = "moveToBeginningOfLineAndModifySelection:";
    
    /* Cmd-Left */
    "@\UF702"  = "moveToBeginningOfLine:";
    "$@\UF702" = "moveToBeginningOfLineAndModifySelection:";
    
    /* Cmd-Right */
    "@\UF703"  = "moveToEndOfLine:";
    "$@\UF703" = "moveToEndOfLineAndModifySelection:";
    
    /* end */
    "\UF72B"  = "moveToEndOfLine:";
    "$\UF72B" = "moveToEndOfLineAndModifySelection:";
    
    /* page up/down */
    "\UF72C"  = "pageUp:";
    "\UF72D"  = "pageDown:";
    }
  3. Restart the Cocoa Application.

This example works very well with TextMate.

In order to bind other keys you need to find their Scan code, and you can use the following modifiers
For more information please check this article

Written by bigdiver

September 11, 2009 at 7:26 pm

Snow Leopard Upgrade breaks a ton of apps

leave a comment »

After having done the Snow Leopard upgrade from leopard 10.5.8 a week ago, I have to say I am disappointed!

A lot of my applications just crash, Xcode and Mac Ports had to be reinstalled, Apache and PHP reconfigured by hand, reinstall MySQL, among others.

I have yet to see any real performance improvements, for example the Terminal application is very slow (over 10s) to give me a prompt.

I did get some 10Gb back from my HDD but… I am considering doing a fresh install. Am I back on Windows?

very sad…

Written by bigdiver

September 11, 2009 at 7:14 pm

Posted in Apple, Snow Leopard

Tagged with , ,

Follow

Get every new post delivered to your Inbox.