在Ubuntu系统中使用HECO二进制文件部署HECO主网同步节点

在Ubuntu系统中使用HECO二进制文件部署HECO主网同步节点

注:因监管问题,hecochain.com域名相关的网页无法进行查看。

本篇文档开始之前,大概说明一下本次HECO同步的情况:

  • 服务器环境
服务器:阿里云服务器
CPU:8核
内存:32GB
数据盘:1T SSD 数据盘
带宽:独享 30M
  • 软件环境
Ubuntu 20.04.3

一、下载HECO二进制文件

  • 下载HECO二进制文件
cd /data/heco
wget https://github.com/HuobiGroup/huobi-eco-chain/releases/download/v1.2.0/geth-linux-amd64
  • 授予可执行权限
chmod +x geth-linux-amd64

二、编辑heco主网配置文件

cd /data/heco
cat config.toml

[Eth]
SyncMode = "fast"
TrieCleanCacheRejournal= 300000000000

[Eth.Miner]
GasFloor = 8000000
GasCeil = 8000000
GasPrice = 0
Recommit = 3000000000
Noverify = false

[Eth.Ethash]
CacheDir = "ethash"
CachesInMem = 2
CachesOnDisk = 3
CachesLockMmap = false
DatasetDir = "/data/heco/data/.ethash"
DatasetsInMem = 1
DatasetsOnDisk = 2
DatasetsLockMmap = false
PowMode = 0

[Eth.TxPool]
Locals = []
NoLocals = false
Journal = "transactions.rlp"
Rejournal = 3600000000000
PriceLimit = 1
PriceBump = 10
AccountSlots = 16
GlobalSlots = 4096
AccountQueue = 64
GlobalQueue = 1024
Lifetime = 10800000000000

[Node]
DataDir = "/data/heco/data"
InsecureUnlockAllowed = true
NoUSB = true
IPCPath = "geth.ipc"
HTTPHost = "0.0.0.0"
HTTPPort = 8545
HTTPCors = ["*"]
HTTPVirtualHosts = ["*"]
HTTPModules = ['eth', 'net', 'web3']

WSHost = "0.0.0.0"
WSPort = 8546
WSModules = ['eth', 'net', 'web3']

GraphQLVirtualHosts = ["localhost"]

[Node.P2P]
MaxPeers = 50
NoDiscovery = false

ListenAddr = ":32668"
EnableMsgEvents = false

[Node.HTTPTimeouts]
ReadTimeout = 30000000000
WriteTimeout = 30000000000
IdleTimeout = 120000000000
  • 修改HECO主网配置文件

HTTPHost: HTTP-RPC服务连接白名单,此参数的值默认为 "localhost",仅允许本地可访问,可设置为:"0.0.0.0"

HTTPVirtualHosts:HTTP-RPC服务监听接口,此参数的值默认为 ["localhost"],可设置为:HTTPVirtualHosts = ["*"]

三、二进制启动HECO主网

3.1 下载bsc主网快照数据

  • 安装linux下的窗口管理器工具:screen
apt-get install screen -y

3.2 启动HECO主网节点

screen -S heco /data/heco/geth-linux-amd64 --config /data/heco/config.toml --logpath /data/heco/logs

参数说明:

--config:指定HECO节点配置文件 --logpath:指定HECO节点日志目录

  • 查看节点日志启动状态
