系统准备

演示的系统为 Ubuntu 18.04 LTS,内存8g以上,硬盘300g+

clone EOS代码

我们以EOS-Mainnet仓库部署,(EOS-Mainnet是部署在目前EOS主网的版本,等于再次在EOSIO仓库测试过的版本,更稳定。)

开始clone 代码

//如果没有安装git,先安装
$sudo apt install git
$git clone https://github.com/EOS-Mainnet/eos.git

切换到最新分支(当前的EOS最新版本为 v1.4.1)

$git fetch
$git checkout -b mainnet-1.4.1

编译代码

$git submodule update --init --recursive
$./eosio_build.sh -s EOS

漫长等待,编译成功

执行安装

$sudo ./eosio_install.sh

安装成功后查看版本

$ nodeos -v
mainnet-1.4.1

各个节点,分别创建钱包和密钥,准备用户名

创建钱包

cleos wallet create --to-console

记得保存返回的钱包解锁密码,丢失无法找回钱包内数据

创建密钥

cleos wallet create_key

创建的密钥会自动添加到钱包,如需查看,可执行

cleos wallet private_keys

输入钱包解锁密码查看

准备用户名

1-5a-z 字符12位,准备好,后面config配置中producer-name用到。

各个节点机器,分别创建目录

选定一个存储位置,用于存储EOS节点配置和节点数据。选定的磁盘存储一般要在300G以上,防止后期不够。
假设我们选定的磁盘位置为/data
然后在当前目录下,新建两个目录

  • eos-tools 用于存放eos节点的配置
  • data 用于存放eos节点数据

创世节点配置

进入eos-tools文件夹

创建genesis.json文件

直接生成genesis.json文件

nodeos --extract-genesis-json genesis.json

创建 config.ini文件

创建 config.ini文件,并输入以下信息

//修改本地节点rpc 访问端口,默认为8888,修改后,本地访问方式为`cleos -u http://127.0.0.1:8000 get info`
http-server-address = 0.0.0.0:8000
//bp节点间的访问地址,当前节点的p2p-peer-address为,服务器IP或者域名,加上下面设置的端口
p2p-listen-endpoint = 0.0.0.0:8001

#设置一个自己的bp名字
agent-name = "EOS Shen Si"
//创世节点名字必须为eosio
producer-name = eosio
#创建一对密钥 创世节点不能修改私钥
signature-provider = EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
#创世节点才需要,其他bp不需要开启
enable-stale-production = true
#添加一些稳定的其他bp节点
# p2p-peer-address =

#以下为通用设置
wasm-runtime = wabt
pause-on-startup = false
abi-serializer-max-time-ms = 3000
chain-state-db-size-mb = 65535
reversible-blocks-db-size-mb = 2048
contracts-console = false
p2p-max-nodes-per-host = 1
allowed-connection = any
max-clients = 100
network-version-match = 1
sync-fetch-span = 500

#filter-on = *
connection-cleanup-period = 30
max-implicit-request = 1500
http-validate-host = false
access-control-allow-origin = *
access-control-allow-headers = *
access-control-allow-credentials = false
verbose-http-errors = true

#添加插件
plugin = eosio::chain_api_plugin
plugin = eosio::history_plugin
plugin = eosio::history_api_plugin
plugin = eosio::producer_plugin

启动节点

$EOS_TOOLS_DIR为eos-tools的当前目录,本例中路径为/data/eos-tools
$EOS_DATA_DIR为eos data的当前目录,本例中路径为/data/data

  • 第一次启动节点,(仅第一次运行使用)
nodeos --genesis-json $EOS_TOOLS_DIR/genesis.json --max-irreversible-block-age 108000000 --data-dir $EOS_DATA_DIR --config-dir $EOS_TOOLS_DIR --delete-all-blocks

如果此时是创世节点,此时已开始出块。

创世节点配置

导入创世账户eosio的私钥5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3到钱包

cleos wallet import

创建系统账户

先创建10对密钥,用于创建前期10个系统的内置账户

cleos wallet create_key

执行10次

