I know most of you will be here for the EPIC title picture, the dinosaurs are from http://deviantart.com/susannehs/ – I hope she isn’t too disappointed 😮 The other art, well, that’s all mine… if you want graph information – feel free to ask, and if after seeing that picture you want art – let’s talk!
In the last post we looked at running Neo4j on a server running Windows Server 2019 Core. But what we did was run it in console mode so whenever you logged off, the server would shut down – which many would say is not ideal for a server.
So let’s install it as a service, as we’re adding a service into the server, we’re going to need to be an admin, so log on to your server as an admin (or use SSH – I will be).
Get to the right place
You don’t need to do this – but it makes life a bit easier. In your PowerShell window, let’s get to the right directory:
NB your Neo4j version might be different depending on when you do this. The script in the previous post will get the latest version.
Install as a service
Invoke-Neo4j : Unable to determine the path to java.exe
At C:\Neo4j\neo4j-enterprise-4.2.1\bin\neo4j.ps1:18 char:7
+ Exit (Invoke-Neo4j -Verbose:$Arguments.Verbose -Command $Arguments.Ar ...
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-Neo4j
Setup the Environment
This is because the scripts we’ve used to start the server so far call an environment.bat file beforehand – which sets up Java etc, but that is on a session by session basis – so we need to add the JAVA_HOME environment variable now:
If you look at the environment.bat file (micro ..\scripts\environment.bat) you’ll see this:
Again Version alert!! They may be different values on your server!!
So we want to set the JAVA_HOME environment variable, and we’ll add it to the path as well, unfortunately, these are cmd commands, so set JAVA_HOME doesn’t work in PowerShell, so we need to run:
One of the things which puts people off of Windows (and this likely won’t solve it, but hey!) is that it’s seen as BLOATWARE. Needing lots of RAM just to start up. Largely, that’s due to the UI, and whilst personally, I’m ok with the trade off (I think 2GB to be able to see what you’re doing is OK), not everyone is of that opinion. Also, there’s a shed load of things that don’t need a UI. Now, I’m not going to set up a server with SSL, the correct domain access etc – as that’s way beyond the scope of this, but I will get one up and running with Neo4j.
Java as a platform works just fine on Windows now, performance wise – there’s not much in it, the biggest difference is likely the cost of licenses – i.e. Ubuntu is free, Windows Server – not so much. But you might have licenses, and indeed engineers/admins who are already experienced in Windows, and don’t really know Linux (ahem – like me).
Things to note, there are things Windows doesn’t have by default, most notably, an ‘in-powershell-editor’ sigh – I remember good old edit but apparently, that’s not been available on x64 systems for ever, so we’ll put an editor in place for that, we’ll also be using a script to download and setup the whole thing, as it’s a lot easier than manually doing it – if you’re interested, you should be able to parse the script files to see what they are doing.
I’m going to start on the principle that you have got Server 2019 (I’m using 20H2) installed and you’re at the initial ‘admin’ prompt, in ‘Command Prompt’ (shudder). I am setting this up for me to use, so I’ll be setting some defaults that I want, you may not want/nor need to do it, but I like it, so :p
1. Install SSH
I want to SSH to my server, whilst I am running it in VMWare and so can do it via remote, I’d rather just open up MobaXTerm and connect in. To do that we need SSH to be setup, so first, just to check it’s not already installed (as of 20H2, it’s not be default), start Powershell:
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
You should see if it’s installed or not, if either aren’t then run the appropriate commands below to install: (for example, I only had to install the server)
I mean, it’s 2020, why PowerShell isn’t the default normally is a mystery to me. Anyhews, we have two places to set it – one is for the VM connection (which you may not need if you never intend to connect that way – but it might be useful), the other is for the SSH users out there:
We’re going to download a script that will download all the appropriate programs (Neo4j Server, Java 11 etc) and configure things so we’re all ready to go. NB. The step where we cd into the C:\Neo4j folder IS IMPORTANT
Go all the way to the bottom of the file and change the memory settings so they fit in your server, in my case, Heap = 256M, PageCache = 256M
Quick Micro tips
Backspace doesn’t work, use Delete instead
10. Start Neo4j
We’re going to run this in console mode initially, allowing us to see it’s all ok, so run:
11. Allow the Firewall to have access (Admin)
Right, we’re nearing the home stretch, we need to add a Firewall rule to allow us to access the server, which we have to do as an Admin. Obviously, for a production environment, you’d set this all up properly, in particular the Profile – here, I’ve used 'Domain' and 'Private' – which means your network connection needs to be one of those, ideally, it would be one of those.
12. Set the Network profile to be ‘Private’ (Admin)
By default the connection you are on will be Public – which means the Firewall will block connections via our new rule, so for me, I’m going to change the network to be Private as it’s my own internal network and that’s accurate.
First, I need to get the network adapter name:
Now we have that, we need to get the current profile, which should be public: