在Ubuntu16.04 上搭建EOS 環(huán)境

本文主要介紹如何在 Ubuntu 16.04 上搭建 EOS 環(huán)境
(噴血吐槽: MMP,從來(lái)沒(méi)有一行代碼沒(méi)寫,搭個(gè)環(huán)境搭了一個(gè)禮拜...)
參考文章:
http://www.itdecent.cn/p/47ea4d11d997
http://www.itdecent.cn/p/c47091d69dde

搭建環(huán)境前注意事項(xiàng):

虛擬機(jī)要求分配至少 8GB 內(nèi)存,貌似是 至少 20GB 可用磁盤空間(記不太清了,最好多分配點(diǎn)), 至于對(duì)已有的虛擬機(jī) 如何擴(kuò)大內(nèi)存或磁盤空間,請(qǐng)自行百度

環(huán)境搭建

  1. 下載 EOS 代碼
git clone https://github.com/EOSIO/eos.git -b DAWN-2018-02-14 --recursive

下載的版本應(yīng)該是DAWN-2018-02-14版
加入--recursive參數(shù),否則EOS關(guān)聯(lián)的子項(xiàng)目沒(méi)法下載

  1. 自動(dòng)編譯
cd eos
./build.sh ubuntu full 

編譯的時(shí)間巨長(zhǎng)... 我的虛擬機(jī)裝在SSD上都平均至少編譯2+小時(shí)....

./build.sh ubuntu 后面可以跟一個(gè)參數(shù),默認(rèn)值為 full , 也可以是 build。
full用于第一次編譯或完全重新編譯,它會(huì)重新嘗試編譯安裝依賴項(xiàng).
build是僅編譯EOS代碼,在變更代碼后可以使用以下命令重新編譯。

./build.sh ubuntu build
  1. 編譯遇到的錯(cuò)誤


    image.png

google之后,找到 解決方案

解決過(guò)程如下:

  1. 打開 eos/plugins/db_plugin/CMakeLists.txt(在 master 分支上對(duì)應(yīng)的地址為 eos/plugins/mongo_db_plugin/CMakeLists.txt )
  2. 在文件中找到 下面對(duì)應(yīng)的 減號(hào) ‘-‘ 行: 表示將該行從文件中刪除 或者注釋掉 ,加號(hào)'+' 行表示在文件中對(duì)應(yīng)位置 添加相應(yīng)的行
@@ -20,14 +20,22 @@ if (libmongoc-1.0_FOUND)

     find_package(libbsoncxx REQUIRED)
     message(STATUS "Found bsoncxx headers: ${LIBBSONCXX_INCLUDE_DIRS}")
-    find_library(EOS_LIBBSONCXX ${LIBBSONCXX_LIBRARIES}
-                 PATHS ${LIBBSONCXX_LIBRARY_DIRS} NO_DEFAULT_PATH)
+    if((LIBBSONCXX_VERSION_MAJOR LESS 3) OR ((LIBBSONCXX_VERSION_MAJOR EQUAL 3) AND (LIBBSONCXX_VERSION_MINOR LESS 2)))
+        find_library(EOS_LIBBSONCXX ${LIBBSONCXX_LIBRARIES}
+          PATHS ${LIBBSONCXX_LIBRARY_DIRS} NO_DEFAULT_PATH)
+      else()
+        set(EOS_LIBBSONCXX ${LIBBSONCXX_LIBRARIES})
+    endif()
     message(STATUS "Found bsoncxx library: ${EOS_LIBBSONCXX}")

     find_package(libmongocxx REQUIRED)
     message(STATUS "Found mongocxx headers: ${LIBMONGOCXX_INCLUDE_DIRS}")
-    find_library(EOS_LIBMONGOCXX ${LIBMONGOCXX_LIBRARIES}
-                 PATHS ${LIBMONGOCXX_LIBRARY_DIRS} NO_DEFAULT_PATH)
+    if((LIBMONGOCXX_VERSION_MAJOR LESS 3) OR ((LIBMONGOCXX_VERSION_MAJOR EQUAL 3) AND (LIBMONGOCXX_VERSION_MINOR LESS 2)))
+        find_library(EOS_LIBMONGOCXX ${LIBMONGOCXX_LIBRARIES}
+          PATHS ${LIBMONGOCXX_LIBRARY_DIRS} NO_DEFAULT_PATH)
+      else()
+        set(EOS_LIBMONGOCXX ${LIBMONGOCXX_LIBRARIES})
+    endif()
     message(STATUS "Found mongocxx library: ${EOS_LIBMONGOCXX}")
  1. 修改完重新進(jìn)行編譯,進(jìn)入 eos 目錄運(yùn)行一下命令
