一、前期准备

① genesis.json 创世文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
"initial_timestamp": "2018-06-08T08:08:08.888",
"initial_key": "EOS7EarnUhcyYqmdnPon8rm7mBCTnBoot6o7fE2WzjvEX2TdggbL3",
"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
}
}

② config.ini 配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#producer-name = !!!!YOUR_BP_NAME!!!!!!!!
#signature-provider = YOUR_BLOCK_SIGN_PUB_KEY=KEY:YOUR_BLOCK_SIGN_PRIV_KEY
agent-name = AgentName
#blocks-dir = "blocks"
chain-state-db-size-mb = 65536
reversible-blocks-db-size-mb = 340
contracts-console = false
http-server-address = 0.0.0.0:8888
p2p-listen-endpoint = 0.0.0.0:9876
p2p-server-address = 127.0.0.1:9876
#bnet-endpoint = !!YOUR_ENDPOINT_IP_ADDRESS!!:9875
#bnet_threads = 4
http-validate-host = false
verbose-http-errors = true
abi-serializer-max-time-ms = 2000
access-control-allow-origin = *
# access-control-allow-headers =
# access-control-max-age =
#access-control-allow-credentials = false
#p2p-max-nodes-per-host = 4
# actor-whitelist =
# actor-blacklist =
# contract-whitelist =
# contract-blacklist =
# filter-on =
# 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 = 150
connection-cleanup-period = 30
network-version-match = 1
sync-fetch-span = 2000
enable-stale-production = false
max-implicit-request = 1500
pause-on-startup = false
max-transaction-time = 30
max-irreversible-block-age = -1
txn-reference-block-lag = 0
unlock-timeout = 90000
plugin = eosio::chain_api_plugin
plugin = eosio::history_plugin
plugin = eosio::history_api_plugin
plugin = eosio::chain_plugin
plugin = eosio::bnet_plugin
#plugin = net_plugin
#plugin = net_api_plugin
#bnet-connect =
#bnet-connect =
#bnet-connect =
#p2p-peer-address =
#p2p-peer-address =
#p2p-peer-address =
#p2p-peer-address = 172.2.0.100:9876
#p2p-peer-address = 172.2.0.200:9876
#Other Pub BP nodes
#p2p-peer-address =
#p2p-peer-address =
p2p-peer-address = bp.cryptolions.io:9876
p2p-peer-address = p2p.mainnet.eospace.io:88
p2p-peer-address = eu-west-nl.eosamsterdam.net:9876
p2p-peer-address = p2p.mainnet.eosgermany.online:9876
p2p-peer-address = 35.197.190.234:19878
p2p-peer-address = mainnet.genereos.io:9876
p2p-peer-address = mainnet.eospay.host:19876
p2p-peer-address = 130.211.59.178:9876
p2p-peer-address = 54.153.59.31:9999
p2p-peer-address = 94.130.250.22:9806
p2p-peer-address = peer.main.alohaeos.com:9876
p2p-peer-address = peer.eosn.io:9876
p2p-peer-address = prod.mainnet.eos.cybex.io:9888
p2p-peer-address = p2p-1.eosnetwork.io:9876
p2p-peer-address = p.jeda.one:3322
p2p-peer-address = eosbattles.com:9877
p2p-peer-address = 34.226.76.22:9876
p2p-peer-address = mainnet.eosoasis.io:9876
p2p-peer-address = node.eosflare.io:1883
p2p-peer-address = mainnet.eoscalgary.io:5222
p2p-peer-address = eos-p2p.worbli.io:33981
p2p-peer-address = 18.188.38.175:9876
p2p-peer-address = 18.221.255.38:9876
p2p-peer-address = eos.staked.us:9870
p2p-peer-address = peering.dutcheos.io:9876
p2p-peer-address = 18.188.4.97:9876
p2p-peer-address = 18.191.125.105:9876
p2p-peer-address = boot.eostitan.com:9876
p2p-peer-address = eosboot.chainrift.com:9876
p2p-peer-address = dc1.eosemerge.io:9876
p2p-peer-address = m.eosvibes.io:9876
p2p-peer-address = node1.eosphere.io:9876
p2p-peer-address = node2.eosphere.io:9876
p2p-peer-address = 45.33.60.65:9820
p2p-peer-address = peering.eosio.cr:1976
p2p-peer-address = peering.eosio.cr:5418
p2p-peer-address = 54.203.121.17:19866
p2p-peer-address = eosnode.fi:9888
p2p-peer-address = api.eosuk.io:12000
p2p-peer-address = fullnode.eoslaomao.com:443
p2p-peer-address = new.eoshenzhen.io:10034
p2p-peer-address = peer.eosio.sg:9876
p2p-peer-address = eos.nodepacific.com:9876
p2p-peer-address = 18.234.6.119:80
p2p-peer-address = eu1.eosdac.io:49876
p2p-peer-address = br.eosrio.io:9876
p2p-peer-address = p2p-public.hkeos.com:19875
p2p-peer-address = node.eosmeso.io:9876
p2p-peer-address = pub1.eostheworld.io:9876
p2p-peer-address = 807534da.eosnodeone.io:19872
p2p-peer-address = mainnet.eoseco.com:10010

