EventStore on Azure and Ubuntu - it's a piece of cake! #2

In the previous post we installed and started an EventStore instance. To be honest it's possible to work with it from this point with no problem. However, there're things, which I'd like to focus on a bit more. 

EventStore structure and configuration

How EventStore is structured on Linux differs somehow when compared with the Windows version. Default directories for it can be found here and I strongly recommend to read so there's no confusion. Important thing is the configuration file stored in /etc/eventstore/ and being read-only. If you'd like to edit it(e.g. to change external IP used by ES), here's the easiest way to do it using vi:

/
kamz@Ubuntu-EventStore:/$ cd etc/eventstore
kamz@Ubuntu-EventStore:/etc/eventstore$ sudo vi eventstore.conf

To edit a file simple press i. Once you're done with your changes, press Escape and :wq to save them and exit. The reason we're using sudo here is to force changes on this locked file. More detailed instruction how to use vi can be found here.

Accessing ES locally

Well, we have EventStore configured and running. What if we'd like to access it via browser. Going to your_vm_ip:2113 is not working just out of the box. Honestly, there're two possible ways:

  • port tunneling
  • using RDP

Both are quite easy to get and configure.

Using port tunneling

For the purpose of port tunneling I'm using PuTTY. The instruction is pretty simple - tunnel target :2113 port to the local port of your choice. How to do it is described here and here. Once you're done, simply go to e.g. 127.0.0.1:2113 in your browser. It should connect to the VM and open EventStore screen.

Using RDP

If you don't want to allow external access to your EventStore instance you can use RDP and manage it from within your virtual machine. If you prefer this way, make sure you are familiar with this instruction how to connect from Windows to Ubuntu using xRDP. One additional thing is needed here - since a VM in Azure is defended by network security group, which denies whole traffic, we have to allow inbound access using RDP. Here's what you have to do:

  • Go to your resource group and find Network security group resource related to your VM
  • Go to Inbound security rules
  • Add a new security rule using port TCP 3389
  • Save a new configuration

Now go to your RDP client and pass public IP of your Ubuntu VM. You should be able to see xRDP screen. Just use credentials you're using to connect to the VM and that's all - you've accessed Ubuntu's desktop. Open a browser window and go to 127.0.0.1:2113. Now you can log in and manage EventStore as you wish.

In the next post we'll try to create and connect ES cluster using multiple Ubuntu machines.

EventStore on Azure and Ubuntu - it's a piece of cake! #1

EventStore is a well known, open-sourced and a solid database designed to be the very foundations of event-driven systems. What is great about it is the fact, that it can be built against both Windows and Ubuntu systems, what widens technology stack it can be used with. If you prefer Linux solutions and would like to build an event sourced solution based on ES, there's nothing that will stop you. In this short series of posts I will present how to quickly install, configure and manage EventStore using Ubuntu VMs from Azure.

Getting VM

You can obtain Ubuntu 14.04 VM from the marketplace in Azure Portal. There's nothing special about its configuration or size - for the purpose of testing it can be whichever you like and you're comfortable with. Once you fill in all fields and provision the whole environment, we can connect to the machine and try to install the database.

Installation

To connect to the VM you need an SSH client and credentials you provided during VM installation process. I personally recommend using PuTTY in Windows environment since it's lightweight and completely free. Once you're logged in, we can start installing EventStore instance.

Firstly run following command:

/
curl -s https://packagecloud.io/install/repositories/EventStore/EventStore-OSS/script.deb.sh | sudo bash

Once you have EventStore preconfigured, you can install it:

/
sudo apt-get install eventstore-oss=3.9.3

You can choose any version you like, in this particular post I selected 3.9.3 since it was the most recent one available.

Once EventStore is installed we can run it using this command:

/
sudo service eventstore start

and use curl to sent testing event to make sure everything is all right. To make things easier, take following JSON from the documentation:

/
[
  {
    "eventId": "fbf4a1a1-b4a3-4dfe-a01f-ec52c34e16e4",
    "eventType": "event-type",
    "data": {
      "a": "1"
    }
  }
]

and use following command to send an event:

/
vi event.txt
curl -i -d @event.txt "http://127.0.0.1:2113/streams/newstream" -H "Content-Type:application/vnd.eventstore.events+json"

Note that we're using vi to quickly create events.txt file using JSON from above. When you execute the command, you should receive HTTP 201 Created response:

/
HTTP/1.1 201 Created
Access-Control-Allow-Methods: POST, DELETE, GET, OPTIONS
Access-Control-Allow-Headers: Content-Type, X-Requested-With, X-Forwarded-Host, X-PINGOTHER, Authorization, ES-LongPoll, ES-ExpectedVersion, ES-EventId, ES-EventType, ES-RequiresMaster, ES-HardDelete, ES-ResolveLinkTo
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Location, ES-Position, ES-CurrentVersion
Location: http://127.0.0.1:2113/streams/newstream/0
Server: Mono-HTTPAPI/1.0
Date: Wed, 22 Feb 2017 08:09:26 GMT
Content-Type: text/plain
Content-Length: 0
Keep-Alive: timeout=15,max=100

Note that the configuration file used by EventStore is located in /etc/eventstore/eventstore.conf and since it's read-only, you will have to use sudo command to change something in it. For now, leave it as it is.

What's next?

In the next posts I will present how to access EventStore from your local computer and what to change to be able to send and receive messages from it. We'll end this series running a simple cluster of EventStore instances on 3 different Ubuntu machines.