Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Installation_1.0

Stéphane Traumat edited this page Feb 7, 2018 · 10 revisions

Debian server (release 8.7).

The operation system we choosed is Debian Jessie, you can download it here.

Some packages need to be installed in order to make blockchain2graph work. You can install them all with this command :

apt-get -y install build-essential module-assistant autoconf libssl-dev libboost-dev libboost-chrono-dev libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libboost-test-dev libboost-thread-dev git libtool shtool autogen pkg-config vim libevent-dev wget curl locate ntp htop;apt-get update;apt-get -y upgrade

Bitcoin core (release 0.14.x).

The next step is now to download Bitcoin core sources from github, build it and create a Linux daemon.

Get the sources.

cd /root  
git clone -b v0.14.1 https://github.com/bitcoin/bitcoin.git

Compile and install.

cd /root/bitcoin
./autogen.sh
./configure --without-gui --disable-wallet
make && make install

Create a system user.

useradd -s /usr/sbin/nologin -r -m -d /home/bitcoin bitcoind

Set bitcoind configuration.

Now, we have to create the configuration file for the bitcoind deamon. This file is named bitcoin.conf should be created in the directory /home/bitcoin/.bitcoin.

You can do it with the commands :

mkdir /home/bitcoin/.bitcoin
touch /home/bitcoin/.bitcoin/bitcoin.conf

Blockchain2graph needs to connect to a bitcoind node accepting REST queries and replying to getrawtransaction queries.

This is the content of the configuration file you have to setup :

rpcuser=bitcoinrpc
rpcpassword=YOUR_BITCOIND_PASSWORD
server=1
txindex=1
rest=1
rpcallowip=AN_IP_ADRESS_TO_ALLOW
rpcallowip=ANOTHER_IP_ADRESS_TO_ALLOW

Setup the linux service.

Now, you have to create a file named bitcoind in /etc/init.d/. You can copy our bitcoind service code here.

After that, you have to make it executable with the command :

chmod +x /etc/init.d/bitcoind

and finally, add it as a system init script :

update-rc.d bitcoind defaults

Check if bitcoind is running.

After starting the daemon with the command service bitcoind start, use this command :

bitcoin-cli -datadir=/home/bitcoin/ -conf=/home/bitcoin/.bitcoin/bitcoin.conf getinfo

You should get a reply looking this :

bitcoin-cli getinfo
{
 “version” : 110200,
 “protocolversion” : 70002,
 “walletversion” : 60000,
 “balance” : 0.00000000,
 “blocks” : 1504,
 “timeoffset” : 0,
 “connections” : 2,
 “proxy” : “”,
 “difficulty” : 1.00000000,
 “testnet” : false,
 “keypoololdest” : 1448293929,
 “keypoolsize” : 101,
 “paytxfee” : 0.00000000,
 “relayfee” : 0.00005000,
 “errors” : “”
}

Java (release 8.x).

Add Java 8 PPA.

To install Java in a proper way, you have to add the webupd8team Java PPA repository to your Debian by creating a file /etc/apt/sources.list.d/java-8-debian.list.

You can do it with these two commands :

echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" > /etc/apt/sources.list.d/java-8-debian.list  
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" >> /etc/apt/sources.list.d/java-8-debian.list  

Then, you have to import GPG key to validate packages before installing them :

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886

Install.

Now use the following command to install Java 8 on your Debian :

apt-get update;apt-get -y install oracle-java8-installer;apt-get -y install oracle-java8-set-default

Check Java version.

At this stage you have installed oracle Java on your Debian system. Use the following command to check that the one you installed is the default one on your system :

java -version

You should see something like that appears :

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

Create a link for defaut release.

The last step for your Java setup is to create a link to allow Tomcat8 and Neo4j deamons to find the correct Java sdk :

ln -s /usr/lib/jvm/java-8-oracle /usr/lib/jvm/default-java

Neo4j (release 3.1.x).

Add the repository.

To install Neo4j in a proper way, you have to add it the repository the list of sources with the following commands :

wget -O - https://debian.neo4j.org/neotechnology.gpg.key | apt-key add -
echo 'deb http://debian.neo4j.org/repo stable/' | tee /etc/apt/sources.list.d/neo4j.list
apt-get update

