Saturday, May 31, 2014

Fixing python terminal

Does your terminal make funny characters when you press the arrow keys instead of retrieving the last command?

You can fix that a couple quick installs.

pip install ipython
# may require you to 'yum install ncurses ncurses-devel' or similar, depending on your os
pip install readline

Now access the shell substituting the command 'python' with 'ipython'.  It should behave nicer.

IPython can do a lot more for you than give you a pretty shell.  Check out its capabilities at the project website.

Installing mongodb on an old computer

I have a little old 32 bit Compaq machine that I'm setting up a playground server for projects.  It has a lot of disk space (~500 GBs), a decent CPU (AMD Sempron 2 GHz), and a nice amount of ram (~2 Gb).  But it's old.  And it's 32 bit.  Still, I wanted to get mongo running on it.

When I tried to install mongo using the instructions for mongodb (yes, I made the change for the 32 bit version), I ran into the following error:

[tcvh@localhost ~]$ sudo service mongod start
Starting mongod: bash: line 1: 22495 Illegal instruction     /usr/bin/mongod -f /etc/mongod.conf > /dev/null 2>&1
                                                           [FAILED]


I looked into this a little, and it seemed the easiest solution was to roll back the version.  At first I tried just following their instructions for specifying a different version number, but when I went to install, yum couldn't find anything.

So instead I crawled around the directory listing for the RPM and saw that they recently changed the naming convention of the RPMs.  I tried a few different things, but eventually found that for installing version 2.0.4, the following works.

The contents of "/etc/yum.repos.d/mongodb.repo":

[mongo-10gen]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686/
gpgcheck=0
enabled=1


The installation commands:

sudo yum install mongo-10gen-2.0.4
sudo yum install mongo-10gen-server-2.0.4

After that you can see that mongod is installed in "/usr/bin"

updatedb  # you just added stuff, so update the search index
locate mongo  # hey, look at that, it's there

You can start up the server and get into the shell with the following:

sudo service mongod start  # kick off the server
mongo  # get into the shell

You may also want to set up the service to run when the machine boots:
sudo chkconfig mongod on

That's it.