小坚的技术博客

EOS主网节点搭建

本文作者:陈进坚
个人博客:https://jian1098.github.io
CSDN博客:https://blog.csdn.net/c_jian
简书:https://www.jianshu.com/u/8ba9ac5706b6
联系方式:jian1098@qq.com

环境搭建

github上下载源码,最好是2.0以后的版本,不然会有很多问题

1
git clone https://github.com/EOSIO/eos -b v2.0.3 --recursive
编译
1
2
cd eos/scripts/
./eosio_build.sh

这个过程需要几个小时的时间,完成会出现下面的内容

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
[100%] Built target print_floats


_______ _______ _______ _________ _______
( ____ \( ___ )( ____ \\__ __/( ___ )
| ( \/| ( ) || ( \/ ) ( | ( ) |
| (__ | | | || (_____ | | | | | |
| __) | | | |(_____ ) | | | | | |
| ( | | | | ) | | | | | | |
| (____/\| (___) |/\____) |___) (___| (___) |
(_______/(_______)\_______)\_______/(_______)

EOSIO has been successfully built. 00:38:51

To verify your installation run the following commands:

export PATH=${HOME}/opt/mongodb/bin:$PATH
/home/jian/opt/mongodb/bin/mongod -f /home/jian/opt/mongodb/mongod.conf &
cd /home/jian/eos/build; make test

For more information:
EOSIO website: https://eos.io
EOSIO Telegram channel @ https://t.me/EOSProject
EOSIO resources: https://eos.io/resources/
EOSIO Stack Exchange: https://eosio.stackexchange.com
EOSIO wiki: https://github.com/EOSIO/eos/wiki
安装
1
./eosio_install.sh

执行之后所有可执行程序会在/root/eosio/2.0/bin目录下

设置软连接
1
2
ln -fs /root/eosio/2.0/bin/nodeos /usr/local/bin/nodeos
ln -fs /root/eosio/2.0/bin/cleos /usr/local/bin/cleos
查看版本
1
2
nodeos -v
v1.8.11

同步区块

EOS主网区块数据很大,要同步所有区块的数据需要十几天以上,这里分别介绍同步全节点和快照(snapshots)同步的具体步骤

全节点同步

准备工作

准备至少1TB的硬盘,最好SSD

编辑配置文件
  • 注意:配置文件中的filter-on = *参数打开的话可能会由于内存数据太大导致节点程序退出,所以最好过滤其他数据,只保留指定账号的数据,格式是filter-on = eosio.token:transfer:,把eosio.token换成你的账号名即可,注意后面有个冒号。

可以编辑默认的配置文件 vi ~/.local/share/eosio/nodeos/config/config.ini,也可以自定义配置文件目录,这里我自定义在/root目录下,将下面的配置复制保存

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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#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 = 2048
contracts-console = false


http-server-address = 0.0.0.0:8888
p2p-listen-endpoint = 0.0.0.0:9876
p2p-server-address = !!YOUR_ENDPOINT_IP_ADDRESS!!:9876


http-validate-host = false
verbose-http-errors = true
abi-serializer-max-time-ms = 2000

chain-threads = 8
http-threads = 6

access-control-allow-origin = *
access-control-allow-headers = Origin, X-Requested-With, Content-Type, Accept
# access-control-max-age =
# access-control-allow-credentials = false

# wasm-runtime = wabt
wasm-runtime = eos-vm-jit
eos-vm-oc-enable = true

#produce-time-offset-us = 250000
last-block-time-offset-us = -300000


# Safely shut down node when free space remaining in the chain state database drops below this size (in MiB). (eosio::chain_plugin)
chain-state-db-guard-size-mb = 128
# Safely shut down node when free space remaining in the reverseible blocks database drops below this size (in MiB). (eosio::chain_plugin)
reversible-blocks-db-guard-size-mb = 2

p2p-max-nodes-per-host = 150

# 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

max-clients = 150
connection-cleanup-period = 30
network-version-match = 0
sync-fetch-span = 2000
enable-stale-production = false

pause-on-startup = false
max-transaction-time = 30
max-irreversible-block-age = -1
txn-reference-block-lag = 0

plugin = eosio::chain_api_plugin
plugin = eosio::history_plugin
plugin = eosio::history_api_plugin
plugin = eosio::chain_plugin

filter-on = *

#plugin = net_plugin
#plugin = net_api_plugin


#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


actor-blacklist = blacklistmee

#https://eoscorearbitration.io/wp-content/uploads/2018/07/ECAF_Arbitrator_Order_2018-06-19-AO-001.pdf
actor-blacklist = ge2dmmrqgene
actor-blacklist = gu2timbsguge
actor-blacklist = ge4tsmzvgege
actor-blacklist = gezdonzygage
actor-blacklist = ha4tkobrgqge
actor-blacklist = ha4tamjtguge
actor-blacklist = gq4dkmzzhege

#https://eoscorearbitration.io/wp-content/uploads/2018/07/ECAF_Arbitrator_Order_2018-06-22-AO-002.pdf
actor-blacklist = gu2teobyg4ge
actor-blacklist = gq4demryhage
actor-blacklist = q4dfv32fxfkx
actor-blacklist = ktl2qk5h4bor
actor-blacklist = haydqnbtgene
actor-blacklist = g44dsojygyge
actor-blacklist = guzdonzugmge
actor-blacklist = ha4doojzgyge
actor-blacklist = gu4damztgyge
actor-blacklist = haytanjtgige
actor-blacklist = exchangegdax
actor-blacklist = cmod44jlp14k
actor-blacklist = 2fxfvlvkil4e
actor-blacklist = yxbdknr3hcxt
actor-blacklist = yqjltendhyjp
actor-blacklist = pm241porzybu
actor-blacklist = xkc2gnxfiswe
actor-blacklist = ic433gs42nky
actor-blacklist = fueaji11lhzg
actor-blacklist = w1ewnn4xufob
actor-blacklist = ugunxsrux2a3
actor-blacklist = gz3q24tq3r21
actor-blacklist = u5rlltjtjoeo
actor-blacklist = k5thoceysinj
actor-blacklist = ebhck31fnxbi
actor-blacklist = pvxbvdkces1x
actor-blacklist = oucjrjjvkrom

#https://eoscorearbitration.io/wp-content/uploads/2018/07/ECAF-Temporary-Freeze-Order-2018-07-13-AO-003.pdf
actor-blacklist = neverlandwal
actor-blacklist = tseol5n52kmo
actor-blacklist = potus1111111

#https://eoscorearbitration.io/wp-content/uploads/2018/07/ECAF-Order-of-Emergency-Protection-2018-07-19-AO-004.pdf
actor-blacklist = craigspys211

#https://eoscorearbitration.io/wp-content/uploads/2018/08/ECAF-Order-of-Emergency-Protection-2018-08-07-AO-005.pdf
actor-blacklist = eosfomoplay1

#https://eoscorearbitration.io/wp-content/uploads/2018/08/ECAF-Order-of-Emergency-Protection-2018-08-28-AO-006.pdf
actor-blacklist = wangfuhuahua

#https://eoscorearbitration.io/wp-content/uploads/2018/09/ECAF-Order-of-Emergency-Protection-2018-09-07-AO-008.pdf
#https://eoscorearbitration.io/wp-content/uploads/2018/09/ECAF-Order-of-Emergency-Protection-2018-09-24-AO-010.pdf
#actor-blacklist = ha4timrzguge
actor-blacklist = guytqmbuhege

#https://eoscorearbitration.io/wp-content/uploads/2018/09/ECAF-Order-of-Emergency-Protection-2018-09-09-AO-009.pdf
actor-blacklist = huobldeposit

#https://eoscorearbitration.io/wp-content/uploads/2018/09/ECAF-Order-of-Emergency-Protection-2018-09-25-AO-011.pdf
actor-blacklist = gm3dcnqgenes
actor-blacklist = gm34qnqrepqt
actor-blacklist = gt3ftnqrrpqp
actor-blacklist = gtwvtqptrpqp
actor-blacklist = gm31qndrspqr
actor-blacklist = lxl2atucpyos

#https://eoscorearbitration.io/wp-content/uploads/2018/10/ECAF-Order-of-Emergency-Protection-2018-10-05-AO-012.pdf
actor-blacklist = g4ytenbxgqge
actor-blacklist = jinwen121212
actor-blacklist = ha4tomztgage
actor-blacklist = my1steosobag
actor-blacklist = iloveyouplay
actor-blacklist = eoschinaeos2
actor-blacklist = eosholderkev
actor-blacklist = dreams12true
actor-blacklist = imarichman55

#https://eoscorearbitration.io/wp-content/uploads/2018/10/ECAF-Order-of-Emergency-Protection-2018-10-05-AO-013.pdf
actor-blacklist = gizdcnjyg4ge

#https://eoscorearbitration.io/wp-content/uploads/2018/10/ECAF-Order-of-Emergency-Protection-2018-10-12-AO-014.pdf
actor-blacklist = gyzdmmjsgige

#https://eoscorearbitration.io/wp-content/uploads/2018/10/ECAF-Order-of-Emergency-Protection-2018-10-13-AO-015.pdf
actor-blacklist = guzdanrugene
actor-blacklist = earthsop1sys

#https://eoscorearbitration.io/wp-content/uploads/2018/10/ECAF-Order-of-Emergency-Protection-2018-10-31-AO-017.pdf
actor-blacklist = refundwallet
actor-blacklist = jhonnywalker
actor-blacklist = alibabaioeos
actor-blacklist = whitegroupes
actor-blacklist = 24cryptoshop
actor-blacklist = minedtradeos

#Manual at 2019.02.22 (MainNet gropup)
actor-blacklist = newdexmobapp
actor-blacklist = ftsqfgjoscma
actor-blacklist = hpbcc4k42nxy
actor-blacklist = 3qyty1khhkhv
actor-blacklist = xzr2fbvxwtgt
actor-blacklist = myqdqdj4qbge
actor-blacklist = shprzailrazt
actor-blacklist = qkwrmqowelyu
actor-blacklist = lhjuy3gdkpq4
actor-blacklist = lmfsopxpr324
actor-blacklist = lcxunh51a1gt
actor-blacklist = geydddsfkk5e
actor-blacklist = pnsdiia1pcuy
actor-blacklist = kwmvzswquqpb
actor-blacklist = guagddoefdqu
编辑genesis.json

将下面的配置复制保存

1
vi 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
{
"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
}
}
第一次启动

默认端口是8888

1
nodeos --config-dir . --data-dir /mnt/omnidata --genesis-json genesis.json --delete-all-blocks

--config-dir:配置文件config.ini所在目录

--data-dir:区块数据存放目录

--genesis-json:文件目录

--delete-all-blocks:删除所有旧区块数据

再次启动

不需要--genesis-json--delete-all-blocks命令

1
nodeos --config-dir . --data-dir /mnt/omnidata
停止节点

如果强制关闭nodeos,下次启动时会报错database dirty flag set (likely due to unclean shutdown): replay required

所以安全退出要使用下面的命令

1
pkill nodeos

如果出现上面的报错,在启动时需要加参数--hard-replay-blockchain重放区块,会花掉很长的时间

snapshot同步

snapshot,即快照同步,当你需要快速搭建节点,不需要之前区块的历史数据的时候适用。快照同步不需要genesis.json文件,当快照初始化完成后,区块会从快照备份的那个区块开始同步数据,包括交易和区块数据。

编辑配置文件

跟全节点同步一样。

下载快照备份文件

从以下两个网站可以下载到快照备份文件

下载完成后解压,解压得到一个.bin文件

1
tar -xzvf snapshot-106753286.bin.tar.gz
初始化快照

启动命令加上--snapshot即可,后面是解压出来的bin文件路径

1
nodeos --config-dir . --data-dir /mnt/omnidata --snapshot /mnt/omnidata/snapshot-106753286.bin

大约10分钟即可初始化完成,占用硬盘约12GB

再次启动

正常启动即可

1
nodeos --config-dir . --data-dir /mnt/omnidata
停止节点
1
pkill nodeos
-------------本文结束感谢您的阅读-------------
🐶 您的支持将鼓励我继续创作 🐶