-
Notifications
You must be signed in to change notification settings - Fork 32
Installation_1.0
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
The next step is now to download Bitcoin core sources from github, build it and create a Linux daemon.
cd /root
git clone -b v0.14.1 https://github.com/bitcoin/bitcoin.git
cd /root/bitcoin
./autogen.sh
./configure --without-gui --disable-wallet
make && make install
useradd -s /usr/sbin/nologin -r -m -d /home/bitcoin bitcoind
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
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
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” : “”
}
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
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
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)
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
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 neo4j with this command :
apt-get install neo4j=3.1.4
In the console, type neo4j status
, you should get a reponse looking like this : Neo4j is already running (pid 1349).
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 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
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
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)
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
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
To deploy the war, you just have to copy it to the tomcat webapps directory :
mv blockchain2graph.war /var/lib/tomcat8/webapps
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
.
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