Install.

Install neo4j with this command :

apt-get install neo4j=3.1.4

Check if neo4j is running.

In the console, type neo4j status, you should get a reponse looking like this : Neo4j is already running (pid 1349).

Change database password.

To change the neo4J default password, use the command line :

curl -H "Content-Type: application/json" -X POST -d '{"password":"YOUR_NEW_PASSWORD"}' -u neo4j:neo4j http://localhost:7474/user/neo4j/password

note : wait a bit before running this command because neo4j needs some time to start.

Tomcat (release 8).

Install Tomcat.

Tomcat is included in the default Debian repositories so installing it is simple. Just type :

apt-get update;apt-get -y install tomcat8

To allow Tomcat applications to access Neo4j, we need to create a Neo4j known_hosts file the following commands :

mkdir /usr/share/tomcat8/.neo4j
touch /usr/share/tomcat8/.neo4j/known_hosts
setfacl -R -m u:tomcat8:rwx,d:u:tomcat8:rwx /usr/share/tomcat8/.neo4j/known_hosts

Change tomcat configuration.

To deal with memory issues, we will change the default memory configuration by creating the setenv.sh file in the /usr/share/tomcat8/bin/ directory.

The content should be :

export CATALINA_OPTS="-server -Xms1024m -Xmx1024m"

and restart Tomcat :

service tomcat8 restart

Check if Tomcat is running.

To check if Tomcat is running, you can type : service tomcat8 status

You should get a reply looking like this :

● tomcat8.service - LSB: Start Tomcat.
   Loaded: loaded (/etc/init.d/tomcat8)
   Active: active (running) since mer. 2016-11-16 22:32:02 CET; 26min ago
  Process: 2012 ExecStart=/etc/init.d/tomcat8 start (code=exited, status=0/SUCCESS)

Blockchain2graph.

Download Blockchain2graph.

You can download Blockchain2graph with the command :

cd /root  
wget -O blockchain2graph.war https://github.com/straumat/blockchain2graph/releases/download/version-1.0/blockchain2graph.war

Configure Blockchain2graph.

Now that we have downloaded blockchain2graph.war, we have to update the blockchain2graph configuration file.

First step, extract the default configuration from the war :

jar xvf blockchain2graph.war WEB-INF/classes/application.properties

Second step, edit it with your favorite text editor :

vim WEB-INF/classes/application.properties

And change the configuration parameters according to your needs :

  • blockchain2graph.address : Your server IP Address (used by the console).
  • blockchain2graph.port : Your server port (used by the console).
  • blockchain2graph.date.format : Date format used to display date in the console.
  • bitcoind.hostname : Bitcoind server ip to connect to.
  • bitcoind.port : Bitcoind server port to connect to.
  • bitcoind.username : Bitcoind username to connect to.
  • bitcoind.password : Bitcoind password to connect to.
  • spring.data.neo4j.uri : Connection URI to connect to the neo4j database (example : bolt://neo4j:b2g@localhost).

Last step, put it back into the blockchain2graph war with the command :

jar -uf blockchain2graph.war WEB-INF/classes/application.properties

Deploy blockchain2graph in Tomcat.

To deploy the war, you just have to copy it to the tomcat webapps directory :

mv blockchain2graph.war /var/lib/tomcat8/webapps

Check if blockchain2graph is running.

You can now connect to the blockchain2graph console at : http://YOUR_IP:YOUR_PORT/blockchain2graph/.

If it's not working, check the tomcat logs by looking at the file /var/lib/tomcat8/logs/catalina.out.

Index creation.

To improve performances, connect to neo4j with the command cypher-shell.

Then turn the following commands :

CREATE CONSTRAINT ON (n:BitcoinBlock) ASSERT n.height IS UNIQUE;
CREATE CONSTRAINT ON (n:BitcoinBlock) ASSERT n.hash IS UNIQUE;
CREATE CONSTRAINT ON (n:BitcoinTransaction) ASSERT n.txid IS UNIQUE;
CREATE CONSTRAINT ON (n:BitcoinAddress) ASSERT n.address IS UNIQUE;

You can check if indexes were well created with the command curl http://localhost:7474/db/data/schema/index/ -u neo4j:PASSWORD