Ubuntu虚拟机EOS安装教程


一、源码下载

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

注意事项:

1.如果git clone失败或者速度过慢,可以修改host或者换源
(1)换源参考:
修改为国内源,主要有利于后面编译时的下载。
(2)修改host :

sudo vim /etc/hosts

在文件末尾加上:192.30.253.113 github.com

2.如果报错

RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull function.
fatal: The remote end hung up unexpectedly
fatal: 过早的文件结束符(EOF)
fatal: index-pack failed

意味着http缓存过小,输入:

git config --global http.postBuffer 524288000

并打开vim ~/.bashrc,在文件末尾加上:

export GIT_TRACE_PACKET=1
export GIT_TRACE=1
export GIT_CURL_VERBOSE=1

保存退出后,运行source ~/.bashrc生效

二、编译源码

执行:

cd ~/eos/scripts 
sudo ./eosio_build.sh

一键安装

注意事项:

1.如果报错出现内存或磁盘大小不足,可以修改内存限制(可以修改至4GB)
具体方法为:

(1)内存不足时,修改内存限制:
打开:eos/scripts/eosio_build_ubuntu.sh,找到:

if [ "${MEM_MEG}" -lt 7000 ]; then 

将7000修改为4000保存即可
(2)扩展磁盘,可参考:
Ubuntu VM虚拟机扩展磁盘

2.如果出现

clang++: error: unable to execute command: Killed
clang++: error: assembler command failed due to signal (use -v to see invocation)
'''
***
'''
make[1]: *** [libraries/testing/CMakeFiles/chain_tester.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

(1)查看swap区是否足够:

free -h

(2)如果swap分区不足,可以使用

sudo fallocate -l 4G /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

备份文件

sudo cp /etc/fstab  /etc/fstab.bak

修改文件

echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

三、安装

1.install安装

(1)脚本安装
执行:

sudo./scripts/eosio_install.sh

(2)手动安装
进入:~/eos/build/programs,执行:

sudo make install

即可安装成功

2.测试(可跳过)

执行:make test

四、运行

1.进入/eos/build/programs/nodeos
运行命令:

./nodeos -e -p eosio \
--plugin eosio::producer_plugin \
--plugin eosio::producer_api_plugin \
--plugin eosio::chain_api_plugin \
--plugin eosio::http_plugin \
--plugin eosio::history_plugin \
--plugin eosio::history_api_plugin \
--filter-on="*" \
--access-control-allow-origin='*' \
--contracts-console \
--http-validate-host=false \
--verbose-http-errors >> nodeos.log 2>&1 &

即可成功运行节点(注意权限问题)

2.环境变量配置:
执行:sudo vim ~/.bashrc
在最后一行加入:

export EOSIO_PATH=~/eosio/2.0/bin
export PATH=$EOSIO_PATH:$PATH

具体路径为安装目录下的/bin文件夹
配置完成后执行

source ~/.bashrc

即可在全局使用命令cleos、nodeos等


总结

该文章对eos源码编译及常见错误进行了总结归纳。更多问题欢迎留言讨论

猜你喜欢

转载自blog.csdn.net/JerryViolet/article/details/108518895