ubuntu在本地上搭建EOS环境

EOS官方源码文档
EOS官方构建文档
目前支持的平台以及硬件要求
这里写图片描述

1 下载EOS

git clone https://github.com/eosio/eos --recursive

这个会有些耗时,需要等待段时间。

下载完成后目录结构是这样的
这里写图片描述

2 执行自动化构建脚本

./eosio_build.sh

构建成功如下
这里写图片描述
这里写图片描述

启动mongo数据库云test

~/opt/mongodb/bin/mongod -f ~/opt/mongodb/mongod.conf &

cd build
make test

运行test测试时,需要验证大概29项,要好耗时一段时间
这里写图片描述

安装可执行文件

cd build
sudo make install

创建单一测试节点

cd /eos/build/programs/nodeos
./nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin 

会看到这样的数据
这里写图片描述

nodeos

这里会报错 我们需要修改config.ini配置文件

cd ~/.local/share/eosio/nodeos/config

这里写图片描述
在 config.ini后添加如下代码:


# Enable block production with the testnet producers
producer-name = eosio
# Load the block producer plugin, so you can produce blocks
plugin = eosio::producer_plugin
# Wallet plugin
plugin = eosio::wallet_api_plugin
# As well as API and HTTP plugins
plugin = eosio::chain_api_plugin
plugin = eosio::http_plugin
# This will be used by the validation step below, to view account history
plugin = eosio::history_api_plugin

保存运行

nodeos

这里写图片描述

Docker容器

安装 Docker

docker 版本要^17.05
这里写图片描述

cd eos/Docker
sudo docker build . -t eosio/eos

这里写图片描述

在容器上启动节点

 sudo docker run --rm --name eosio -d -p 8888:8888 -p 9876:9876 -v /tmp/work:/work -v /tmp/eosio/data:/mnt/dev/data -v /tmp/eosio/config:/mnt/dev/config eosio/eos-dev  /bin/bash -c "nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::wallet_plugin --plugin eosio::producer_plugin --plugin eosio::history_plugin --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin --plugin eosio::http_plugin -d /mnt/dev/data --config-dir /mnt/dev/config --http-server-address=0.0.0.0:8888 --access-control-allow-origin=* --contracts-console"

默认情况下,所有数据都保存在 docker volume中。如果数据过时或损坏,则可以删除它:

docker inspect --format '{{ range .Mounts }}{{ .Name }} {{ end }}' nodeos
fdc265730a4f697346fa8b078c176e315b959e79365fc9cbd11f090ea0cb5cbc
docker volume rm fdc265730a4f697346fa8b078c176e315b959e79365fc9cbd11f090ea0cb5cbc

或者,可以直接将主机目录安装到容器中。

docker run --name nodeos -v /path-to-data-dir:/opt/eos/bin/data-dir -p 8888:8888 -p 9876:9876 -t eosio/eos nodeosd.sh arg1 arg2

查看链信息

 curl http://127.0.0.1:8888/v1/chain/get_info

在 docker上启动两个服务 nodeos 和 keosd

docker-compose up

After docker-compose up, two services named nodeos and keosd will be started. nodeos service will expose ports 8888 and 9876 to the host. keosd service does not expose any port to the host, it is only accessible to cleos when runing cleos is running inside the keosd container as described in “Execute cleos commands” section.

猜你喜欢

转载自blog.csdn.net/qq_27623521/article/details/80365887
今日推荐