Learn how to use Chocolatey to install Neo4j on a Windows machine

[As community content, this post reflects the views and opinions of the particular author and does not necessarily reflect the official stance of Neo4j.]

There are many ways to install Neo4j on a Windows server or desktop, including as a simple .exe file or a .zip file. However, it would be great to make it easy to install Neo4j in a more Windows-standard way.

Previously this was difficult in Windows as there was no standard package manager, however Chocolatey has gained a lot of popularity in the past few years as the Windows package manager to use.

How easy is it to install? Well, this is command to install Neo4j and Java:

choco install jre8 neo4j-community

This will install Java 1.8 and Neo4j Community Edition, and then start the Neo4j server – all in one short command line!

In this blog post we will look at: Why did I choose Chocolatey to package Neo4j, and what is Chocolatey exactly anyway? We’ll also cover how to install Neo4j with more examples, how the Chocolatey packages are a built and future plans for the packages.

    • What is Chocolatey?
    • Why did I choose Chocolatey?
    • How to install Neo4j using Chocolatey
    • How are the Chocolatey packages built?
    • What’s next?

Why Chocolatey?


In late 2014, I was trying out Neo4j Community Edition for a project I was working on. It was a highly connected dataset, perfect for a graph database.

As I have always been an advocate of automation (and I hate doing the same thing twice!), I created a simple PowerShell script to download the Neo4j .zip file, configure the database and then start the service. This was ok, but it still seemed clumsy and I couldn’t share this easily with other people.

Even back then, Chocolatey was very popular, and I noticed there was no Neo4j package. I decided to convert my installation script to a Chocolatey-based installation and share my work with other Windows Neo4j users.

Fast forward to the present day and there has been nearly 1,000 downloads of the Neo4j package from the community repository at chocolatey.org, and even a community contribution to the Neo4j Chocolatey package itself.

What is Chocolatey?


So what is this whole Chocolatey thing anyway? The Chocolatey website does a great job of explaining what Chocolatey is and isn’t. Here’s a brief excerpt:

“Chocolatey is a package manager for Windows (like apt-get or yum but for Windows). It was designed to be a decentralized framework for quickly installing applications and tools that you need. It is built on the NuGet infrastructure currently using PowerShell as its focus for delivering packages from the distros to your door, err computer.

“Chocolatey is a single, unified interface designed to easily work with all aspects of managing Windows software using a packaging framework that understands both versioning and dependency requirements. Chocolatey packages encapsulate everything required to manage a particular piece of software into one deployment artifact by wrapping installers, executables, zips, and scripts into a compiled package file. Chocolatey packages can be used independently, but also integrate with configuration managers like SCCM, Puppet, and Chef. Chocolatey is trusted by businesses all over the world to manage their software deployments on Windows. You’ve never had so much fun managing software!”


In essence, Chocolatey is a tool to make it easy to create, publish, discover and install software for Windows.

Create


Chocolatey uses and extends the common Windows Nuget format for creating packages.

Publish


Chocolatey packages can be published to the Community Feed which is available to anyone on the Internet to both publish and consume. Packages are moderated by automated processes, and by humans when necessary. Also packages and any associated files are virus scanned.

Discover


People can either search the package list or use the choco search command.

Install


Installation is performed using a command prompt or PowerShell, e.g., choco install <packagename> There are currently over 4,000 packages available for installation.

Many people are concerned with security and trusting internet-based installers, and rightly so! Chocolatey takes security seriously and packages are moderated and vetted prior to approval. Chocolatey also announced their Pro and Business editions which includes features such as anti-virus/anti-malware detection and a Private Content Distribution Network (CDN) for package binaries.

And you can always host your own Chocolatey Server if you need to.

How Do I Install Chocolatey?


Follow the installation instructions on https://chocolatey.org/install.

How Do I Install Neo4j using Chocolatey?


Once you have installed Chocolatey, open an administrative command prompt or PowerShell window. (Here’s how to open an administrative command prompt.)

You need to have Java installed prior to installing Neo4j, although of course you can install Java with Chocolatey. A simple installation command line is:

choco install jre8 neo4j-community

Chocolatey packages support installation parameters where you need to customise the installation. The available Package Parameters are documented in the package description. For example, for Neo4j 3.0.1:

https://chocolatey.org/packages/neo4j-community/3.0.1

/Install:[Install Path]
/ImportNeoProperties:[Path to file]
/ImportServiceProperties:[Path to file]
/HTTPEndPoint:[Host/IP:port]
/HTTPSEndPoint:[Host/IP:port]
/ServiceName:[Windows Service Name]

More detailed information about the Package Parameters are documented in the Github repository for the Neo4j packages. In the case of this example:

https://github.com/glennsarti/neo4j-community-chocolatey/tree/master/neo4j-community-3.0.1

/Install:<Install Path>

This installs Neo4j to the specified directory. The default is to install to <Chocolatey Bin Root>\neo4j-community which is typically C:\tools\Neo4jCommunity

/ImportNeoProperties:<Path to file>

