ubuntu在本地上搭建EOS環境
阿新 • • 發佈:2018-12-10
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.