账户名公钥私钥
eosio.tokenEOS5rNiix2ENyUcvGo5pCr7yUukkhCUHySYfcMpFGNH18XERuf9t5
eosio.bpayEOS7YEYexP3yQtddnQHJGV4CDLUF58RkFTDNUZR5MPmD9jx1xFH8f
eosio.msigEOS5SoN8xuQBCA5vBcRZXiVYA9xjkShaVN3UpsMngv1X2dhHojAS4
eosio.namesEOS6Q44xh1p35ZkVkfSAguWLPJiqJVCi2B4AuGsxVwchKrKHKkf9T
eosio.ramEOS81nArYKAitRN1h2GUCCNZWS6zArKzrg1JvcgC5zyhFAumQRgrR
eosio.ramfeeEOS8HhotHdovvtC1RR5G7bPRgLaHXkFbMGbSfwKKrtkQspy1rapy3
eosio.savingEOS85QMTp1Xm71jCAYYvVhm3dxmxZuobUEHxe1wLNb8qL52kmrfwX
eosio.stakeEOS5USZ8g5p3fU965ByvhL8AgfXfWUbeDHXjySe2QiG1wcz5So9KR
eosio.vpayEOS8Qk7vEPme8huxpqa4mS9jfuDriQrpM6MJjFDvcvJfiPaKfypR6
eosio.sudoEOS8Qk7vEPme8huxpqa4mS9jfuDriQrpM6MJjFDvcvJfiPaKfypR6

部署系统合约

进入eos/build/contracts

部署eosio.bios
cleos -u http://127.0.0.1:8000 set contract eosio eosio.bios/ -p eosio
创建账户
cleos -u http://127.0.0.1:8000 create account eosio eosio.token EOS5rNiix2ENyUcvGo5pCr7yUukkhCUHySYfcMpFGNH18XERuf9t5 EOS5rNiix2ENyUcvGo5pCr7yUukkhCUHySYfcMpFGNH18XERuf9t5
cleos -u http://127.0.0.1:8000 create account eosio eosio.bpay EOS7YEYexP3yQtddnQHJGV4CDLUF58RkFTDNUZR5MPmD9jx1xFH8f EOS7YEYexP3yQtddnQHJGV4CDLUF58RkFTDNUZR5MPmD9jx1xFH8f
cleos -u http://127.0.0.1:8000 create account eosio eosio.msig EOS5SoN8xuQBCA5vBcRZXiVYA9xjkShaVN3UpsMngv1X2dhHojAS4 EOS5SoN8xuQBCA5vBcRZXiVYA9xjkShaVN3UpsMngv1X2dhHojAS4
cleos -u http://127.0.0.1:8000 create account eosio eosio.names EOS6Q44xh1p35ZkVkfSAguWLPJiqJVCi2B4AuGsxVwchKrKHKkf9T EOS6Q44xh1p35ZkVkfSAguWLPJiqJVCi2B4AuGsxVwchKrKHKkf9T
cleos -u http://127.0.0.1:8000 create account eosio eosio.ram EOS81nArYKAitRN1h2GUCCNZWS6zArKzrg1JvcgC5zyhFAumQRgrR EOS81nArYKAitRN1h2GUCCNZWS6zArKzrg1JvcgC5zyhFAumQRgrR
cleos -u http://127.0.0.1:8000 create account eosio eosio.ramfee EOS8HhotHdovvtC1RR5G7bPRgLaHXkFbMGbSfwKKrtkQspy1rapy3 EOS8HhotHdovvtC1RR5G7bPRgLaHXkFbMGbSfwKKrtkQspy1rapy3
cleos -u http://127.0.0.1:8000 create account eosio eosio.saving EOS85QMTp1Xm71jCAYYvVhm3dxmxZuobUEHxe1wLNb8qL52kmrfwX EOS85QMTp1Xm71jCAYYvVhm3dxmxZuobUEHxe1wLNb8qL52kmrfwX
cleos -u http://127.0.0.1:8000 create account eosio eosio.stake EOS5USZ8g5p3fU965ByvhL8AgfXfWUbeDHXjySe2QiG1wcz5So9KR EOS5USZ8g5p3fU965ByvhL8AgfXfWUbeDHXjySe2QiG1wcz5So9KR
cleos -u http://127.0.0.1:8000 create account eosio eosio.upay EOS8Qk7vEPme8huxpqa4mS9jfuDriQrpM6MJjFDvcvJfiPaKfypR6 EOS8Qk7vEPme8huxpqa4mS9jfuDriQrpM6MJjFDvcvJfiPaKfypR6
cleos -u http://127.0.0.1:8000 create account eosio eosio.sudo EOS8Qk7vEPme8huxpqa4mS9jfuDriQrpM6MJjFDvcvJfiPaKfypR6 EOS8Qk7vEPme8huxpqa4mS9jfuDriQrpM6MJjFDvcvJfiPaKfypR6
部署 eosio.token
cleos -u http://127.0.0.1:8000 set contract eosio.token eosio.token
创建代币
cleos -u http://127.0.0.1:8000 push action eosio.token create '["eosio","10000000000.0000 EOS",0,0,0]' -p eosio.token
发布代币
cleos -u http://127.0.0.1:8000 push action eosio.token issue '["eosio","1000000000.0000 EOS","issue"]' -p eosio
issue 中的发行量(supply),要比上边创建的最大量(max_supply),要少一个0
查询账户余额
cleos -u http://127.0.0.1:8000 get currency balance eosio.token eosio

