Public chain development combat: local environment preparation virtualbox articles

Originally, I wanted to write a few articles about the environment configuration of each public chain in the local development, but I still feel that I should write down the most basic environment configuration first, and I must first improve the tool for the good work, first improve the mastery of virtualbox. It is necessary to build a development environment to simulate the production environment locally, especially for blockchain developers, because it is often necessary to simulate multiple machines to interact;

Many people may say that it is not necessary because, for example:

Bitcoin core has regtest mode, so you can run a single node;

ETH has ganache and truffle dev can simulate the private chain with software simulation;

EOS can use docker composer to open multiple docker instances to interact;

But for a complete project, the chain operation is only a part of it, we definitely need a lot of parts of the chain operation, unless your project is running purely on the chain, generally the project on the chain is often in a few The interaction between different chains, such as ETH and IPFS, the development environment also requires multiple nodes. For example, the hyperledger also needs to run peer nodes, orderer nodes and other nodes. Here I mainly say that the chain operation is usually required. Such as traditional db, web api, etc.

The host machine for the demo here is windows, then, virtualbox version 6.0,

The usual requirement is that the database and background services run on the intranet, and then the blockchain nodes and website programs can communicate with the external network, and of course communicate with the intranet.

The following figure compares the capabilities of several virtual modes of virtualbox:

For example, one virtual machine may contain a web server and a second one a database, and since they are extracted from the virtualbox document: Host-only networking is sometimes useful for preconfigured virtual appliances, where multiple virtual machines are shipped together and designed to cooperate. A second, bridged, network would then connect the web server to the outside world to serve data to, the the Outside world cannot connect to the database.

So we choose the following configuration: * vb1 running database and background services: host-only mode * vb2 running blockchain nodes and website services: bridged mode and host-only mode

Our expected result is:

The host machine can communicate with vb1 and vb2, through ssh (default port 22, recommended for winscp for windows users), vb1 can communicate with vb2, or communicate with host machine vb2 can communicate with everything. Including vb2/host/external network

Build

First create a hostonly adpter in virtualbox,

File=>host network manager

>>>vb1

>>>vb2

As shown above, sometimes dhcp server is inexplicable and does not work, can not assign ip to bridged mode, the specific reason I did not study in depth, this problem can be manually fixed: `dhclient eth0` or you can set static ip “` vim /etc /network/interfaces auto lo iface lo inet loopback

Auto eth0 iface eth0 inet static address yourip netmask 255.255.255.0 gateway your gateway “`

2. Common commands

“` ifconfig ip route show route -n cat /etc/network/interfaces /etc/init.d/networking restart service network-manager restart ifdown eth0 ifup eth0 dhclient eth0 Ifconfig eth0 [ip] netmask 255.255.255.0 up route add default Gw [gateway] eth0 ip route add default via [gateway] dev eth0 “`

3. More exploration

1) We can even turn vb2 into a router, which can do a lot of interesting things, such as monitoring various packets of vb1.

2) Sometimes we will encounter insufficient disk space, for example, I have encountered the lack of disk space due to running multiple docker, and the blockchain node synchronization data leads to insufficient space, if you do not want to come back again If you want to resize: * Install os before resize, one step: `VBoxVBoxManage.exe modifyhd your.vdi –resize [targetsize]`

* Resize after installing os, slightly troublesome, pro test available: First use the above steps to expand the vdi size, and then use gparted for partition expansion, specific reference http://derekmolloy.ie/resize-a-virtualbox-disk/

Main reference material: https://www.virtualbox.org/manual/ch06.html

We will continue to update Blocking; if you have any questions or suggestions, please contact us!

Share:

Was this article helpful?

93 out of 132 found this helpful

Discover more

Market

Which exchanges and currencies are in the process of brushing? New report decrypts the real trading situation of the encryption market

BTI's algorithm connects to the exchange through its public API and websocket. The transaction is analyzed and t...

Market

Exclusive Interview with Yuga Labs We are more like Tencent of Web3, constantly changing the rules of NFT games

During the Token2049 conference, BlockBeats reporter had a conversation with Daniel Alegre, the CEO of Yuga Labs, dis...

Market

Semafor The US Department of Justice is considering fraud charges against Binance, but is concerned about a FTX-style run in the market.

Insiders say that federal prosecutors are concerned that if they were to prosecute Binance, it could lead to a run on...

Blockchain

New gameplay? A rubbish currency exchange where everyone can use the currency

BlockBeats learned that the Shitcoin.market was officially launched on August 14. This is a decentralized trading pla...

Blockchain

The compliance exchange is about to appear in Singapore?

On December 18, 2019, the official website of the Monetary Authority of Singapore (hereinafter referred to as "M...

Blockchain

Bloomberg Interview with He Yi: My relationship with CZ is that of a mentor, friend, and spouse.

He Yi referred to Zhao as a comrade-in-arms and also as a college roommate. She said that their relationship only beg...