# head -100 chain.log 
INFO [10-18|18:27:38.096] Starting Geth on Ethereum mainnet... 
INFO [10-18|18:27:38.096] Bumping default cache on mainnet         provided=1024 updated=4096
INFO [10-18|18:27:38.097] Maximum peer count                       ETH=50 LES=0 total=50
INFO [10-18|18:27:38.097] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
WARN [10-18|18:27:38.097] Option nousb is deprecated and USB is deactivated by default. Use --usb to enable 
WARN [10-18|18:27:38.098] Sanitizing cache to Go's GC limits       provided=4096 updated=2606
INFO [10-18|18:27:38.098] Set global gas cap                       cap=25,000,000
WARN [10-18|18:27:38.098] Sanitizing invalid miner gas price       provided=0    updated=1,000,000,000
INFO [10-18|18:27:38.098] Allocated trie memory caches             clean=390.00MiB dirty=651.00MiB
INFO [10-18|18:27:38.098] Allocated cache and file handles         database=/data/heco/data/geth/chaindata cache=1.27GiB handles=32767
INFO [10-18|18:27:38.114] Opened ancient database                  database=/data/heco/data/geth/chaindata/ancient readonly=false
INFO [10-18|18:27:38.115] Writing default main-net genesis block 
INFO [10-18|18:27:38.115] Persisted trie from memory database      nodes=5 size=742.00B time="37.858µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [10-18|18:27:38.115] Initialised chain configuration          config="{ChainID: 128 Homestead: 0 DAO: <nil> DAOSupport: true EIP150: 0 EIP155: 0 EIP158: 0 Byzantium: 0 Constantinople: 0 Petersburg: 0 Istanbul: 0, Muir Glacier: <nil>, RedCoastBlock: 6618800, Berlin: 8577000, London: 8577000, Engine: congress}"
INFO [10-18|18:27:38.115] Initialising Ethereum protocol           network=128 dbversion=<nil>
INFO [10-18|18:27:38.116] Loaded most recent local header          number=0 hash=5751d1..4cb144 td=1 age=10mo3w10h
INFO [10-18|18:27:38.116] Loaded most recent local full block      number=0 hash=5751d1..4cb144 td=1 age=10mo3w10h
INFO [10-18|18:27:38.116] Loaded most recent local fast block      number=0 hash=5751d1..4cb144 td=1 age=10mo3w10h
WARN [10-18|18:27:38.117] Failed to load snapshot, regenerating    err="missing or corrupted snapshot"
INFO [10-18|18:27:38.117] Rebuilding state snapshot 
INFO [10-18|18:27:38.117] JamConfig sanity PeriodsSecs             old=0 new=3
INFO [10-18|18:27:38.117] JamConfig sanity JamSecs                 old=0 new=15
INFO [10-18|18:27:38.117] JamConfig sanity UnderPricedFactor       old=0 new=3
INFO [10-18|18:27:38.117] JamConfig sanity PendingFactor           old=0 new=1
INFO [10-18|18:27:38.117] JamConfig sanity MaxValidPendingSecs     old=0 new=300
INFO [10-18|18:27:38.117] Resuming state snapshot generation       root=51729b..61d32f accounts=0 slots=0 storage=0.00B elapsed="544.689µs"
INFO [10-18|18:27:38.117] Generated state snapshot                 accounts=4 slots=0 storage=259.00B elapsed="780.136µs"
INFO [10-18|18:27:38.117] Regenerated local transaction journal    transactions=0 accounts=0
INFO [10-18|18:27:38.132] Allocated fast sync bloom                size=1.27GiB
INFO [10-18|18:27:38.132] Gasprice oracle is ignoring threshold set threshold=2
INFO [10-18|18:27:38.132] Prediction started                       checkBlocks=20 Interval=3 ff=2 mf=5 lf=8 minMi=500 minLi=1000 fp=75 mp=90 minCnt=100
WARN [10-18|18:27:38.132] Error reading unclean shutdown markers   error="leveldb: not found"
INFO [10-18|18:27:38.133] Starting peer-to-peer node               instance=Geth/v1.2.0-stable-f7849a80/linux-amd64/go1.13.4
INFO [10-18|18:27:38.139] Stored checkpoint snapshot to disk       number=0 hash=5751d1..4cb144
INFO [10-18|18:27:38.145] New local node record                    seq=1 id=ef7e229d842043a6 ip=127.0.0.1 udp=32668 tcp=32668
INFO [10-18|18:27:38.149] Started P2P networking                   self=enode://e1f394741c1e2e77797d04e42da63b9f52f3717d89a33f7317ef70f3b87511869508114d5a522ba5c543d961d9ed3426a6457cbe33a550ecfc01fc36145564d1@127.0.0.1:32668
INFO [10-18|18:27:38.149] IPC endpoint opened                      url=/data/heco/data/geth.ipc
INFO [10-18|18:27:38.150] HTTP server started                      endpoint=[::]:8545 prefix= cors=* vhosts=*
INFO [10-18|18:27:38.150] WebSocket enabled                        url=ws://[::]:8546
INFO [10-18|18:27:38.151] Initialized state bloom                  items=9 errorrate=0.000 elapsed=18.155ms
ERROR[10-18|18:27:39.440] Snapshot extension registration failed   peer=98998f1a err="peer connected on snap without compatible eth support"
INFO [10-18|18:27:39.630] New local node record                    seq=2 id=ef7e229d842043a6 ip=47.242.166.213 udp=32668 tcp=32668
INFO [10-18|18:27:48.150] Block synchronisation started 
INFO [10-18|18:27:50.076] Looking for peers                        peercount=2 tried=139 static=0
INFO [10-18|18:28:01.226] Looking for peers                        peercount=2 tried=98  static=0
INFO [10-18|18:31:58.461] Imported new state entries               count=273 elapsed="3.638µs"   processed=273 pending=4369 trieretry=0 coderetry=0 duplicate=0 unexpected=0
......
INFO [10-18|18:35:19.310] Imported new block receipts              count=2048 elapsed=381.770ms   number=875,712 hash=8f1f86..3a8931 age=9mo2w5d    size=5.63MiB

四、查询是否同步完成

  • 查看当前最新区块
# curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' http://127.0.0.1:8545
{"jsonrpc":"2.0","id":1,"result":"0xa352a4"}
  • 查看当前同步状态
# curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://127.0.0.1:8545
{"jsonrpc":"2.0","id":1,"result":false}

注:结果为false为同步完成


以上,就是今天分享的全部内容了。

希望大家通过以上方式可以解决自己的实际需求,解决自己目前所遇到的问题。

如果在部署过程中有任何疑问,可以添加我的个人微信,备注:地区-职业方向-昵称,欢迎来撩,加入区块链技术交流群,与更多的区块链技术大佬学习交流。

原创不易,码字不易。 觉得这篇文章对你有点用的话,麻烦你为本文点个赞,留言或转发一下,因为这将是我输出更多优质文章的动力,感谢!

点赞 0
收藏 0
分享
本文参与登链社区写作激励计划 ,好文好收益,欢迎正在阅读的你也加入。

0 条评论

请先 登录 后评论
杰哥的技术杂货铺
杰哥的技术杂货铺
0x6e60...2aa2
江湖只有他的大名,没有他的介绍。