EOS多主機節點搭建
阿新 • • 發佈:2018-11-05
參考:構建多節點私鏈
一、eosio節點:
1.1、修改配置檔案:
wallet(keosd) port:8900 (預設)
Nodeos(http-server-address):9800
p2p port:9900
NOTE: 127.0.0.1 與0.0.0.0的區別,其他機器找不到127.0.0.1
# The local IP and port to listen for incoming http connections; set blank to disable. (eosio::http_plugin)
http-server-address = 0.0.0.0:9800
# The actual host:port used to listen for incoming p2p connections. (eosio::net_plugin)
p2p-listen-endpoint = 0.0.0.0:9900
# The public endpoint of a peer node to connect to. Use multiple p2p-peer-address options as needed to compose a network. (eosio::net_plugin)
# p2p-peer-address =
p2p-peer-address = 172.20.22.128:9900
producer-name = eosio
# Timeout for unlocked wallet in seconds (default 900 (15 minutes)). Wallets will automatically lock after specified number of seconds of inactivity. Activity is defined as any wallet command e.g. list-wallets. (eosio::wallet_plugin)
unlock-timeout = 90000
# Plugin(s) to enable, may be specified multiple times
# plugin =
plugin = eosio::http_plugin
plugin = eosio::chain_api_plugin
plugin = eosio::net_api_plugin
plugin = eosio::wallet_api_plugin
plugin = eosio::history_api_plugin
位置:
sec@ll-B85M-DS3H-A:~/rgh/eos_multi/config$ pwd
/home/sec/rgh/eos_multi/config
1.2 建立錢包:
cleos wallet create
1.4 建立金鑰對:
cleos create key
Private key: 5Jmsawgsp1tQ3GD6JyGCwy1dcvqKZgX6ugMVMdjirx85iv5VyPR
Public key: EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4
1.2 建立賬戶inita:
cleos --url http://localhost:9800 create account eosio inita EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4 EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4
1.3 將eosio和inita的私鑰匯入錢包(nodeos配置檔案 signature-provider =):
//eosio私鑰
signature-provider = EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
cleos wallet import --private-key
//inita私鑰
建立賬戶的公私鑰對
1.3 建立合約
cleos --url http://localhost:9800 set contract eosio /home/sec/rgh/eos_719/eos/build/contracts/eosio.bios
1.4 啟動nodeos節點:
[email protected]-B85M-DS3H-A:~/rgh/eos_multi$ pwd
/home/sec/rgh/eos_multi
[email protected]-B85M-DS3H-A:~/rgh/eos_multi$ nodeos --enable-stale-production --data-dir ./data --config-dir ./config --replay-blockchain --delete-all-blocks eosio::chain_plugin
二、inita 節點
2.1 配置檔案
signature-provider =
# The local IP and port to listen for incoming http connections; set blank to disable. (eosio::http_plugin)
http-server-address = 0.0.0.0:9800
# The actual host:port used to listen for incoming p2p connections. (eosio::net_plugin)
p2p-listen-endpoint = 0.0.0.0:9900
# The public endpoint of a peer node to connect to. Use multiple p2p-peer-address options as needed to compose a network. (eosio::net_plugin)
# p2p-peer-address =
p2p-peer-address = 172.20.22.137:9900
signature-provider = EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4=KEY:5Jmsawgsp1tQ3GD6JyGCwy1dcvqKZgX6ugMVMdjirx85iv5VyPR
# ID of producer controlled by this node (e.g. inita; may specify multiple times) (eosio::producer_plugin)
producer-name = inita
# Plugin(s) to enable, may be specified multiple times
# plugin =
plugin = eosio::http_plugin
plugin = eosio::chain_api_plugin
plugin = eosio::net_api_plugin
#plugin = eosio::wallet_api_plugin
#plugin = eosio::account_history_api_plugin
2.2 啟動inita 節點:
[email protected]-Inspiron-3847:~/eos2_eos_multi$ pwd
/home/u/eos2_eos_multi
[email protected]-Inspiron-3847:~/eos2_eos_multi$ nodeos --enable-stale-production --data-dir ./data --config-dir ./config --replay-blockchain --delete-all-blocks eosio::chain_plugin
至此:nodeos 產塊,Inita接收塊:
三、在nodeos機器向eosio合約推送動作:
[email protected]:~$ cleos --url http://localhost:9800 push action eosio setprods "{\"schedule\":[{\"producer_name\":\"inita\",\"block_signing_key\":\"EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro9dq7Sd1C3dC4\"},{\"producer_name\":\"eosio\",\"block_signing_key\":\"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV\"}]}" -p [email protected]
executed transaction: b50cbfc8de00f69020ff0fa05e1ae23f2376fb43aecf151169d281dbcfece41b 184 bytes 10155 us
# eosio <= eosio::setprods {"schedule":[{"producer_name":"inita","block_signing_key":"EOS7ijWCBmoXBi3CgtK7DJxentZZeTkeUnaSDvyro...
warning: transaction executed locally, but may not be confirmed by the network yet ]
至此:eosio和nodeos節點輪流產塊:nodeos節點產塊,inita接收;inita 產塊,nodeos接收