Because Mongo is so simple and lightweight, it can run on many platforms. For businesses, there is often some Linux presence and Red Hat is likely the distribution of choice. So, I wanted to write down what it takes to get MongoDB installed on Red Hat Linux Enterprise v6.
First, because I’m a private person, I needed to create an account on www.RedHat.com, then I could download a 30-day trial. This is in the form of a boot disk image (an .iso) and then the actual DVD image which contains the operating system install.
You could always use the open-source Fedora version, which is almost identical, however for this blog post, I wanted to use the real thing since this may be a reference for someone installing on actual Red Hat Enterprise.
The simplest way for me to do this was on Hyper-V, on my Windows 8.1 Pro workstation. Here’s how that went:
STEP 1: Download the ISO’s for Red Hat
Go to www.redhat.com and go to Download Evaluations:
then you’ll see that you can download the ISO’s:
STEP 2: Create the virtual machine in Hyper-V
Open “Hyper-V manager” (see this post, if you have Windows 8 or 8.1 “Pro”, to see how to enable Hyper-V) – this could be on Windows 8 or 8.1 Pro – or on Windows Server, it’s the same Hyper-V software. Right-click on the server name and choose to create a new virtual machine – and follow the prompts:
STEP 3: Install Red Hat Linux Enterprise v6 on the Hyper-V virtual machine
Right-click on the VM and choose Start and go through the installer per-normal…
Not that we booted from the boot ISO, and after a few screens, we need to switch our media over to the installation disk:
You can switch to the other ISO you downloaded from the Media menu (which I can’t take a screenshot of), or by right-click on Settings for that VM back in Hyper-V
And go to the “DVD Drive” that is listed:
From here, you can click browse and point to the other ISO you downloaded (named “rhel-server-6.5-i386-dvd.iso”, in my case). That’s how it is supposed to work, but it did not in this case. I got this, whenever I tried to eject or change the disc that is mounted in that DVD drive.
Well, that should be what we do, but Red Hat has a death-grip on the DVD drive, so we can’t eject it! So, I shut down the VM, added a second DVD drive, and that worked. I mounted the boot disc to one and the installation disc to the other. That fixed this, for me.
During the installation, I just chose “Basic Server”:
Installation took about :15 minutes
Note that “Red Hat 6 does not configure network interfaces on default installation”. Yes, you heard correctly, in the year 2014 – why would network cards be enabled by default!
So, I had to go enable it, and set it to use DHCP. Edit this config file:
$ sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0
That file now looks like this:
Reboot and try to ping something, or type “ifconfig” and you’ll see the network card is now working.
STEP 4: Download and Install MongoDB
This ended up being pretty easy. I just followed the instructions right from the MongoDB site:
This is ideal too because in a corporate environment where you aren’t allowed to install un-vetted software from the Internet, you can configure Yum to point to a local repository.
Per the instructions, I created the file:
$ sudo nano /etc/yum.repos.d/mongodb.repo
Then, I can run the Yum install:
$ sudo yum install mongo-10gen mongo-10gen-server
Which looks like this:
STEP 5: Start the service
Now I should be able to start the service with:
$ service mongod start
And sure enough:
STEP 6: Connect to the service
And when I run the mongo client:
I can connect to the local instance: