EOS启动网络的详细过程(多节点的启动)
准备工作:1.启动钱包(这里不再啰嗦)2.三个账户的公私钥eosioEOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3aiguoloveuipEOS5YCbPBQqYo...
准备工作:
1.启动钱包(这里不再啰嗦)
2.三个账户的公私钥
eosio
EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
aiguoloveuip
EOS5YCbPBQqYoaMZKHkK2FhoNDSYFekqXSpYeWiCGDHCxU9w2U6mr
5JVK7ndrrqxZVzeM6MEMHb7QiULdxDuoA2upc37DqJhwCLTdG3y
eosproducer2
EOS7buuQTWf4KqdDC5xwbhaBkkNX9bnAnc7XoEXtaJTDXfzakisjs
5HskFQ7GLQ6UEoQWqCJPBjtFFCvaJ2brfS2qo5AcabRXmuwUCgz
3.genesis.json的准备
{
"initial_timestamp": "2018-06-01T12:00:00.000",
"initial_key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"initial_configuration": {
"max_block_net_usage": 1048576,
"target_block_net_usage_pct": 1000,
"max_transaction_net_usage": 524288,
"base_per_transaction_net_usage": 12,
"net_usage_leeway": 500,
"context_free_discount_net_usage_num": 20,
"context_free_discount_net_usage_den": 100,
"max_block_cpu_usage": 200000,
"target_block_cpu_usage_pct": 1000,
"max_transaction_cpu_usage": 150000,
"min_transaction_cpu_usage": 100,
"max_transaction_lifetime": 3600,
"deferred_trx_expiration_window": 600,
"max_transaction_delay": 3888000,
"max_inline_action_size": 4096,
"max_inline_action_depth": 4,
"max_authority_depth": 6
}
}
4.各个节点的端口规划
| http-server-address | p2p-listen-endpoint | p2p-server-address | p2p-peer-address |
创世节点(eosio) | 8884 | 9004 | 9004 |
|
出块节点(aiguoloveuip) | 8885 | 9005 | 9005 | 9004 |
出块节点(eosproducer2) | 8886 | 9006 | 9006 | 9004 9005 |
启动创世节点:
1.代码:
/eos/home/Jungle/private_chain/eos-source/build/programs/nodeos/nodeos -e -p eosio --signature-provider=EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3 --plugin eosio::producer_plugin --plugin eosio::chain_api_plugin --plugin eosio::http_plugin --plugin eosio::history_api_plugin --http-server-address=172.26.247.122:8884 --p2p-listen-endpoint=172.26.247.122:9004 --p2p-server-address=172.26.247.122:9004 --p2p-peer-address 172.26.247.122:9005 --data-dir ./data/ --config-dir ./ --genesis-json genesis.json --max-transaction-time 3000
2.注意的地方
-
--data-dir 是数据存放的地方,包括blocks和state,所以不用另外在家--blocks-dir参数(为了更加整齐)
-
--max-tansaction-time 为的是解决报错Error 3080006: transaction took too long
-
--http-server-address --p2p-listen-endpoint --p2p-server-address三个都要指定,但是--p2p-peer-address不必添加,之后其他节点指定该节点后就会同步区块
-
将当前进程切换到后台 ctrl-z ,bg
-
--genesis-json每个节点第一次启动的时候都要加上genesis.json配置文件,get info得到的chainid是和genesis.json有关,所以必须指定
-
想要get transaction(get actions),可以加上参数--filter-on "*"
BIOS:
00_CONFIG.conf代码
{
"SOURCES_FOLDER": "/eos/home/Jungle/private_chain/eos-source",
"EOSIO_PRODUCER_PUB_KEY": "EOS7wp9yW6a9pwrnNmaUPGLdxmZmywY3B5mLEhrqJCrsNqSuev936",
"EOSIO_PRODUCER_PRIV_KEY": "5Kk7LCFTcoyK2PjaBjPrDAYBJie2xUycHiWgChuVjvtkLEYuSgq",
"WALLET_PASSWD":"",
"INIT_ACCOUNT": "aiguoloveuip",
"INIT_PUB_KEY": "EOS5YCbPBQqYoaMZKHkK2FhoNDSYFekqXSpYeWiCGDHCxU9w2U6mr ",
"INIT_PRIV_KEY": "5JVK7ndrrqxZVzeM6MEMHb7QiULdxDuoA2upc37DqJhwCLTdG3y",
"INIT_URL":"http://eos.aiguoloveuip.com"
}
01_BIOS_CONTRACT.sh代码
#!/bin/bash
SOURCES_FOLDER="$( jq -r '.SOURCES_FOLDER' "00_CONFIG.conf" )"
CONTRACTS_FOLDER="$SOURCES_FOLDER/build/contracts"
EOSIO_PRODUCER_KEY="$( jq -r '.EOSIO_PRODUCER_PUB_KEY' "00_CONFIG.conf" )"
./cleos.sh set contract eosio $CONTRACTS_FOLDER/eosio.bios -p eosio
# only eosio initial producer.. 注意这里我们没有将eosio作为生产者,因为后面我们要投票,大于15%票数才会主网才算真正启动,然后eosio就会停止出块,由投票权重前21个节点出块
#./cleos.sh push action eosio setprods '{"schedule":[{"producer_name":"eosio","block_signing_key":"'$EOSIO_PRODUCER_KEY'"}]}' -p eosio
02_SYSTEM_ACCOUNTS.sh代码
#!/bin/bash
./cleos.sh create account eosio eosio.bpay EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
./cleos.sh create account eosio eosio.msig EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
./cleos.sh create account eosio eosio.names EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
./cleos.sh create account eosio eosio.ram EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
./cleos.sh create account eosio eosio.ramfee EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
./cleos.sh create account eosio eosio.saving EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
./cleos.sh create account eosio eosio.stake EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
./cleos.sh create account eosio eosio.token EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
./cleos.sh create account eosio eosio.vpay EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
03_TOKENMSIG_CONTRACTS.sh代码
#!/bin/bash
SOURCES_FOLDER="$( jq -r '.SOURCES_FOLDER' "00_CONFIG.conf" )"
CONTRACTS_FOLDER="$SOURCES_FOLDER/build/contracts"
./cleos.sh set contract eosio.token $CONTRACTS_FOLDER/eosio.token -p eosio.token
./cleos.sh set contract eosio.msig $CONTRACTS_FOLDER/eosio.msig -p eosio.msig
04_TOKEN_CREATE_ISSUE.sh代码
#!/bin/bash
./cleos.sh push action eosio.token create '["eosio", "1000000000.0000 EOS", 0, 0, 0]' -p eosio.token
./cleos.sh push action eosio.token issue '["eosio", "1000000000.0000 EOS", "init"]' -p eosio
05_SYSTEM_CONTRACTS.sh代码
#!/bin/bash
SOURCES_FOLDER="$( jq -r '.SOURCES_FOLDER' "00_CONFIG.conf" )"
CONTRACTS_FOLDER="$SOURCES_FOLDER/build/contracts"
./cleos.sh set contract eosio $CONTRACTS_FOLDER/eosio.system -p eosio
./cleos.sh push action eosio setpriv '["eosio.msig",1]' -p eosio
06_TEST_ACCOUNTS.sh代码
#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
INIT_PUB_KEY="$( jq -r '.INIT_PUB_KEY' "00_CONFIG.conf" )"
./cleos.sh system newaccount eosio $INIT_ACCOUNT $INIT_PUB_KEY $INIT_PUB_KEY --stake-net "50.0000 EOS" --stake-cpu "500.0000 EOS" --buy-ram-kbytes 8888
07_TEST_ACCOUNTS_TRANSFER.sh代码
#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
#这里我们转2亿个EOS,为后面抵押做准备,要大于EOS总数的15%,也就是1.5亿
./cleos.sh transfer eosio $INIT_ACCOUNT "200000000.0000 EOS" "init"
10_REGPRODUCER.sh 注册成为bp节点
#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
INIT_PUB_KEY="$( jq -r '.INIT_PUB_KEY' "00_CONFIG.conf" )"
INIT_URL="$( jq -r '.INIT_URL' "00_CONFIG.conf" )"
./cleos.sh system regproducer $INIT_ACCOUNT $INIT_PUB_KEY "$INIT_URL" -p INIT_ACCOUNT
11_STAKE_TOKENS.sh cpu和net各抵押1亿EOS,就满足大于15%
#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
./cleos.sh push action eosio delegatebw '{"from":"'$INIT_ACCOUNT'", "receiver":"'$INIT_ACCOUNT'", "stake_net_quantity":"100000000.0000 EOS", "stake_cpu_quantity":"100000000.0000 EOS", "transfer": false}' -p $INIT_ACCOUNT
13_VOTE_PRODUCER.sh 执行该命令后,创世节点开始停止出块
#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
./cleos.sh system voteproducer prods $INIT_ACCOUNT $INIT_ACCOUNT -p $INIT_ACCOUNT
cleos.sh的脚本
#!/bin/bash
CLEOS=/eos/home/Jungle/private_chain/eos-source/build/programs/cleos/cleos
$CLEOS -u http://172.26.247.122:8884 --wallet-url http://172.26.247.122:55553 "$@"
之后执行各个脚本
#1-5是主网BIOS启动过程
./01_BIOS_CONTRACT.sh
./02_SYSTEM_ACCOUNTS.sh
./03_TOKENMSIG_CONTRACTS.sh
./04_TOKEN_CREATE_ISSUE.sh
./05_SYSTEM_CONTRACTS.sh
#6-10 是创建新账户并注册生产节点,抵押,投票,过程
./06_TEST_ACCOUNTS.sh
./07_TEST_ACCOUNTS_TRANSFER.sh
./10_REGPRODUCER.sh
./11_STAKE_TOKENS.sh
./13_VOTE_PRODUCER.sh
#注意运行完这个命令后,创世节点停止出块
#等到bp节点启动后,bp节点开始出块,创世节点转为接收区块,类似出现如下信息:1998000ms thread-0 controller.cpp:769 start_block ] promoting proposed schedule (set in block 404) to pending; current block: 405 lib: 404 schedule: {"version":1,"producers":[{"producer_name":"aiguoloveuip","block_signing_key":"EOS5YCbPBQqYoaMZKHkK2FhoNDSYFekqXSpYeWiCGDHCxU9w2U6mr"}]}
出块节点aiguoloveuip的启动
config.ini中的配置
get-transactions-time-limit = 30
max-transaction-time=3000 #防止产生transaction too long 错误
#config.ini文件中的genesis-json没有生效,所以启动节点是要指明该文件--genesis-json
#genesis-json = "/eos/home/Jungle/aiguo/JungleTestnet-aiguoloveuip/genesis.json"
http-server-address = 172.26.247.122:8885
p2p-listen-endpoint = 172.26.247.122:9005
p2p-server-address = 172.26.247.122:9005
# SSL
# Filename with https private key in PEM format. Required for https (eosio::http_plugin)
# https-server-address =
# Filename with the certificate chain to present on https connections. PEM format. Required for https. (eosio::http_plugin)
# https-certificate-chain-file =
# Filename with https private key in PEM format. Required for https (eosio::http_plugin)
# https-private-key-file =
contracts-console = true #该配置项是console端输出,用于智能合约调试,使用print()函数
http-validate-host = 0 从v1.0.9版本之后 加上该配置项才能从外部连通http server
#该值默认为1024; 如果启动node加上--filter-on "*"的话可能会出现bad acclocation 错误,issues中的#4661,所以增加了chain-state
chain-state-db-size-mb = 2048
allowed-connection = any
log-level-net-plugin = info
max-clients = 120
connection-cleanup-period = 30
network-version-match = 0
sync-fetch-span = 2000
enable-stale-production = true #要为true,不然不出块
required-participation = 33
mongodb-queue-size = 256
plugin = eosio::producer_plugin
# plugin = eosio::producer_abi_plugin 这个插件不需要添加,放开后报错
plugin = eosio::history_plugin
plugin = eosio::history_api_plugin
plugin = eosio::chain_plugin
plugin = eosio::chain_api_plugin
agent-name = aiguoloveuip
# private-key = ["EOS5YCbPBQqYoaMZKHkK2FhoNDSYFekqXSpYeWiCGDHCxU9w2U6mr","5JVK7ndrrqxZVzeM6MEMHb7QiULdxDuoA2upc37DqJhwCLTdG3y"] 注意这里的格式改变了
signature-provider = EOS5YCbPBQqYoaMZKHkK2FhoNDSYFekqXSpYeWiCGDHCxU9w2U6mr=KEY:5JVK7ndrrqxZVzeM6MEMHb7QiULdxDuoA2upc37DqJhwCLTdG3y
producer-name = aiguoloveuip
#这里我们的p2p是连的创世区块,同步数据,即使创世区块没有指定p2p,也会同步到数据
p2p-peer-address = 172.26.247.122:9004
启动节点的脚本start.sh
#!/bin/bash
NODEOS=/eos/home/Jungle/private_chain/eos-source/build/programs/nodeos/nodeos
DATADIR=/eos/home/Jungle/private_chain/chain5/
$DATADIR/stop.sh
$NODEOS --max-irreversible-block-age 500000 --data-dir $DATADIR/data/ --config-dir $DATADIR "$@" > $DATADIR/stdout.txt 2> $DATADIR/stderr.txt & echo $! > $DATADIR/nodeos.pid
启动:
第一次启动
1.需要指明genesis.json文件
2.如果删除了数据,重新启动也用该命令(--delete-all-blocks就是将data数据删除了,所以不用手动删除)
./start.sh --genesis-json genesis.json --delete-all-blocks
以后如果数据还存在的话启动
./start.sh
如果重启后出现同步数据问题:
-
可以先尝试--replay-blockchain
-
再者可以:start.sh --hard-replay-blockchain --truncate-at-block [有问题的区块编号]
-
最后不行就--delete-all-blocks
--replay-blockchain
clear chain state database and replay all blocks
--hard-replay-blockchain
clear chain state database, recover as many blocks as possible from the block log, and then replay those blocks
--delete-all-blocks
clear chain state database and block log
--truncate-at-block arg (=0)
stop hard replay / block log recovery at this block number (if set to non-zero number)
出块节点eosproducer2的启动
config.ini中的配置
get-transactions-time-limit = 30
max-transaction-time=3000
#genesis-json = "/eos/home/Jungle/aiguo/JungleTestnet-aiguoloveuip/genesis.json"
http-server-address = 172.26.247.122:8886
p2p-listen-endpoint = 172.26.247.122:9006
p2p-server-address = 172.26.247.122:9006
access-control-allow-origin = *
# SSL
# Filename with https private key in PEM format. Required for https (eosio::http_plugin)
# https-server-address =
# Filename with the certificate chain to present on https connections. PEM format. Required for https. (eosio::http_plugin)
# https-certificate-chain-file =
# Filename with https private key in PEM format. Required for https (eosio::http_plugin)
# https-private-key-file =
allowed-connection = any
log-level-net-plugin = info
max-clients = 120
connection-cleanup-period = 30
network-version-match = 0
sync-fetch-span = 2000
enable-stale-production = true
required-participation = 33
mongodb-queue-size = 256
plugin = eosio::producer_plugin
# plugin = eosio::producer_abi_plugin
plugin = eosio::chain_api_plugin
plugin = eosio::history_plugin
plugin = eosio::history_api_plugin
plugin = eosio::chain_plugin
agent-name = eosproducer2
# private-key = ["EOS5YCbPBQqYoaMZKHkK2FhoNDSYFekqXSpYeWiCGDHCxU9w2U6mr","5JVK7ndrrqxZVzeM6MEMHb7QiULdxDuoA2upc37DqJhwCLTdG3y"]
signature-provider = EOS7buuQTWf4KqdDC5xwbhaBkkNX9bnAnc7XoEXtaJTDXfzakisjs=KEY:5HskFQ7GLQ6UEoQWqCJPBjtFFCvaJ2brfS2qo5AcabRXmuwUCgz
producer-name = eosproducer2
#这里我们同步9004和9005的数据
p2p-peer-address = 172.26.247.122:9004
p2p-peer-address = 172.26.247.122:9005
在这之前我们先要创建账户,注册出块节点,转账,抵押,投票
00_CONFIG.conf
{
"SOURCES_FOLDER": "/eos/home/Jungle/private_chain/eos-source",
"EOSIO_PRODUCER_PUB_KEY": "EOS7wp9yW6a9pwrnNmaUPGLdxmZmywY3B5mLEhrqJCrsNqSuev936",
"EOSIO_PRODUCER_PRIV_KEY": "5Kk7LCFTcoyK2PjaBjPrDAYBJie2xUycHiWgChuVjvtkLEYuSgq",
"WALLET_PASSWD":"",
"INIT_ACCOUNT": "eosproducer2",
"INIT_PUB_KEY": "EOS7buuQTWf4KqdDC5xwbhaBkkNX9bnAnc7XoEXtaJTDXfzakisjs",
"INIT_PRIV_KEY": "5HskFQ7GLQ6UEoQWqCJPBjtFFCvaJ2brfS2qo5AcabRXmuwUCgz",
"INIT_URL":"http://eosproducer2.com"
}
06_TEST_ACCOUNTS.sh
#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
INIT_PUB_KEY="$( jq -r '.INIT_PUB_KEY' "00_CONFIG.conf" )"
./cleos.sh system newaccount eosio $INIT_ACCOUNT $INIT_PUB_KEY $INIT_PUB_KEY --stake-net "50.0000 EOS" --stake-cpu "500.0000 EOS" --buy-ram-kbytes 8888
07_TEST_ACCOUNTS_TRANSFER.sh
#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
./cleos.sh transfer eosio $INIT_ACCOUNT "200.0000 EOS" "init"
10_REGPRODUCER.sh
#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
INIT_PUB_KEY="$( jq -r '.INIT_PUB_KEY' "00_CONFIG.conf" )"
INIT_URL="$( jq -r '.INIT_URL' "00_CONFIG.conf" )"
./cleos.sh system regproducer $INIT_ACCOUNT $INIT_PUB_KEY "$INIT_URL" -p INIT_ACCOUNT
11_STAKE_TOKENS.sh 由于主网已经启动,这次抵押不需要太多EOS,只要权重排在前21就可以
#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
./cleos.sh push action eosio delegatebw '{"from":"'$INIT_ACCOUNT'", "receiver":"'$INIT_ACCOUNT'", "stake_net_quantity":"100.0000 EOS", "stake_cpu_quantity":"100.0000 EOS", "transfer": false}' -p $INIT_ACCOUNT
13_VOTE_PRODUCER.sh
#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
./cleos.sh system voteproducer prods $INIT_ACCOUNT $INIT_ACCOUNT -p $INIT_ACCOUNT
执行脚本
./06_TEST_ACCOUNTS.sh
./07_TEST_ACCOUNTS_TRANSFER.sh
./10_REGPRODUCER.sh
./11_STAKE_TOKENS.sh
./13_VOTE_PRODUCER.sh
启动节点的脚本 start.sh
#!/bin/bash
NODEOS=/eos/home/Jungle/private_chain/eos-source/build/programs/nodeos/nodeos
DATADIR=/eos/home/Jungle/private_chain/chain6/
$DATADIR/stop.sh
$NODEOS --max-irreversible-block-age 500000 --data-dir $DATADIR/data/ --config-dir $DATADIR "$@" > $DATADIR/stdout.txt 2> $DATADIR/stderr.txt & echo $! > $DATADIR/nodeos.pid
启动:
第一次启动(包括如果删除了数据,重新启动(--delete-all-blocks就是将data数据删除了,所以不用手动删除))
./start.sh --genesis-json genesis.json --delete-all-blocks
以后如果数据还存在的话启动
./start.sh
更多推荐
所有评论(0)