./build.sh ubuntu build

等待編譯成功即可

  1. 最后一步
cd build
make install

該命令會(huì)將編譯好的可執(zhí)行文件、頭文件、庫(kù)文件和模板文件安裝到build下的install目錄下,在該目錄的bin下有所有編譯好的命令,包括eosd、eosc、eoscpp等等。

創(chuàng)建并啟動(dòng)測(cè)試網(wǎng)絡(luò)單節(jié)點(diǎn)

教程
執(zhí)行命令:

cd build/programs/eosd
./eosd 

直接使用命令執(zhí)行./eosd 會(huì)得到一個(gè)錯(cuò)誤(注意這一步是要做的,因?yàn)?code>eosd會(huì)在當(dāng)前目錄( eos/build/programs/eosd)產(chǎn)生一個(gè)data-dir的目錄。 如果沒(méi)有報(bào)錯(cuò),始終沒(méi)有停止,使用ctrl+c 停掉 eosd
進(jìn)入 data-dir目錄修改 config.ini

cd data-dir
sudo gedit config.ini

通過(guò)查找以下 屬性名,找到對(duì)應(yīng)的位置進(jìn)行設(shè)置, 注意去掉注釋(前面有# 號(hào)的去掉# 號(hào))

  1. genesis-json 設(shè)置為 eos 目錄下的 genesis.json 文件所在路徑,在我的系統(tǒng)中路徑為 /home/ethan/develop/blockchain/eos
genesis-json = /home/ethan/develop/blockchain/eos
  1. enable-stale-production 設(shè)置為 true
enable-stale-production = true
  1. 添加以下到文件中
producer-name = inita
producer-name = initb
producer-name = initc
producer-name = initd
producer-name = inite
producer-name = initf
producer-name = initg
producer-name = inith
producer-name = initi
producer-name = initj
producer-name = initk
producer-name = initl
producer-name = initm
producer-name = initn
producer-name = inito
producer-name = initp
producer-name = initq
producer-name = initr
producer-name = inits
producer-name = initt
producer-name = initu
# 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

配置好之后,保存,進(jìn)入eos/build/programs/eosd 目錄下,重新執(zhí)行 ./eosd, 如果報(bào)錯(cuò) can not run eosd after building:unable to find genesis file, 表示genesis.json文件未配置成功,檢查注釋是否去掉或者 路徑是否正確.

執(zhí)行成功后,如圖所示:


image.png

參考文件:

# Load the testnet genesis state, which creates some initial block producers with the default key
genesis-json = /path/to/eos/source/genesis.json
 # Enable production on a stale chain, since a single-node test chain is pretty much always stale
enable-stale-production = true
# Enable block production with the testnet producers
producer-name = inita
producer-name = initb
producer-name = initc
producer-name = initd
producer-name = inite
producer-name = initf
producer-name = initg
producer-name = inith
producer-name = initi
producer-name = initj
producer-name = initk
producer-name = initl
producer-name = initm
producer-name = initn
producer-name = inito
producer-name = initp
producer-name = initq
producer-name = initr
producer-name = inits
producer-name = initt
producer-name = initu
# 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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • CMake學(xué)習(xí) 本篇分享一下有關(guān)CMake的一些學(xué)習(xí)心得以及相關(guān)使用。 本文目錄如下: [1、CMake介紹] [...
    AlphaGL閱讀 12,431評(píng)論 11 79
  • 1. 賬戶與錢包1.1 創(chuàng)造并管理錢包1.2 生成EOS Keys并導(dǎo)入1.3 備份您的錢包1.4 創(chuàng)建賬戶 2....
    cenkai88閱讀 4,145評(píng)論 1 7
  • 1 EOS智能合約的介紹1.1 所需背景知識(shí)1.2 EOS智能合約基礎(chǔ)知識(shí)1.3 技術(shù)局限性 2 智能合約文件2....
    cenkai88閱讀 30,952評(píng)論 5 28
  • 1 獲取代碼 2 構(gòu)建EOS2.1 自動(dòng)構(gòu)建2.1.1 Ubuntu 16.102.1.2 MacOS Sierr...
    cenkai88閱讀 1,223評(píng)論 0 0
  • 雨天微涼,隨心溫故。 一葉落,而知天下秋。人生為人,是因有思想,有人因思想敏銳而陷入痛苦,有人因獨(dú)具精神而力量過(guò)人...
    養(yǎng)游標(biāo)余閱讀 872評(píng)論 1 2

友情鏈接更多精彩內(nèi)容