MongoDB in FreeNAS jail

home automation

This posts describes steps I took to get MongoDB running inside of a jail on my FreeNAS 9.1.1 setup. All commands issued from @freenas are from the main console, and @homeauto_database are from inside of the jail. This step provided me with a fully functional persistence backend for OpenHAB.

  1. Create port jail via FreeNAS UI
  2. Configure Jail
    [root@freenas]$ jls
       JID  IP Address      Hostname                      Path
        12  -               homeauto_database             /mnt/mainsafe/jails/homeauto_database
    [root@freenas]$ jexec 12 /bin/tcsh
    [root@homeauto_database]$ portsnap fetch extract
    [root@homeauto_database]$ cd /usr/ports/databases/mongodb/
    [root@homeauto_database]$ make install
  3. Fill in any prompts that you get (I’ve used default settings for all)
  4. Create mount-points via FreeNAS UI to expose directories you like
  5. Make mongodb start up at boot
    [root@homeauto_database]$ vi /etc/rc.conf
    # add at the bottom
  6. Start MongoDB for the first time
    [root@homeauto_database]$ /usr/local/etc/rc.d/mongod start
  7. Check if the process is listening
    [root@homeauto_database]$ netstat -a | egrep 'Proto|LISTEN'
    Proto Recv-Q Send-Q Local Address          Foreign Address        (state)
    tcp4       0      0 *.28017                *.*                    LISTEN
    tcp4       0      0 *.27017                *.*                    LISTEN
    tcp4       0      0 *.ssh                  *.*                    LISTEN
    tcp6       0      0 *.ssh                  *.*                    LISTEN
    We can see that mongodb is listening!
  8. Get IP address of the jail
    [root@homeauto_database]$ ifconfig
    epair11b: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
            ether 02:e7:61:00:13:0b
            inet netmask 0xffffff00 broadcast
  9. Try to connect via UMongo –
    (you may need to enable execution of programs from unidentified developers on osx 10.9 or later)

That’s it! You should now have a database running on your FreeNAS server.

blog comments powered by Disqus