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

installation_3.0_bitcoin_neo4j

Stéphane Traumat edited this page Jul 4, 2018 · 3 revisions

Debian server (release 9.4).

The operation system we choosed is Debian Stretch, 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 update;apt-get -y install automake 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 openjdk-8-jdk;apt-get -y upgrade

Bitcoin core (release 0.16.x).

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

Create a user.

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

Get the sources.

cd /home/bitcoin  
git clone -b v0.16.1 https://github.com/bitcoin/bitcoin.git

Compile and install.

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

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

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

A sample bitcoin.conf file is available here.

Setup the linux service.

Now, you have to create a file named bitcoind in /etc/init.d/ with the command :

touch /etc/init.d/bitcoind

Edit this file to create your daemon or 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 restarting the server, use this command :

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

You should get a reply looking this :

{
  "chain": "main",
  "blocks": 8859,
  "headers": 506482,
  "bestblockhash": "000000001ba3e0220bbdd8e7e5ad80e28db57c2ccd798346aac2a0114c8207cb",
  "difficulty": 1,
  "mediantime": 1238140259,
  "verificationprogress": 3.071215408814337e-05,
  "chainwork": "0000000000000000000000000000000000000000000000000000229c229c229c",
  "pruned": false,
  "softforks": [
    {
      "id": "bip34",
      "version": 2,
      "reject": {
        "status": false
      }
    }, 
    {
      "id": "bip66",
      "version": 3,
      "reject": {
        "status": false
      }
    }, 
    {
      "id": "bip65",
      "version": 4,
      "reject": {
        "status": false
      }
    }
  ],
  "bip9_softforks": {
    "csv": {
      "status": "defined",
      "startTime": 1462060800,
      "timeout": 1493596800,
      "since": 0
    },
    "segwit": {
      "status": "defined",
      "startTime": 1479168000,
      "timeout": 1510704000,
      "since": 0
    }
  }
}

Neo4j (release 3.4.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=1:3.4.1;apt-mark hold neo4j

According to your needs, you can change the neo4 configuration ( /etc/neo4j/neo4j.conf ) :

  • dbms.directories.data : to set where neo4j should store data.
  • dbms.memory.pagecache.size : The amount of memory to use for mapping the store files. We advise 13000m.
  • dbms.memory.heap.initial_size : heap initial size. We advise 11000m.
  • dbms.memory.heap.max_size : heap maximal size. We advise 11000m.
  • dbms.connectors.default_listen_address : uncomment and set it to 0.0.0.0 to allow access to neo4j from outside.
  • dbms.connector.bolt.listen_address: uncomment and set it to 0.0.0.0:7687 to allow access to neo4j from outside.
  • dbms.connector.http.listen_address : uncomment and set it to 0.0.0.0:7474 to allow access to neo4j from outside.
  • dbms.connector.https.listen_address : uncomment and set it to 0.0.0.0:7473 to allow access to neo4j from outside.

Check if neo4j is running.

In the console, type service neo4j status, you should get a reponse looking like this :

● neo4j.service - Neo4j Graph Database
   Loaded: loaded (/lib/systemd/system/neo4j.service; disabled; vendor preset: enabled)
   Active: active (running) since Sun 2018-01-28 20:42:21 UTC; 3min 58s ago
 Main PID: 2397 (java)

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.

Blockchain2graph.

Create a user.

useradd -s /usr/sbin/nologin -r -m -d /home/blockchain2graph blockchain2graph

Download Blockchain2graph.

You can download Blockchain2graph with the command :

mkdir /var/blockchain2graph
wget -O /var/blockchain2graph/blockchain2graph-bitcoin-neo4j.jar https://github.com/straumat/blockchain2graph/releases/download/version-3.0/blockchain2graph-bitcoin-neo4j.jar

Setup rights.

We will change the owner of the jar

chown blockchain2graph:blockchain2graph /var/blockchain2graph/blockchain2graph-bitcoin-neo4j.jar

Create a service and set configuration.

We will now create a service to run blockchain2graph :

touch /etc/systemd/system/blockchain2graph-bitcoin-neo4j.service

Here is the content, change it acording to your configuration :

[Unit]
Description=Blockchain2graph-bitcoin-neo4j
After=syslog.target

[Service]
Environment="SPRING_DATA_NEO4J_URI=bolt://neo4j:b2g135!@localhost"
Environment="BITCOINCORE_HOSTNAME=5.196.65.205"
Environment="BITCOINCORE_PORT=8332"
Environment="BITCOINCORE_USERNAME=bitcoinrpc"
Environment="BITCOINCORE_PASSWORD=JRkDy3tgCYdmCEqY1VdfdfhTswiRva"
ExecStart=/usr/bin/java -jar /var/blockchain2graph/blockchain2graph-bitcoin-neo4j.jar SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

You can start blockchain2graph with the command : service blockchain2graph-bitcoin-neo4j start

Check if blockchain2graph is running.

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

If it's not working, check the logs by looking at /var/log/syslog.