neo blockchain book
  • NEOHOPE's Blockchain Book
  • 概述
    • 本书内容
    • 读者定位
    • 本书约定
    • 项目对比
    • 名词释义
  • 基本原理
    • 区块链
    • 智能合约
    • 交易所
    • 系统架构
  • 基础算法
    • 默克尔树
    • Bloom过滤器
    • 公钥私钥及椭圆曲线
  • 共识算法
    • 分布式系统
    • Paxos与Raft算法
    • 拜占庭容错算法
  • Bitcoin
    • 整体架构
    • 状态转换
    • 区块确认
    • 分叉处理
    • P2P
    • 脚本
    • 钱包
    • 使用
    • 编译(Ubuntu)
    • 私链搭建(Linux)
    • 私链搭建(Docker)
  • Ethereum
    • 整体架构
    • 状态转换
    • 区块确认
    • 使用
    • Remix IDE环境搭建(Ubuntu16)
    • 智能合约编写01
    • 智能合约编写02
    • 智能合约编写03
    • 智能合约编写04
    • 编译(MacOS)
    • 私链搭建
  • EOS
    • 整体架构
    • 使用
    • 智能合约使用(单机单节点单钱包)
    • 智能合约使用(单机单节点多钱包)
    • 编写简单的智能合约
    • 编写有数据存储的智能合约
    • 编译(Linux)
    • 私链搭建(单机多节点)
    • 私链搭建(多机多节点)
  • Fabric
    • 整体架构
    • 身份管理
    • 共识达成
    • 使用
    • 智能合约介绍
    • 智能合约使用01
    • 智能合约使用02
    • 编译(MacOS)
    • 私链搭建(Ubuntu)
    • 在私链中添加一个机构
  • Cosmos
    • 整体架构
    • Zone与Hub
    • 使用
  • IPFS
    • 整体架构
    • 使用
    • 编译(MacOS)
    • 私链搭建
  • 然后呢?
由 GitBook 提供支持
在本页
  • 最终创建两个生产节点的私链
  • 开启钱包服务节点
  • 创建一个默认钱包
  • 创建第一个生产节点
  • 创建第二个生产节点
  • 激活test2用户
  • 状态检查
  • 完结
  1. EOS

私链搭建(单机多节点)

最终创建两个生产节点的私链

开启钱包服务节点

#建议只在本地监听,因为密钥传输是不加密的
keosd --http-server-address 127.0.0.1:8899
#直接输出
2042116ms thread-0   wallet_plugin.cpp:41          plugin_initialize    ] initializing wallet plugin
2042120ms thread-0   http_plugin.cpp:141           plugin_initialize    ] host: 127.0.0.1 port: 8899
2042121ms thread-0   http_plugin.cpp:144           plugin_initialize    ] configured http to listen on 127.0.0.1:8899
2042122ms thread-0   http_plugin.cpp:213           plugin_startup       ] start listening for http requests
2042123ms thread-0   wallet_api_plugin.cpp:70      plugin_startup       ] starting wallet_api_plugin
2042127ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/create
2042127ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/get_public_keys
2042127ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/import_key
2042127ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/list_keys
2042127ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/list_wallets
2042127ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/lock
2042127ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/lock_all
2042128ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/open
2042128ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/set_timeout
2042128ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/sign_transaction
2042128ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/unlock\
#后输出的
2167622ms thread-0   wallet.cpp:182                save_wallet_file     ] saving wallet to file /home/hiup/eosio-wallet/./default.wallet
3194752ms thread-0   wallet.cpp:182                save_wallet_file     ] saving wallet to file /home/hiup/eosio-wallet/./default.wallet

创建一个默认钱包

cleos --wallet-port 8899  wallet create

#记住输出的私钥
"PW5JMmtnJxaUiEwwSLVSrA9UTxSzypnxVkhRtKA1QeSAQm25LU8Dx"

创建第一个生产节点

#第一个节点叫eosio
nodeos --enable-stale-production --producer-name eosio --plugin eosio::chain_api_plugin --plugin eosio::net_api_plugin
#不停输出区块信息
eosio generated block 36cd7280... #7030 @ 2018-04-16T03:36:09.000 with 0 trxs, lib: 7029
eosio generated block a135dfcc... #7031 @ 2018-04-16T03:36:09.500 with 0 trxs, lib: 7030
eosio generated block 6b6e8f9d... #7032 @ 2018-04-16T03:36:10.000 with 0 trxs, lib: 7031
eosio generated block 26f1a273... #7033 @ 2018-04-16T03:36:10.500 with 0 trxs, lib: 7032
eosio generated block 797bdc13... #7034 @ 2018-04-16T03:36:11.000 with 0 trxs, lib: 7033

创建第二个生产节点

