Tuesday, August 27, 2019

Deploy Oracle Blockchain SDK on Oracle Cloud Infrastructure

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

First edit the Docker yum Repository:
$ sudo tee /etc/yum.repos.d/docker.repo <<-EOF
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/oraclelinux/7
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF


Then Install the Docker Engine:
$sudo yum install docker-engine-17.05.0.ce


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