Installing RavenDB as a service on Server Core - A walkthrough

I'm currently working on a RavenDB to SQL Server ETL project, and in order to run local development and load profiling, I've been running RavenDB build 2.5.2750 on Windows Server Core 2012R2 alongside SQL Server 2012.  It's worth noting that Raven can only be installed as a service on Server Core due to the lack of IIS.  So if you need to deploy it as an IIS application, you'll need to install the full GUI.

Deploying Raven on Server Core is actually a very simple task, but as I'm planning to blog on a few other aspects of the RavenDB ETL process, I figured this was a nice starting point. Hopefully for anyone else out there going down this route, this walkthrough may come in handy.

First, you need to download your build from here as a zip, extract the contents and then move the extracted contents over to whichever folder on your server you want Raven to reside.  Once this is done, open the \Server folder and look for the "Raven.Server.exe.config" file and open it in your favourite editor.

Here, you're looking for the two lines I've highlighted.  Change the port and datadir (database location) if necessary and save your changes.

Checking server config file

Next, you need to configure the server firewall to allow RavenDB requests in on the port you've specified.  To accomplish this, run the following command "netsh advfirewall firewall add rule name="{YOUR RULENAME}" dir=in protocol=TCP localport={YOUR PORT} action=allow" at the server console.

Allowing RavenDB through the firewall

Once the firewall is configured, the next step is to install the Raven as a service by running the "raven.server -install" command from the \Server folder.

Installing RavenDB as a service

And that's it! RavenDB should now be running as a service, in this example on port 8080.  To confirm this, open a browser window and navigate to "{SERVERNAME}:{PORT}" and you should be rewarded with the Raven management console.

My next requirement was to restore a development database to my core deployment.  I've decided to include these steps as I hit a slight snag during my restore process, and a quick Google search confirmed I wasn't the only one.

Restoring a database in Raven is an offline activity, requiring the Raven server to be down for the process to complete successfully.  To stop the service, from the \Server folder, run the command "raven.server /stop"

Stopping the service

Once the service is down, you're free to go ahead and restore your database.  This can be done from the management studio, but as we're already in the server console, run the following command "raven.server -src {BACKUP FOLDER} -dest {TARGET RESTORE FOLDER} -restore"

Restoring database

After the database has restored successfully, start the service again using the "raven.server /start" command.

Starting the service

This is where things got slightly interesting.  Others seem to get this issue on GUI versions of Windows Server so it isn't core specific (or limited to 2012R2), but attempting to open the restored database in management studio gave me this error.

Database doesn't exist error message'

A closer look revealed although the database folder had been created with all the indexes and data files, the describing document in the Raven system database didn't exist.

To resolve this, just create a new database from management studio with the same name as the one you've restored.

Creating database

Unlike SQL Server, I found Raven doesn't show you a progress bar and make the database available on completion.  Attempting to access the database straight away can generate another 503 error message like the one below.

Database not ready error

The only thing that's required here is patience.  Keep an eye on the statistics section in the bottom left hand side of the management studio screen.  When the database is fully loaded, you'll see the statistics change to represent the database contents.

From the system database, you can confirm the describing document for the restored database now exists.

Describing document

Finally, once the database has been fully loaded, you can browse any collections and documents it contains through management studio.

Browse contents

If you've read this far, I hope this guide has been helpful and will help you get past the couple of oddities I encountered without any problems.  Next time I'm going to get onto something a bit more BI relevant - configuring the SQL Replication Bundle.

I hope this was helpful - Andy Knight.

Ask Us a Question