应返回10000000000.0000 EOS

部署 eosio.msig
cleos -u http://127.0.0.1:8000 set contract eosio eosio.msig -p eosio
cleos -u http://127.0.0.1:8000 push action eosio setpriv '{"account": "eosio.msig", "is_priv": 1}' -p eosio
部署eosio.system
cleos -u http://127.0.0.1:8000 set contract eosio eosio.system -p eosio
部署 eosio.sudo
cleos -u http://127.0.0.1:8000 set contract eosio eosio.sudo -p eosio
cleos -u http://127.0.0.1:8000 push action eosio setpriv '{"account": "eosio.sudo", "is_priv": 1}' -p eosio
创建其他三个bp的账户,(账户名和公钥由各自节点自己提供)
cleos system newaccount eosio eosio.bp1 EOS7mcXeVUSLCZxEf8eBPm2MbmiswNovoB6rk71pPqaZoxwSAeK7b EOS7mcXeVUSLCZxEf8eBPm2MbmiswNovoB6rk71pPqaZoxwSAeK7b  --stake-net '50.00 EOS' --stake-cpu '50.00 EOS'  --buy-ram-kbytes 10000
cleos system newaccount eosio eosio.bp2 EOS6wLrhcEQDZJvfZSCgVkFzsKcv34XTsTTjXXQZajWaBbEhvLPMg  EOS6wLrhcEQDZJvfZSCgVkFzsKcv34XTsTTjXXQZajWaBbEhvLPMg   --stake-net '50.00 EOS' --stake-cpu '50.00 EOS'  --buy-ram-kbytes 10000
cleos system newaccount eosio eosio.bp3 EOS6u8i7rknHyAd7AdziWSnEsAbyJHA3U9So4R8p2z58cA1KeEDv2  EOS6u8i7rknHyAd7AdziWSnEsAbyJHA3U9So4R8p2z58cA1KeEDv2   --stake-net '50.00 EOS' --stake-cpu '50.00 EOS'  --buy-ram-kbytes 10000
查看以创建的用户
cleos -u http://127.0.0.1:8000 get account eosio.bp1
cleos -u http://127.0.0.1:8000 get account eosio.bp2
cleos -u http://127.0.0.1:8000 get account eosio.bp3

确认创建ok

其他bp加入

进入eos-tools文件夹

创建genesis.json文件

将创世节点的genesis.json文件,复制到此目录

创建 config.ini文件

将创世节点的config.ini复制到此目录,并修改以下信息

agent-name = "节点的名称,用于信息展示"
producer-name = 节点的账户名
signature-provider = 节点的公钥+私钥,(此配置妥善保存,别手误上传)
enable-stale-production = false
p2p-peer-address = 添加其他的节点地址

