Sponsored By Aspose - File Format APIs for .NET

Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!

Installing Neo4j in an Azure Linux VM

I’ve been playing with Neo4j a lot recently. I’ll be writing a lot more about that later, but at a very very high level, Neo4j is a graph database that in addition to some language-specific bindings has a slick HTTP interface. You can install it on Windows, Linux, and Mac OSX, so if you’re more comfortable on Windows, don’t read this post and think that you can’t play with this awesome database unless you forget everything you know, replace your wardrobe with black turtlenecks, and write all your code in vi (though that is an option). For me, though, I hate installers and want the power of a package manager such as homebrew (OSX) or apt-get (Linux). So I’m going to take you through the steps that I went through to get neo4j running on Linux. And just to have a little more fun with things, I’ll host neo4j on a Linux VM hosted in Azure.

For the Azure tasks, I use the CLI tools for as much as humanly possible (and continue to look forward to the day when I can do everything through the CLI). Glenn has blogged quite a bit about the CLI, so I’m not going to go into any depth here, but in case you haven’t installed the CLI tools, you can get them through Node Package Manager with the following command:

npm install azure-cli

After the CLI tools are installed, just type ‘azure’ in your terminal window for some rockin’ ASCII art and a list of the available commands.

So to create my new linux VM, I’ll run the following command:

azure vm create hldlnxneo b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-12_04_1-LTS-amd64-server-20121218-en-us-30GB howarddierking -e -l “West US”

While you can easily look up what this means, here’ the quick rundown:

  • “hldlnxneo” is the dns name of my VM (I’ll be able to access it via hldlnxneo.cloudapp.net later)
  • the giant string is an existing image name for an Ubuntu distribution – you can see the list of existing images with the command ‘azure vm image list’ – you can also upload your own if you prefer.
  • ‘howarddierking’ is the default user account that’s created – you’re asked to specify the password later
  • the ‘-e’ arg says to enable SSH on the default port (22)
  • the ‘-l’ arg allows you to specify the region (data center) where you want the VM created.

So once I have my virtual machine created, I can easily access it with ssh (ssh is another big incentive for me choosing a linux Azure image):

ssh howarddierking@hldlnxneo.cloudapp.net

And I’m now in a remote shell session on the Azure VM. Insanely awesome.

Now, all I need to do is install Neo4j using apt-get. It took me a while to land on this page, so my hope is that at the very least, this post helps elevate it in search results (or at least provides another avenue to reach it). Additionally, there was one error/difference in the instructions that I’ll note here.

Enter the superuser/root shell with:

sudo -s

This will be a convenience to keep us from having to preface many of the below commands with sudo.

Add Neo4j on Debian/Ubuntu

  1. Add Neo4j repository to APT:
    echo ‘deb http://debian.neo4j.org/repo stable/’ > /etc/apt/sources.list.d/neo4j.list
  2. Update depedency lists: apt-get update
  3. Install Neo4j: apt-get install neo4j (say “yes” to all questions)

Confirm Neo4j is running locally

Note: at this point, you can exit the root shell with the ‘exit’ command.

curl http://localhost:7474

Make Neo4j accessible from the outside

Only do this if it is necessary, for instance when your services accessing Neo4j run on a different host. Make sure to secure the instance by enabling SSL and adding authentication (like the authentication-extension.

  1. Find and open: /etc/neo4j/neo4j-server.properties
    1. this is the location on my Azure VM where apt-get installed neo4j – if you don’t find the file here, you can always find out where it was installed with the command ‘dpkg -L neo4j’
  2. uncomment the line: #org.neo4j.server.webserver.address=
  3. Check that SSL access is enabled: org.neo4j.server.webserver.https.enabled=true
  4. restart the Neo4j Server: sudo /etc/init.d/neo4j-service restart
    1. ** this is different than the official version where the command is neo4j-server
  5. Navigate to the Azure portal and open port the port that Neo4j runs on (7474 by default) – in my case, I’ll map port 80 to port 7474 using the “add new endpoint” function as shown below…Screen Shot 2012-12-28 at 11.24.16 PM
  6. Check if it is accessible from the outside: ‘curl http://hldlnxneo.cloudapp.net’

And there we go – we have a new Neo4j database instance just ready for new nodes and edges!

Much more to come on those topics…

About Howard Dierking

I like technology...a lot...
This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.