在Ubuntu中安装EOS

Linux大全评论4K views阅读模式

一、EOS公链

2018年6月3日,Block.one宣布EOSIO 1.0正式发布。
EOS主网(eosforce.io)已于6月15日正式上线。

EOS是Block.One公司开发的一款超高性能的类操作系统区块链,其设计目标是:

  • 支持大量用户,可能是上亿级别的用户
  • 消除手续费(可以免费使用)
  • 超高性能(支持百万级TPS)
  • 具备横向和纵向性能扩展能力

项目的代码库:https://github.com/EOSIO/
项目的wiki地址:https://github.com/EOSIO/eos/wiki

二、EOS团队

EOS的创始团队是Block.One公司
CEO:Brendan Blumer 一个持续的成功创业者2001年至今创建过多家成功的企业,2017年成立了BlockOne。
CTO:Dan Larimer 由于其在github上的名字是ByteMaster,所以江湖人称BM,开发过BTS、Steemit这两个经过长时间验证的成功区块链项目。
EOS官网:https://eos.io/
 BlockOne公司官网:http://www.block.one/
投资方:Inblockchain、Blockchain Capital、FenbushiVC等(来源于官网)

三、EOS代币

市面上流通的EOS代币最初是基于以太坊发行的ERC20代币,代号为EOS,目前通过将以太坊token映射到EOS主网,可以兑换成主网的真正EOS Token。

四、EOS代币如何增值?

跟其他Token不同,EOS代币代表的是是EOS主网资源的拥有权,也就是说只要你持有部分EOS,那么EOS主网的部分资源理论上就永远属于你,这也是为什么EOS区块链能做到免费给用户提供服务的原因。EOS是一个为DApp而生的超高性能公链,越往后发展上面的应用也就会越多,当EOS网络上的应用越多时,EOS的主网资源就会越宝贵,这时候EOS代币就会越值钱。
 目前EOS代币的价格约55元人民币左右,流通市值约365亿人民币。

五、常用资源

https://eosflare.io/ EOS区块链浏览器(对应以太坊的https://etherscan.io/)
https://block.cc/coin/eos 查看区块链信息

前言

本文以eosio_build.sh官方脚本的方式在Ubuntu 18.04 LTS Desktop版+VMWare10环境下安装EOS最新版本(2018/07/01),根目录为用户家目录~/,克隆完EOS对应的目录为~/eos,下一篇将介绍以Docker的方式来安装EOS(推荐学习下一篇)。

一、需要的软硬件环境

1、软件

以下为官方推荐的系统环境:

  • CentOS 7
  • Ubuntu 16.04 LTS (Ubuntu 16.10 推荐)
  • Ubuntu 18.04 LTS
  • Amazon 2017.09 或以上
  • Fedora 25或以上 (Fedora 27 推荐)
  • Mint 18
  • MacOS Darwin 10.12 或以上 (MacOS 10.13.x 推荐)

2、硬件

  • 8G内存(官方建议而已,实际上用不了这么多,可以在编译脚本中修改绕过,4G验证可行)
  • 20G硬盘空间

更多详情参见EOS官方wiki:https://github.com/EOSIO/eos/wiki

二、下载EOS安装包

1、克隆代码库
$ cd ~
$ git clone https://github.com/EOSIO/eos --recursive #VPN新加坡线路,可以直接下载,不用设置CDN映射

【神坑1】如果出现以下提示:
ssh: Could not resolve hostname github.com: Temporary failure in name resolution
可能原因是没有找到最近的github cdn服务器。
 解决办法:
sudo vim /etc/hosts
在文件末尾加入一行:
192.30.253.113 github.com #香港线路

如果克隆代码时未带--recursive参数或者子模块克隆时报错,那么可切换到项目路径下面执行如下命令,更新子模块。
$ cd ~/eos
$ git submodule update --init --recursive

 

小提示:下载完成后,可以将~/eos文件夹打包备份,以便下次可以直接解压编译,节约时间。

三、开始编译EOS

为了避免权限不够,导致中途执行出错,我们在脚本前面加上sudo。
$ cd ~/eos
$ sudo ./eosio_build.sh

