How to install private blockchain on multichain.

in #blockchain7 years ago (edited)

I have written this article just for learning purpose. It gives you the step by step process to install private blockchain on multichain. I have used Oracle VM Virtual Box Manager and two Ubuntu 16.04 LTS operating systems for the practical.

image01.jpg

Blockchain and Multichain

Blockchain is the collection of the blocks where all blocks are linked together like a chain. It is nothing but a database where we can only append but edit and delete are not allowed. This is currently very fast-growing technology because of the good concept behind it in this modern technology.

Multichain is a platform for the creation and deployment of private blockchains, either within or between organizations. It has derived from Bitcoin core software and hence it is compatible with Bitcoin ecosystem.

Installing Multichain

Let’s start both Ubuntu virtual machines and follow the steps below.

STEP 1:

We need to run following commands on both machines. This will download multichain-1.0.3.tar.gz and unzip and copy.

cd /tmp
wget https://www.multichain.com/download/multichain-1.0.3.tar.gz 
tar -xvzf multichain-1.0.3.tar.gz
cd multichain-1.0.3
sudo mv multichaind multichain-cli multichain-util /usr/local/bin

image02.jpg

STEP 2: IP address configuration on both system

We need to make sure each VM node will have different IP address. If we clone same VM, it will have the same local host IPs. In that situation, we need to change the Mac address of all or some nodes so that it gives different IP addresses. It has been described in following sub steps.

  • Go the Oracle VM VirtualBox Manager > File Menu > Host Network Manager (Ctrl + W). Click create new Host Network Manager. We are going to use this new Host Network. Please note the Adapter IPs and DHCP IP addresses.

Network Adapter IP Address
image03.jpg

DHCP Server IPs
image04.jpg

  • Shutdown all VMs. Let’s go back to Oracle VM Virtual Manager window and change Mac address of network card. You might need to do this step for all other nodes except the one. I am using only two nodes that is why I need to change in only on first node.

  • To change Mac Address of Network card, go to Oracle VM Virtual Manager > Right click on VM1 > Settings > Network > Adapter2 and make sure some fields are same as below

Attached to: Host-only Adapter
Name: VirtualBox Host-Only Ethernet Adapter #2
Mac Address: Newly generated Mac Address (Click small Refresh icon to change Mac Address)

image05.jpg

  • After we have configured the IP settings, check if ssh is installed in both the VMs. SSH (Secure Shell) is a protocol used to securely log onto remote systems. It is the most common way to access remote Linux and Unix-like servers. If ssh is not installed, run the following command:
sudo apt-get install openssh-server

sudo service ssh status 
  • Also, check for the status of firewall. If it is active, disable it.
sudo ufw status 

sudo ufw disable 
  • Check the IP address of VM1. In my case, the host only driver is enp0s8 and its IP is 192.168.154.3. In your system, it might be different IP address.
ifconfig

image06.jpg

  • Check IP of VM2. Here I found enp0s8 and IP is 192.168.154.5 that is different IP than VM1
ifconfig

image07.jpg

  • Execute the following command in the terminal of the first machine (VM1):
ssh 192.168.136.5   (This address is VM2 IP address)

image08.jpg

STEP 3: Creating a blockchain on the first server

First, we will create a new blockchain named rmchain01 (you can name your blockchain whatever you want). On first server, run below command

multichain-util create rmchain01

image09.jpg

cat ~/.multichain/rmchain01/params.dat             (To view the blockchain's default settings)

nano ~/.multichain/rmchain01/params.dat            (To make change in params.dat, run the following command)
  • Now let’s change some parameters and save the file.

Chain description = Raj multichain for learning
Anyone-can-connect = true
Initial-block-reward = 2562400
Minimum relay fee = 130

image10.jpg

  • To initialize the blockchain, including mining the genesis block, run following command from VM1
multichaind rmchain01 -daemon

image11.jpg

  • Above command starts the server and the genesis block will be found. It gives now the node address that others can connect to this chain. Make a note of this node address. In the picture above, it is [email protected]:9713 or [email protected]:9713

STEP 4: Connecting to the blockchain

Now let’s connect to this blockchain from second server VM2 using following command.

multichaind [email protected]:9713

image12.jpg

  • If there is an error, please connect the VM1 server from VM2 running following command
ssh [VM1 IP address] (192.168.154.3)
  • Blockchain successfully initialized and it asked to grant access to specific address to be connected. Back on the first server VM1, add connection permissions for this address:
multichain-cli rmchain01 grant 1QSLReWGypkZ5VhTpBXMTJRrWM9Fax9azLf6jN connect

image13.jpg

  • Now try reconnecting again from the second server:
multichaind rmchain01 -daemon

This shows now second node VM2 has started.

MultiChain interactive mode

We can use Interactive mode so that we don’t need to type enter multichain-cli rmchain01 every time.

multichain-cli rmchain01

Conclusions:

This is the simple example for installing private blockchain on multichain just using two nodes. We can add as much nodes as we need. Only we need to connect to multichain (here rmchain01) from each node and grant permissions to address for successfully connection.

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.030
BTC 68180.36
ETH 2642.05
USDT 1.00
SBD 2.70