#加载智能合约
cleos --wallet-port 8899 set contract eosio ../eos/build/contracts/eosio.bios
Reading WAST/WASM from ../eos/build/contracts/eosio.bios/eosio.bios.wast...
Assembling WASM...
Publishing contract...
executed transaction: 684d83f376333d381841d79931b0c820698a3f2cadb11080169bc5504d1eff8b  3280 bytes  2200576 cycles
#         eosio <= eosio::setcode               {"account":"eosio","vmtype":0,"vmversion":0,"code":"0061736d0100000001581060037f7e7f0060057f7e7e7e7e...
#         eosio <= eosio::setabi                {"account":"eosio","abi":{"types":[],"structs":[{"name":"set_account_limits","base":"","fields":[{"n...

#创建密钥对
cleos create key
Private key: 5JaN9LSpwuqY89KbtiJHQDdngQztDyB9XZHz2KC6QxP7xn9NUeN
Public key: EOS5BTsWP7hC7wAeUuoo6Q3LBTjiPLoEAM6hY51ujDEzsq7UNfex2

#导入密钥对到钱包
cleos --wallet-port 8899 wallet import 5JaN9LSpwuqY89KbtiJHQDdngQztDyB9XZHz2KC6QxP7xn9NUeN

#创建新用户test2
./cleos --wallet-port 8899 create account eosio test2 EOS5BTsWP7hC7wAeUuoo6Q3LBTjiPLoEAM6hY51ujDEzsq7UNfex2 EOS5BTsWP7hC7wAeUuoo6Q3LBTjiPLoEAM6hY51ujDEzsq7UNfex2
executed transaction: 431d872ad07764b912c1eca32e50e01bd0dac26113f6545054b453a1b5330daf  352 bytes  102400 cycles
#         eosio <= eosio::newaccount            {"creator":"eosio","name":"test2","owner":{"threshold":1,"keys":[{"key":"EOS5BTsWP7hC7wAeUuoo6Q3LBTj...

#开启用户test2的生产
#避免了端口冲突
./nodeos --producer-name test2 --plugin eosio::chain_api_plugin --plugin eosio::net_api_plugin --http-server-address 127.0.0.1:8889 --p2p-listen-endpoint 127.0.0.1:9877 --p2p-peer-address 127.0.0.1:9876 --config-dir node2 --data-dir node2 --private-key [\"EOS5BTsWP7hC7wAeUuoo6Q3LBTjiPLoEAM6hY51ujDEzsq7UNfex2\",\"5JaN9LSpwuqY89KbtiJHQDdngQztDyB9XZHz2KC6QxP7xn9NUeN\"]
test2 generated block b6fe0ecd... #7978 @ 2018-04-16T03:44:03.000 with 0 trxs, lib: 7977
test2 generated block 85f9b073... #7979 @ 2018-04-16T03:44:03.500 with 0 trxs, lib: 7978
test2 generated block 36066d05... #7980 @ 2018-04-16T03:44:04.000 with 0 trxs, lib: 7979
test2 generated block 1d5314fa... #7981 @ 2018-04-16T03:44:04.500 with 0 trxs, lib: 7980
test2 generated block b5410853... #7982 @ 2018-04-16T03:44:05.000 with 0 trxs, lib: 7981

激活test2用户

./cleos --wallet-port 8899 push action eosio setprods "{ \"version\": 1, \"producers\": [{\"producer_name\": \"test2\",\"block_signing_key\": \"EOS5BTsWP7hC7wAeUuoo6Q3LBTjiPLoEAM6hY51ujDEzsq7UNfex2\"}]}" -p eosio@active
executed transaction: 8644f6707157ecceae7397000234e1725d2f18a39a53de27e1b375e6b5b85d1f  272 bytes  105472 cycles
#         eosio <= eosio::setprods              {"version":1,"producers":[{"producer_name":"test2","block_signing_key":"EOS5BTsWP7hC7wAeUuoo6Q3LBTji...

状态检查

#节点1
./cleos get info
{
  "server_version": "74a4c7a0",
  "head_block_num": 7715,
  "last_irreversible_block_num": 7714,
  "head_block_id": "00001e23e240c450f2bf1b747ea64eba97f8ffd784f6a8e63daae279a386ab9d",
  "head_block_time": "2018-04-16T03:41:51",
  "head_block_producer": "test2"
}


#节点2
./cleos --port 8889 get info
{
  "server_version": "74a4c7a0",
  "head_block_num": 7770,
  "last_irreversible_block_num": 7769,
  "head_block_id": "00001e5a78fd1fca6b21c823e51b50f0d7984d1ff5eb0e297a48d2bd1b610b52",
  "head_block_time": "2018-04-16T03:42:19",
  "head_block_producer": "test2"

完结

上一页编译(Linux)下一页私链搭建(多机多节点)

最后更新于7年前