【神坑2】如果出现如下提示:内存不足7G,
[sudo] simon 的密码:

    Beginning build version: 1.2
    2018年 07月 01日 星期日 10:49:30 UTC
    User: root
    git head id: 90fefdd12a4797e47890910f11dd7b60f1435ed4
    Current branch: master

    ARCHITECTURE: Linux

    OS name: Ubuntu
    OS Version: 18.04
    CPU speed: 3292.429Mhz
    CPU cores:
    Physical Memory: 3933 Mgb
    Disk install: /dev/sda1
    Disk space total: 39G
    Disk space available: 29G
    Your system must have 7 or more Gigabytes of physical memory installed.
    Exiting now.

解决办法:
修改内存限制方法:
 找到~/eos/scripts/eosio_build_ubuntu.sh(系统环境不同,脚本文件名不同)
 打开文件,定位到27行if [ "${MEM_MEG}" -lt 7000 ]; then 数字修改成4000,即4G内存,安装前在VMWare10中可以将内存设置成4G多一点,因为刚好4G仍然有可能报内存不足。

修改硬盘空间限制方法:
 打开~/eos/eosio_build.sh,定位到52行:
DISK_MIN=20
单位:GB,一般不差硬盘空间,所以不建议修改。

【神坑3】MongoDB安装失败,可能原因是git没有克隆成功
Checking MongoDB installation.

    Installing MongoDB 3.6.3.
  % Total    % Received % Xferd  Average Speed  Time    Time    Time  Current
                                Dload  Upload  Total  Spent    Left  Speed
  0    0    0    0    0    0      0      0 --:--:--  0:00:30 --:--:--    0
curl: (28) Operation timed out after 30002 milliseconds with 0 out of 0 bytes received
    Unable to download MongoDB at this time.

    Exiting now.

解决办法:
 打开~/eos/scripts/eosio_build_ubuntu.sh文件,搜索Unable to download MongoDB at this time,定位到错误提示行,依次将下列两个安装包手工下载至~/家目录:
https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.3.tgz
https://github.com/mongodb/mongo-c-driver/releases/download/1.9.3/mongo-c-driver-1.9.3.tar.gz

注释掉208-213行,在213行后加入cp "${HOME}/mongodb-linux-x86_64-3.6.3.tgz" "${HOME}/opt/"
注释掉282-291行,在291行后加入cp "${HOME}/mongo-c-driver-1.9.3.tar.gz" "${TEMP_DIR}/"
#注释掉208-213行
#STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.3.tgz)
        #if [ "${STATUS}" -ne 200 ]; then
        #  printf "\\tUnable to download MongoDB at this time.\\n"
        #  printf "\\n\\tExiting now.\\n\\n"
        #  exit 1;
        #fi
#增加一行
cp "${HOME}/mongodb-linux-x86_64-3.6.3.tgz" "${HOME}/opt/" #手工将文件包下载下来拷贝到家目录~/

#注释掉282-291行
# STATUS=$(curl -LO -w '%{http_code}' --connect-timeout 30 https://github.com/mongodb/mongo-c-driver/releases/download/1.9.3/mongo-c-driver-1.9.3.tar.gz)
        # if [ "${STATUS}" -ne 200 ]; then
            # if ! rm -f "${TEMP_DIR}/mongo-c-driver-1.9.3.tar.gz"
            # then
                # printf "\\n\\tUnable to remove file %s/mongo-c-driver-1.9.3.tar.gz.\\n" "${TEMP_DIR}"
            # fi
            # printf "\\tUnable to download MongoDB C driver at this time.\\n"
            # printf "\\tExiting now.\\n\\n"
            # exit 1;
        # fi
#增加一行
cp "${HOME}/mongo-c-driver-1.9.3.tar.gz" "${TEMP_DIR}/" #手工将文件包下载下来拷贝到家目录~/

【神坑4】MongoDB C driver无法完成编译
该程序为 x86_64-pc-linux-gnu 编译
报告错误到 <bug-make@gnu.org>
    Error compiling MongoDB C driver.

    Exiting now.

解决办法:
 打开脚本,定位到319行,或搜索Error compiling MongoDB C driver.
经查发现if ! make -j"${JOBS}"中的JOBS值为空,原因是第7行CPU_CORE=$( lscpu | grep "^CPU(s)" | tr -s ' ' | cut -d\ -f2 || cut -d' ' -f2 )没有获取到CPU的个数(奇葩了),在第8行增加CPU_CORE=2即可。

【神坑5】llvm编译器安装包克隆失败
Checking for LLVM with WASM support.
    Installing LLVM with WASM
正克隆到 'llvm'...
remote: Counting objects: 24803, done.
remote: Compressing objects: 100% (23960/23960), done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: 过早的文件结束符(EOF)
fatal: index-pack 失败
    Unable to clone llvm repo @ https://github.com/llvm-mirror/llvm.git.

    Exiting now.

解决办法:
 打开~/eos/scripts/eosio_build_ubuntu.sh文件,注释掉455-472行,即从if ! mkdir "${TEMP_DIR}/llvm-compiler" 2>/dev/null到fi行。再执行如下命令:
mkdir -p /tmp/llvm-compiler
cd /tmp/llvm-compiler
git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git

扩展阅读:Ubuntu编译安装llvm+clang

在经过190分钟左右(去除中间处理坑的时间,网络稳定的情况下),终于编译完成,此次没有踩到LLVM相关的坑。
 编译成功后显示:
    _______  _______  _______ _________ _______
    (  ____ \(  ___  )(  ____ \\__  __/(  ___  )
    | (    \/| (  ) || (    \/  ) (  | (  ) |
    | (__    | |  | || (_____    | |  | |  | |
    |  __)  | |  | |(_____  )  | |  | |  | |
    | (      | |  | |      ) |  | |  | |  | |
    | (____/\| (___) |/\____) |___) (___| (___) |
    (_______/(_______)\_______)\_______/(_______)

    哈哈,恭喜Simon,终于通关了~~~
    EOSIO has been successfully built. 01:10:31

    To verify your installation run the following commands:

    export PATH=${HOME}/opt/mongodb/bin:$PATH
    /home/simon/opt/mongodb/bin/mongod -f /home/simon/opt/mongodb/mongod.conf & cd /home/simon/eos/build; make test

    For more information:
    EOSIO website: https://eos.io
    EOSIO Telegram channel @ https://t.me/EOSProject
    EOSIO resources: https://eos.io/resources/
    EOSIO Stack Exchange: https://eosio.stackexchange.com
    EOSIO wiki: https://github.com/EOSIO/eos/wiki

四、安装EOS

编译完成后,在EOSIO图形下可以看到这几个命令,运行完后,EOS即可安装成功!
cd ~/eos/build
sudo make install

export PATH=${HOME}/opt/mongodb/bin:$PATH
/home/simon/opt/mongodb/bin/mongod -f /home/simon/opt/mongodb/mongod.conf & cd /home/simon/eos/build; make test

五、启动单节点测试网络
nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::account_history_api_plugin

六、测试

在浏览器地址栏访问 http://localhost:8888/v1/chain/get_info

七、附编译EOS依赖列表
1. clang-4.0
2. lldb-4.0
3. libclang-4.0-dev
4. cmake
5. make
6. automake
7. libbz2-dev
8. libssl-dev
9. libgmp3-dev
10. autotools-dev
11. build-essential
12. libicu-dev
13. python2.7-dev
14. python3-dev
15. autoconf
16. libtool
17. curl
18. zlib1g-dev
19. doxygen
20. graphviz

安装前也可以先装依赖,运行如下命令:
sudo apt-get install clang-4.0 lldb-4.0 libclang-4.0-dev cmake make automake libbz2-dev libssl-dev libgmp3-dev autotools-dev build-essential libicu-dev python2.7-dev python3-dev autoconf libtool zlib1g-dev doxygen graphviz

企鹅博客
  • 本文由 发表于 2019年8月13日 12:12:09
  • 转载请务必保留本文链接:https://www.qieseo.com/240144.html

发表评论