Deploying JanusGraph on Alibaba Cloud ECS

Prerequisite: Elastic Compute Service (ECS) Instance

First, we’ll require an up and running ECS instance. This article assumes one configured with CentOS version 7.4. If you haven’t already, sign up on Alibaba Cloud. You can use this link to get $300 worth of free trial products.

Preparing the Server

When I’m the only tenant on a CentOS server, one of the first things I do is to disable selinux — permanently. With it on, you may sometimes run into weird bugs here and there that are a pain to debug. I normally use this command

sudo sed -i 's/enforcing/disabled/g' /etc/selinux/config /etc/selinux/config
sudo yum -y install wget
sudo wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -Uvh epel-release-latest-7.noarch.rpm
sudo yum -y install git zip unzip
sudo yum -y update
sudo shutdown -r now

Installing & Configuring JanusGraph Dependencies

JanusGraph relies on other database technologies in order to achieve its graph structure and massive scalability. These are typically referred to as storage backends and (optional) index backends. For storage backends you can choose one from either Apache Cassandra? (or its compatible ScyllaDB), Apache HBase?, Google Cloud Bigtable or Oracle BerkeleyDB. For index backends which power JanusGraph’s support for geo, numeric range, and full-text search, you can choose one from either ElasticSearch?, Apache Solr? or Apache Lucene?.

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearchsudo vi /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
sudo yum install -y java elasticsearch
sudo vi /etc/yum.repos.d/cassandra.repo
[cassandra-3.x]
name=Apache Cassandra
baseurl=https://www.apache.org/dist/cassandra/redhat/311x/
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.apache.org/dist/cassandra/KEYS
sudo yum install -y Cassandra
sudo vi /etc/cassandra/default.conf/cassandra.yaml
start_rpc: false
start_rpc: true
sudo systemctl daemon-reload
sudo chkconfig elasticsearch on
sudo chkconfig cassandra on
sudo service cassandra start
sudo service elasticsearch start
sudo service elasticsearch status
sudo service cassandra status

Installing JanusGraph

Installing and configuring JanusGraph takes very few steps. First download the latest zip file from the official GitHub repository.

wget https://github.com/JanusGraph/janusgraph/releases/download/v0.3.0/janusgraph-0.3.0-hadoop2.zip
unzip janusgraph-0.3.0-hadoop2.zip
cd janusgraph-0.3.0-hadoop2
bin/gremlin-server.sh
bin/gremlin.sh
:plugin use tinkerpop.credentials
graph = TinkerGraph.open()
graph.createIndex("username",Vertex.class)
credentials = credentials(graph)
credentials.createUser("myusername","mYpa$$word!")
credentials.findUser("myusername ").properties()
credentials.countUsers()
graph.io(IoCore.gryo()).writeGraph("data/credentials.kryo")
:quit
vi conf/tinkergraph-credentials.properties
gremlin.graph=org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
gremlin.tinkergraph.vertexIdManager=LONG
gremlin.tinkergraph.graphLocation=data/credentials.kryo
gremlin.tinkergraph.graphFormat=gryo
cp conf/gremlin-server/gremlin-server.yaml conf/gremlin-server/socket-gremlin-server.yamlvi conf/gremlin-server/socket-gremlin-server.yaml
authentication: {
className: org.apache.tinkerpop.gremlin.server.auth.SimpleAuthenticator,
config: {
credentialsDb: conf/tinkergraph-credentials.properties}}
ssl: {
enabled: true}
bin/gremlin-server.sh ./conf/gremlin-server/socket-gremlin-server.yaml
sudo vi /etc/systemd/system/janusgraph.service
[Unit]
Description = JanusGraph Server
After = cassandra.service elasticsearch.service
[Service]
User=root
ExecStart = /home/root/janusgraph-0.3.0-hadoop2/bin/gremlin-server.sh /home/root/janusgraph-0.3.0-hadoop2/conf/gremlin-server/socket-gremlin-server.yaml
TimeoutStartSec=60
[Install]
WantedBy = multi-user.target
sudo systemctl daemon-reload
sudo chkconfig janusgraph on
sudo service janusgraph start
sudo service janusgraph status

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com