How I Struggled With Usergrid, Cassandra, and Elasticsearch
Installing Usergrid
You’d better RTFM and consider my story not as a tutorial, but as a set of comments on my adventures with that manual in June of 2017.
The Usergrid Stack is a Java EE web application that runs on Tomcat and uses the Cassandra database for storage and the ElasticSearch search engine for queries.
Before running the Usergrid on Tomcat, you’ll start by setting up the database and search engine nodes.
Installing Cassandra
First of all, you’ll need Cassandra.
For storage purposes, I set up a separate Ubuntu instance that will become a Cassandra single node cluster.
The setup is simple. It's described in Cassandra's official docs or in digital ocean tutorials. They even look code-hipster-friendly!
Installing Elasticsearch
The next step is Elastic Search
And again, I used Digital Ocean tutorials
Installing Tomcat
The same thing with Tomcat. Used the following tutorial
Running Usergrid with Cassandra
Usergrid seems to need Tomcat 7 or later that’s why I decided to try 8 and see what will happen. I immediately faced a problem with the Usergrid config.
It seemed not to pick up the config file usergrid-deployment.propertiesduring
deployment from Tomcat.
No matter if I put them where docs said or followed various advice from the internet. It was not connecting either to Elasticsearch or to Cassandra.
Rebuilding Usergrid From Source
There were several posts on the internet concerning this problem and a couple of possible solutions:
- Build from sources yourself and Usergrid may begin to pick up configs correctly
- Build from sources yourself and replace the default config file.
God bless java developers, building from sources wasn’t painful! Except for 4 lines that were not mentioned in building docs:
cd ~\usergrid\sdks\javamvn installcd ..\..\stackmvn install -DskipTests=true
Well.
A more detailed look at logs showed that it actually did pick up configs if they were in …./tomcat/lib/ even before my rebuilds.
In my case, the Cassandra node and Usergrid app were running on different instances, and after more logs smoking it turned out that the problem was in Cassandra configs and its bind address.
But nevertheless, I learned how to build Usergrid and now it was time for taking off!
Downgrading Tomcat
However, Usergrid couldn’t start under Tomcat and I decided to try wiping Tomcat8 and try Tomcat7.
Finally, It worked.
Downgrading Elasticsearch
The next problem was in Elasticsearch. Logs showed an exception on connection attempts. I reinstalled the same version of ES that was in Usergrid docs : 1.7.2 instead of the newest 5.4.x.
And it finally worked!
Now I possibly had the best backend for my apps in the whole world.
Hosting
This team of Java Usergrid Monster with Cassandra seems to be rather hungry.
Thanks to my previous season’s algo-trading project I had a heritage, consisting of a dedicated instance with 64 GB of RAM, a huge SSD, and a powerful CPU.
It has been a good bargain one day, so it’s pretty sorrowful for me just to let it go. I decided to utilize it for my later adventures.
Virtualization
I’ve already had a virtualization setup running that I decided to use.
It give me have more or less separated virtual hosts, living on one physical instance, and share resources between them in an automatic or manual manner.
Previously, that setup fitted all my needs like a charm.
- I could guarantee RAM resources for more critical processes.
- I could create new hosts with limited access rights and even share them with other people. I was using this option for creating brokerage account login instances that were running on Ubuntu with GUI. For Research, trading algorithms, and data storage I was using GUI-less *nix instances.
ESXi - Not Recommended
I’ve spent some time on ESXi hypervisor and that was pretty unpleasant.
It turned out to be just one more *nix-based hypervisor and, unfortunately, hardware-fastidious. I couldn’t use the up-to-date version of it because my network card hardware just wasn’t supported in the latest versions. ESXi also doesn’t support network routing, so I had to set up a separate virtual host that routed traffic to other virtual hosts. So much pain.
Proxmox - Recommended
Then I moved to Proxmox VE and that was great.
If you are suddenly diving into that special kind of hipster-developer hell, I strongly recommend hetzner manuals and this special great manual that describes how to configure the network for virtual hosts behind NAT with ports forwarding and DHCP. That was enough to set up everything and saved me weeks of googling.
The pros and cons of having your own host compared to AWS or digital ocean are obvious.
Anyway, it’s a pretty cool exercise with a rather satisfying aftertaste, when everything works at last.
Comments