3、获取EOS源代码

我们创建一个文件夹作为eos源代码的位置,例如mkdir -p /home/eosio

1
cd /home/eosio && git clone https://github.com/EOSIO/eos --recursive

那么最终eos代码的位置是,/home/eosio/eos

二、编译源代码

  • cd /home/eosio/eos && ./eosio_build.sh
  • 一路yes下去,很容易就完成了,安装过程有点漫长,耐心等待。

三、编写连接主网的shell脚本

我们创建一个专门放置eos配置文件、创世文件和区块数据的文件夹。例如mkdir -p /home/eosio/data && cd /home/eosio/data

①、编写启动节点和停止节点的shell脚本

1、启动文件 vi /home/eosio/data/start.sh

1
2
3
4
5
6
7
8
DATADIR="/home/eosio/data/"
NODEOSBINDIR="/home/eosio/eos/build/programs"
$DATADIR/stop.sh
echo -e "Starting Nodeos \n";
ulimit -s 64000
$NODEOSBINDIR/nodeos/nodeos --data-dir $DATADIR --config-dir $DATADIR "$@" > $DATADIR/stdout.txt 2> $DATADIR/stderr.txt & echo $! > $DATADIR/nodeos.pid

2、停止文件 vi /home/eosio/data/stop.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
DIR="/home/eosio/data"
if [ -f $DIR"/nodeos.pid" ]; then
pid=`cat $DIR"/nodeos.pid"`
echo $pid
kill $pid
rm -r $DIR"/nodeos.pid"
echo -ne "Stoping Nodeos"
while true; do
[ ! -d "/proc/$pid/fd" ] && break
echo -ne "."
sleep 1
done
echo -ne "\rNodeos Stopped. \n"
fi

② 把前期准备中的创世文件genesis.json以及config.ini配置文件都放在/home/eosio/data/ 里面

三、启动节点

① 初始化创世块

1
/home/eosio/eos/build/programs/nodeos/nodeos --genesis-json /home/eos/data/genesis.json --data-dir /home/eos/data --config-dir /home/eos/data

② 启动节点

  • ./home/eosio/data/start.sh
  • 不出意外,就启动成功了

四、验证是否成功连入主网络

  • curl http://127.0.0.1:8888/v1/chain/get_info
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
{ "server_version""serve : "26ec83de",
"chain_id": "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906",
"head_block_num": 493299,
"last_irreversible_block_num": 493298,
"last_irreversible_block_id": "000786f240401f6fcc24de5240ddd9fead88cbbbbec740c181258dc3e682fb96",
"head_block_id": "000786f36fafd9e98d703a004a302e86958de991dedbbc27f33c393c2adb2c6f",
"head_block_time": "2018-06-13T07:28:58",
"head_block_producer": "genesisblock",
"virtual_block_cpu_limit": 200000000,
"virtual_block_net_limit": 1048576000,
"block_cpu_limit": 199900,
"block_net_limit": 1048576
}

认准 “chain_id”: “aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906”,