启动从节点

$EOS_TOOLS_DIR为eos-tools的当前目录,本例中路径为/data/eos-tools
$EOS_DATA_DIR为eos data的当前目录,本例中路径为/data/data

  • 第一次启动节点,(仅第一次运行使用)
nodeos --genesis-json $EOS_TOOLS_DIR/genesis.json --max-irreversible-block-age 108000000 --data-dir $EOS_DATA_DIR --config-dir $EOS_TOOLS_DIR --delete-all-blocks

此时从节点已经接收来自eosio创世节点的数据。

开始投票,从普通节点成为出块节点

给从节点分别转代币

创世节点,先把大于15%主网总发行量,分成当前启动主网节点数份数,目前为了好记,直接一人转100000000.0000 EOS

cleos -u http://127.0.0.1:8000 push action eosio.token transfer '["eosio", "eosio.bp1","100000000.0000 EOS","vote"]' -p eosio
cleos -u http://127.0.0.1:8000 push action eosio.token transfer '["eosio", "eosio.bp2","100000000.0000 EOS","vote"]' -p eosio
cleos -u http://127.0.0.1:8000 push action eosio.token transfer '["eosio", "eosio.bp3","100000000.0000 EOS","vote"]' -p eosio

各个从节点,分别抵押自己的代币

cleos -u http://127.0.0.1:8000 system delegatebw  eosio.bp* eosio.bp* '25000000.0000 EOS' '25000000.0000 EOS'

各个节点分别提交注册出块节点申请

cleos -u http://127.0.0.1:8000 system regproducer eosio.bp*  节点公钥  节点的网址

各个节点,开始投票

cleos -u http://127.0.0.1:8000 system voteproducer prods eosio.bp* eosio.bp*

查看出块节点

cleos -u http://127.0.0.1:8000  get schedule

此时 eosio.bp1-3,三个节点应该都已经在出块了。

eosio等系统账号,将权限交给社区

eosio.bpay
cleos push action eosio updateauth '{"account": "'eosio.bpay'", "permission": "active", "parent": "owner", "auth":{"threshold": 1, "keys": [], "waits": [], "accounts": [{"weight": 1, "permission": {"actor": "eosio", "permission": active}}]}}' -p eosio.bpay@active
cleos push action eosio updateauth '{"account": "'eosio.bpay'", "permission": "owner", "parent": "",       "auth":{"threshold": 1, "keys": [], "waits": [], "accounts": [{"weight": 1, "permission": {"actor": "eosio", "permission": active}}]}}' -p eosio.bpay@owner

其他账户eosio.msig eosio.names eosio.ram eosio.ramfee eosio.saving eosio.stake eosio.token eosio.vpay eosio.sudo同上

eosio
cleos push action eosio updateauth '{"account": "eosio", "permission": "active", "parent": "owner", "auth":{"threshold": 1, "keys": [], "waits": [], "accounts": [{"weight": 1, "permission": {"actor": "eosio.prods", "permission": active}}]}}' -p eosio@active
cleos push action eosio updateauth '{"account": "eosio", "permission": "owner", "parent": "",       "auth":{"threshold": 1, "keys": [], "waits": [], "accounts": [{"weight": 1, "permission": {"actor": "eosio.prods", "permission": active}}]}}' -p eosio@owner

其他命令

  • 继续同步数据 (常规退出后,继续执行)
nodeos --max-transaction-time 1000 --max-irreversible-block-age 108000000 --data-dir $EOS_DATA_DIR --config-dir $EOS_TOOLS_DIR
  • 重建数据,重新接收
nodeos --hard-replay-blockchain --wasm-runtime wavm --max-irreversible-block-age 108000000 --data-dir $EOS_DATA_DIR --config-dir $EOS_TOOLS_DIR

其他设置

  • 中文支持:sudo apt-get update && sudo apt-get -y install language-pack-zh-hans
  • 时间同步,sudo apt-get install chrony
    修改ulimit限制

    • ulimit -s 64000
    • sudo vi /etc/security/limits.conf
*               soft    stack            64000
root          soft    stack            64000