Tuesday, August 27, 2019

Deploy Oracle Blockchain SDK on Oracle Cloud Infrastructure

[EDITED JUNE-18-2020, UPDATE TO INSTALL DOCKER, WITH SPECIAL THANKS TO MATHIJS KEMP]

In my previous post I described how to write a chaincode for Oracle Blockchain Cloud Service. Sometimes you don't have access to the blockchain cloud service, or you want to test your blockchain locally without deploying it to your production instance.

For that use case, there is good news: you can deploy it on Oracle Cloud Infrastructure.

To make this work you need to do the following:

  1. Create a compartment for your blockchain (for example SDKBLOCKCHAIN)
  2. Create a public/private key pair
  3. Create a VCN 
  4. Create a compute instance
  5. Install docker
  6. Build the SDK
  7. Create blockchain instance (founder)

Create the VCN

see https://docs.cloud.oracle.com/iaas/Content/Network/Tasks/managingVCNs.htm for a detailed explanation of this service in Oracle Cloud Infrastructure.

For this purpose, we create a VCN and related resources. 

create VCN dialog in Oracle Cloud Infrastructure





















Next we open up the ports for this VCN so the blockchain console ports are accessible from the internet

  • Click on security lists
  • Click on the default security list
  • Make sure the provisioning page is accessible from the internet by opening port 3000
  • Make sure that 500 ports are accessible from the internet (the blockchain SDK will take up to 500 ports)
Ingress rule for ports of Blockchain Console

















The list of rules should look like this:

List of Ingress rules for SDK VCN















Create the Compute instance

Create a compute instance that complies with the following values:

AttributeValueRemark
Linux Version7.3or higher
Linux kernel3.10or higher
RAM4GBor higher
Storage30GBbuild.sh -d <> >=12GB Ensure there's enough space to unpack the package.Workspace
build.sh -w [] >=5GB Workspace is relating to the transaction
volume. For a clean installation, at least 5G of free space is
recommended./var/lib >=10GB For a clean installation, Oracle
Blockchain Platform SDK Docker images consume approximately 8GB /var/lib
space.
CPU2or higher
hostname[compute instance].[subnet].[dns vcn]internal FDQN
IPxxx.xx.xx.xxxpublic IP of your instance

Set the timezone TZ variable

Make sure that you set the TZ variable in your profile, otherwise you will get an error when provisioning the blockchain instance.

  • vi .bash_profile file
  •  Add  TZ='Europe/Amsterdam'; export TZ to the file
  • Save and quit (wq)
  •  Log out
  • Log in

Disable the firewall


Check if the firewall is running: sudo firewall-cmd --state
running
If it is running, stop it:
sudo systemctl disable firewalld
run the command again: sudo firewall-cmd --state
not running

You can of course update the firewall instead of disabling it, I was too lazy to type that up today 😁

Install Docker

  1. Execute the following commands to install some required packages:

    sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    sudo yum install -y yum-utils device-mapper-persistent-data lvm2
  2. Add the repository

    sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  3. Install the docker community edition

    sudo yum install docker-ce docker-ce-cli containerd.io
  4. Start docker and enable the start of docker on boot

    sudo systemctl enable --now docker.service
  5. Check the version of docker

    sudo docker version

    Run hello world to see if docker is installed correctly

    docker run hello-world


Build the Instance

Now we are ready to install the SDK

  • Download it from the Oracle website 
  • Unzip to /usr/local/bcssdk
  • Run sudo ./build.sh  This will run it with all the default:

OptionAttributeValue
-dpackage directory/usr/local/bcssdk
-wprovision workspace directory~/obcs_worksapce
-pprovision console port3000

Create Instance


  • Open the console: http://[IP ADDRESS]:3000
  • Chose a username and password for your provisioning application and click ok
  • This opens the console and you can create a founder with the following attributes:
AttributeValue
Instance namename you picked
host nameinternal FQND
start portport you opened in ingress
founderyes
authorizationyes

The username password will be set to admin/Welcome1 when you check the "Authorization" box. The result can be seen below

Picture shows the values of the created instance
Provision instance after building the SDK

Finally

Click on the name. This will open a browser, but it will say "not found". Replace the FQDN with the IP address, and leave the port.

When you do that, it warns about the certificate. Accept that and it prompts for username password.
Login using admin/Welcome1 and you will see your blockchain console!

http://[IP ADDRESS]:21003

Blockchain console after creating the instance














Happy coding 😀

No comments:

Post a Comment