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

installation_1.5

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

This installation was tested on this configuration : 8 vCores * 3,1 GHz / 30 GO Ram. Bitcoind is running on another server.

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.15.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.15.0.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

To improve performances, you can set a higher number of threads who will deal with the rpc request by adding a parameter rpcthreads=16.

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_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, 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.3.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

Install.

Install neo4j with this command :

apt-get update;apt-get -y install neo4j=3.3.1;apt-mark hold neo4j

note : If you want to change the location of the database on the filesystem, edit the file /etc/neo4j/neo4j.conf and change the value of the parameter dbms.directories.data.

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 and thread issues, we will set a new configuration in the setenv.sh file in the /usr/share/tomcat8/bin/ directory.

The content should be :

export CATALINA_OPTS="-server -Xms6000m -Xmx6000m -Dsun.net.client.defaultConnectTimeout=60000 -Dsun.net.client.defaultReadTimeout=60000"

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.5/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 this file 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.

Create indexes.

To improve the speed of the process, you can create indexes :

cypher-shell -u neo4j -p NEO4J_PASSWORD 'CREATE CONSTRAINT ON (n:BitcoinAddress) ASSERT n.address IS UNIQUE;'
cypher-shell -u neo4j -p NEO4J_PASSWORD 'CREATE CONSTRAINT ON (n:BitcoinBlock) ASSERT n.hash IS UNIQUE;'
cypher-shell -u neo4j -p NEO4J_PASSWORD 'CREATE CONSTRAINT ON (n:BitcoinTransaction) ASSERT n.txid IS UNIQUE;  '
cypher-shell -u neo4j -p NEO4J_PASSWORD 'CREATE INDEX ON :BitcoinBlock(height);'
cypher-shell -u neo4j -p NEO4J_PASSWORD 'CREATE INDEX ON :BitcoinTransactionOutput(txid, n);'