This copies the file specified to <Install Path>\conf\neo4j.conf. This is a quick way to configure the Neo4j server prior to service start. Information about the configuration file can be found at https://neo4j.com/docs/stable/server-configuration.html

/ImportServiceProperties:<Path to file>

This copies the file specified to <Install Path>\conf\neo4j-wrapper.conf. This is a quick way to configure the Neo4j Windows Service prior to service start. Information about the configuration file can be found at https://neo4j.com/docs/stable/server-performance.html

/WindowsServiceName:<Name of Windows Service>

This is the name of the Windows service which will be installed.

Note: This setting overrides the ServiceProperties file:

/HTTPEndpoint:<IP Address or hostname>:<Port>

This is the HTTP Endpoint that will be used by the Neo4j server, e.g., localhost:7474

Note: This setting overrides the NeoProperties file:

/HTTPSEndpoint:<IP Address or hostname>:<Port>

The HTTPS Endpoint that will be used by the Neo4j server, e.g., 0.0.0.0:7473

Note: This setting overrides the NeoProperties file. Example usage:

choco install neo4j-community -version 3.0.1 -packageParameters 
"/Install:C:\Apps\Neo /ImportNeoProperties:C:\Config\MyNeoProperites.txt 
/ImportNeoServerProperties:C:\Config\MyNeoServerProperites.txt"

This command will install Neo4j to C:\Apps\Neo, import the neo4j.properties file from C:\Config\MyNeoProperites.txt and the neo4j-server.properties file from C:\Config\MyNeoServerProperites.txt

Common Failures with Installing Neo4j using Chocolatey


Some common failures when installing Neo4j are:
    • If using the community Chocolatey feed, internet access is required to download the installation .zip file.
    • If the Neo4j Chocolatey package is already installed, you need to use the --force parameter to tell Chocolatey to forcibly install.
    • An appropriate version of Java needs to be installed prior to Neo4j. For example, earlier versions of Neo4j 2.x may not work on Java 1.8 or Neo4j 3.x will fail if using Java 1.7.
Remember, if you have an issue installing with Chocolatey, add --verbose or --debug to the installation command to get more detailed information about the error. Alternatively, a detailed log is created during any installation at C:\ProgramData\chocolatey\logs.

How Are the Chocolatey Packages Built?


The source files for the Neo4j Chocolatey packages are located in the Github repository.

Requirements:
    • Microsoft Windows
    • PowerShell version 3.0 or above
    • Chocolatey
    • Psake PowerShell Module. Psake is like a PowerShell version of Rake or Make
A psake file called default.ps1 contains the common tasks for creating the Chocolatey packages from templates. The default action is to build and pack all Chocolatey packages. For more information on the different kinds of tasks run psake with the -docs argument, e.g., Invoke-Psake -docs

Future Plans for the Neo4j Chocolatey Packages…


There are a few things which I would like to add:

    • Automate the packaging process
    • While the packaging process itself is templated, I still need to manually check for newer versions of Neo4j and then create the packaging information and publish to the Chocolatey feed. Instead I would like to automate the process so that within a short time of a new Neo4j database version being released, the corresponding Chocolatey package is created and published.
    • Install a private JRE if Java is not installed
    • Many products install their own private Java Runtime Environment so they do not have to depend on it being installed prior. Also, the version of Java can be controlled. I’d like to add a feature to the Neo4j installation process where it would install a private JRE if Java is not detected on the computer. This could also be added as a Package Parameter to always install a private JRE.
    • Add the Enterprise Edition of Neo4j
    • Currently only the Community Edition is available on Chocolatey as most Neo4j Enterprise Edition users would probably have their own method of installing. However, if there is a demand for the Enterprise edition, it would not be too difficult to add.

Conclusion


Chocolatey is an easy method to quickly install the Neo4j graph database on a Windows computer – much easier in fact than most existing methods. Also, as Chocolatey is integrated into other configuration management products such as Puppet, Chef and PowerShell DSC, Neo4j can be installed and managed however best fits your needs.

You can always submit issues and pull requests to the Neo4j Chocolatey Packages repository. I look forward hearing your feedback and thoughts – let me know what you think!


Want to dig deeper into the world of graph technology? Click below to get your free copy of the Learning Neo4j ebook and catch up to speed with the world’s leading graph database.

Get the Book

 

Keywords:  


About the Author

Glenn Sarti , Senior Software Engineer, Puppet

Glenn Sarti Image

Glenn is originally from Perth in Western Australia and in late 2015 moved his family to Portland (Oregon, United States) where he nows work at Puppet as Senior Software Developer on the Windows team. In what spare time he has, Glenn is the maintainer for the Neo4j Community packages on Chocolatey, and contributes to the Neo4j project, by assisting the Neo4j Operability team with Neo4j on Windows.

Glenn can be found on Twitter @glennsarti, on his blog at http://glennsarti.github.io or on the Neo4j Slack Channel.


Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe

Upcoming Event

 


Have a Graph Question?

Stack Overflow
Community Forums
Contact Us

Share your Graph Story?

Email us: content@neo4j.com