2018-11-16 eos节点搭建
# EOS开发入门到精通
### 初始环境设置:
官方参考文档:
centos环境(阿里云美国硅谷服务器 编译过程中就不会遇到opensll的问题)
centos下载源更新:
```
yum -y update
```
git 下载:
```
yum install git
```
创建eos下载目录:
```
mkdir eos_install
cd eos_install
```
从GitHub·中clone Eos
```
git clone https://github.com/eosio/eos --recursive
```
如果没加--recursive,则拉完源码后需要在源码目录执行以下命令(如果没有执行,执行编译命令时会提示)
```
git submodule update --init --recursive
```
进入到eos文件夹并执行编译命令
```
sh eosio_build.sh
```
###编译提示RAM空间不足
![1535526753203](C:\Users\cxw\AppData\Local\Temp\1535526753203.png)
### 方法一:修改EOS目录先的script所对应的脚本文件
进到eos/scripts/路径,修改对应的sh文件,找到“Your system must have 7 or more Gigabytes of physical memory installed”字样,或者You must have at least %sGB of available storage to install EOSIO,将后面的exit 1命令去掉即可。
```
if [ "${MEM_MEG}" -lt 7000 ]; then
printf "\\tYour system must have 7 or more Gigabytes of physical memory installed.\\n"
printf "\\tExiting now.\\n"
# exit 1
fi
```
顺道把硬盘不足的提示也注释掉,测试发现13G的空闲硬盘是可以编译成功的。
```
> if [ "${DISK_AVAIL%.*}" -lt "${DISK_MIN}" ]; then
printf "\\tYou must have at least %sGB of available storage to install EOSIO.\\n" "${DISK_MIN}"
printf "\\tExiting now.\\n"
# exit 1
fi
```
### 方法二:直接更改系统配置(换成内存8G,4核,硬盘空间40G)
安装过程中输入yes和1 同意并下载安装包
编译过程中回遇到下面的问题:
CMake问题:
![1535532280265](C:\Users\cxw\AppData\Local\Temp\1535532280265.png)
解决问题:
把eosio_build.sh中的CMAKE_BUILD_TYPE=Release改成CMAKE_BUILD_TYPE=Debug
![1535586289693](C:\Users\cxw\AppData\Local\Temp\1535586289693.png)
继续等待编译完成(大概1到2个小时)
编译完成后(成功的样子如下图:)
![1535585380384](C:\Users\cxw\AppData\Local\Temp\1535585380384.png)
### 构建完成后需要对构建的产物进行验证:
•Linux 系(Ubuntu、centos等):
~/opt/mongodb/bin/mongod -f ~/opt/mongodb/mongod.conf &
•Mac:
/usr/local/bin/mongod -f /usr/local/etc/mongod.conf &
test 测试:
![1535597665866](C:\Users\cxw\AppData\Local\Temp\1535597665866.png)
为了方便开发智能合约,还需要在 build 目录进行 make install:
该命令会将编译好的可执行文件、头文件、库文件和模板文件安装到build下的install目录下,在该目录的bin下有所有编译好的命令,包括eosd、eosc、eoscpp等等。
需要进入build目录然后执行以下命令:
```
cd build
make install
```
nodeos测试:
在命令行终端 cd 到 eos/build/programs/nodeos/ 目录
直接执行 ./nodeos
结果如下:
![1535597529700](C:\Users\cxw\AppData\Local\Temp\1535597529700.png)
# 常用插件清单
cd 到 /root/.local/share/eosio/nodeos/config 目录( ~/eos_install/eos/build/programs/nodeos/)
编辑 config 文件
添加如下插件:.
```
plugin = eosio::chain_api_plugin
plugin = eosio::history_api_plugin
(#plugin = eosio::wallet_api_plugin)
plugin = eosio::net_api_plugin
plugin = eosio::producer_api_plugin
enable-stale-production = true
producer-name = eosio
```
### bug:
fork database is inconsistent with shared memory
```
./nodeos --replay-blockchain --hard-replay-blockchain --delete-all-blocks
第一种情况:
./nodeos --data-dir=/data/packages/nodeos --hard-replay --wasm-runtime wavm
第二种情况:
./nodeos --data-dir=/data/packages/nodeos --replay-blockchain
第三种情况:
./nodeos --data-dir=/data/packages/nodeos
```
### [如何正常停止nodeos?(database dirty flag set (likely due to unclean shutdown): replay required)](https://www.bcskill.com/index.php/archives/305.html)
kill 命令再次执行时会导致以下错误。
```
pkill -9 nodeos or kill -9 {pid}
database dirty flag set (likely due to unclean shutdown): replay required
```
当重新运行nodeos时,必须使用--replay-blockchain命令忽略它。让我们安全的结束nodeos 进程
```shell
This appears to be two different issues.
Startup after a crash or ungraceful shutdown nearly always fails due to corruption of the boost shared memory cache of the in-memory database. --resync is required to clean up the mess.
For normal shutdown, never kill with -9. Always use either the default (no argument) signal (which is SIGTERM) or SIGINT. Numerically, those are 15 and 2, respectively.
pkill nodeos | Safe
pkill -15 nodeos | Safe
pkill -2 nodeos | Safe
pkill -TERM nodeos | Safe
pkill -SIGTERM nodeos | Safe
pkill -INT nodeos | Safe
pkill -SIGINT nodeos | Safe
pkill -9 nodeos | Not Safe
pkill -KILL nodeos | Not Safe
pkill -SIGKILL nodeos | Not Safe
The core dump is a different problem. That looks like a corrupted network packet, specifically a signed_block_summary. Summary messages are being eliminated from the protocol, so this particular error will no longer be possible soon.
```
unable to find plugin: eosio::wallet_api_plugin
解决:去掉 这句话
阿里云镜像系统:
![1535612705524](C:\Users\cxw\AppData\Local\Temp\1535612705524.png)
第一个:编译完成的系统
第二个:完成第一个节点的的基本配置
企业版(Ubuntu )
阿里云 系统配置
4核16G 40G 硬盘 +100G data数据盘
EOS7nasiNj8p2W4EfB35aZWXuqXqV5ZYrJB491A1KLbBmj5F5cs9j
https://www.bcskill.com/index.php/archives/354.html