当前位置: 首页 > news >正文

Docker-compsoe部署prysm-beacon-chain + geth服务(geth版本v1.14.0)

1、创建目录结构

~ # mkdir -p /data/docker-compose/eth
~ # cd /data/docker-compose/eth
/data/docker-compose/eth# mkdir beacondata  eth  ethdata  prysm

2、编写prysm-beacon-chain Dockerfile和启动脚本文件

/data/docker-compose/eth# vim Dockerfile
/data/docker-compose/eth# vim beacon-start.sh
#!/bin/bash/usr/local/bin/beacon-chain generate-auth-secret/usr/local/bin/beacon-chain \--accept-terms-of-use \--execution-endpoint=http://eth:8545 \--jwt-secret=/data/prysm/jwt.hex \--checkpoint-sync-url=https://beaconstate.info \--genesis-beacon-api-url=https://beaconstate.info \--datadir /data/beacondata
# 使用 Ubuntu 20.04 作为基础镜像
FROM ubuntu:20.04# 安装必要的系统库和工具
RUN apt-get update && \apt-get install -y curl && \apt-get clean# 创建存储数据的目录
RUN mkdir -p /data/prysm
WORKDIR /data/prysm# 下载 Prysm beacon chain 二进制文件并将其复制到 /usr/local/bin/beacon-chain
RUN curl -Lo /usr/local/bin/beacon-chain https://github.com/prysmaticlabs/prysm/releases/download/v5.0.3/beacon-chain-v5.0.3-linux-amd64 && \chmod +x /usr/local/bin/beacon-chain && \ls -l /usr/local/bin/beacon-chain#拷贝启动脚本并赋予执行权限
COPY beacon-start.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/beacon-start.sh# 设定容器启动时运行的命令
ENTRYPOINT ["/usr/local/bin/beacon-start.sh"]

3、编写eth对应的Dockerfile

/data/docker-compose/eth#vim eth/Dockerfile

打eth镜像Dockerfile文件

# 使用 Ubuntu 20.04 作为基础镜像
FROM ubuntu:20.04# 安装必要的系统库和工具
RUN apt-get update && \apt-get install -y curl && \apt-get clean# 创建存储数据的目录
RUN mkdir -p /data/ethdata
WORKDIR /data/ethdata# 下载 eth 二进制文件并将其解压到 /usr/local/bin/geth
RUN curl -Lo /tmp/geth.tar.gz https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.14.0-87246f3c.tar.gz && \tar -xzf /tmp/geth.tar.gz -C /tmp/ && \mv /tmp/geth-linux-amd64-1.14.0-87246f3c/geth /usr/local/bin/ && \chmod +x /usr/local/bin/geth && \rm /tmp/geth.tar.gz# 设定容器启动时运行的命令
ENTRYPOINT ["/usr/local/bin/geth"]

4、编写docker-compose.yaml文件

version: '3.8'services:prysm-beacon-chain:build: context: .dockerfile: Dockerfilecontainer_name: prysm-beacon-chainvolumes:- ./prysm:/data/prysm- ./beacondata:/data/beacondataports:- "4000:4000"networks:- eth_networkcommand: >sh -c "/usr/local/bin/beacon-start.sh"eth:build: context: ./ethdockerfile: Dockerfilecontainer_name: ethvolumes:- ./prysm/:/data/prysm/:ro- ./ethdata:/data/ethdataports:- "3545:3545"- "8545:8545"     networks:- eth_networkcommand: --cache 4096 --http --http.api web3,eth,net,personal,txpool,engine,admin --http.addr 0.0.0.0 --http.port 3545  --datadir /data/ethdata   --allow-insecure-unlock --rpc.allow-unprotected-txs  --authrpc.addr 0.0.0.0 --authrpc.port 8545 --authrpc.vhosts localhost --maxpeers=300 --authrpc.jwtsecret /data/prysm/jwt.hex
networks:eth_network:driver: bridge 

5、启动容器

/data/docker-compose/eth# docker-compose up -d
[+] Building 1.1s (12/12) FINISHED                                                                                                                                                                                                            => [internal] load build definition from Dockerfile                                                                                                                                                                                     0.0s=> => transferring dockerfile: 1.13kB                                                                                                                                                                                                   0.0s=> [internal] load metadata for docker.io/library/ubuntu:20.04                                                                                                                                                                          0.9s=> [internal] load .dockerignore                                                                                                                                                                                                        0.0s=> => transferring context: 2B                                                                                                                                                                                                          0.0s=> [1/7] FROM docker.io/library/ubuntu:20.04@sha256:874aca52f79ae5f8258faff03e10ce99ae836f6e7d2df6ecd3da5c1cad3a912b                                                                                                                    0.0s=> [internal] load build context                                                                                                                                                                                                        0.0s=> => transferring context: 388B                                                                                                                                                                                                        0.0s=> CACHED [2/7] RUN apt-get update &&     apt-get install -y curl &&     apt-get clean                                                                                                                                                  0.0s=> CACHED [3/7] RUN mkdir -p /data/prysm                                                                                                                                                                                                0.0s=> CACHED [4/7] WORKDIR /data/prysm                                                                                                                                                                                                     0.0s=> CACHED [5/7] RUN curl -Lo /usr/local/bin/beacon-chain https://github.com/prysmaticlabs/prysm/releases/download/v5.0.3/beacon-chain-v5.0.3-linux-amd64 &&     chmod +x /usr/local/bin/beacon-chain &&     ls -l /usr/local/bin/beaco  0.0s=> [6/7] COPY beacon-start.sh /usr/local/bin/                                                                                                                                                                                           0.0s=> [7/7] RUN chmod +x /usr/local/bin/beacon-start.sh                                                                                                                                                                                    0.2s=> exporting to image                                                                                                                                                                                                                   0.0s=> => exporting layers                                                                                                                                                                                                                  0.0s=> => writing image sha256:55bbc4ebf584ed73c90d2e57dc5eaff32f3152f238e6c566af48fcc14463797d                                                                                                                                             0.0s=> => naming to docker.io/library/eth_prysm-beacon-chain                                                                                                                                                                                0.0s
[+] Running 3/3⠿ Network eth_eth_network       Created                                                                                                                                                                                                 0.1s⠿ Container eth                 Started                                                                                                                                                                                                 0.3s⠿ Container prysm-beacon-chain  Started

6、验证
1)查询容器运行情况

/data/docker-compose/eth# docker-compose ps
NAME                 COMMAND                  SERVICE              STATUS              PORTS
eth                  "/usr/local/bin/geth…"   eth                  running             0.0.0.0:3545->3545/tcp, 0.0.0.0:8545->8545/tcp, :::3545->3545/tcp, :::8545->8545/tcp
prysm-beacon-chain   "/usr/local/bin/beac…"   prysm-beacon-chain   running             0.0.0.0:4000->4000/tcp, :::4000->4000/tcp

2)查询目录结构图

/data/docker-compose/eth# tree -L 2
.
├── beacondata
│   ├── beaconchaindata
│   ├── blobs
│   ├── metaData
│   └── tosaccepted
├── beacon-start.sh
├── docker-compose.yaml
├── Dockerfile
├── eth
│   └── Dockerfile
├── ethdata
│   ├── geth
│   ├── geth.ipc
│   └── keystore
└── prysm└── jwt.hex8 directories, 8 files

4)进入eth控制台查询同步情况

/data/docker-compose/eth# docker exec -it eth /bin/bash
root@44f580801f7c:/data/ethdata# geth attach /data/ethdata/geth.ipc 
Welcome to the Geth JavaScript console!instance: Geth/v1.14.0-stable-87246f3c/linux-amd64/go1.22.2
at block: 0 (Thu Jan 01 1970 00:00:00 GMT+0000 (UTC))datadir: /data/ethdatamodules: admin:1.0 debug:1.0 engine:1.0 eth:1.0 miner:1.0 net:1.0 rpc:1.0 txpool:1.0 web3:1.0To exit, press ctrl-d or type exit
> eth.blockNumber
0
> eth.syncing
{currentBlock: 0,healedBytecodeBytes: 0,healedBytecodes: 0,healedTrienodeBytes: 0,healedTrienodes: 0,healingBytecode: 0,healingTrienodes: 0,highestBlock: 0,startingBlock: 0,syncedAccountBytes: 0,syncedAccounts: 0,syncedBytecodeBytes: 0,syncedBytecodes: 0,syncedStorage: 0,syncedStorageBytes: 0,txIndexFinishedBlocks: 0,txIndexRemainingBlocks: 1
}

5)日志查询
eth容器的日志查询

root@iZt4ndiwb4prb26wx84bsuZ:/data/docker-compose/eth# docker logs -f --tail 10 eth 
INFO [05-07|07:08:58.617] Looking for peers                        peercount=0 tried=111 static=0
INFO [05-07|07:09:08.638] Looking for peers                        peercount=0 tried=155 static=0
WARN [05-07|07:09:13.459] Post-merge network, but no beacon client seen. Please launch one to follow the chain!
INFO [05-07|07:09:18.754] Looking for peers                        peercount=1 tried=217 static=0
INFO [05-07|07:09:28.754] Looking for peers                        peercount=2 tried=86  static=0
INFO [05-07|07:09:38.757] Looking for peers                        peercount=2 tried=181 static=0
INFO [05-07|07:09:48.764] Looking for peers                        peercount=1 tried=192 static=0
INFO [05-07|07:09:58.801] Looking for peers                        peercount=1 tried=138 static=0
INFO [05-07|07:10:08.878] Looking for peers                        peercount=1 tried=171 static=0
INFO [05-07|07:10:18.956] Looking for peers                        peercount=2 tried=55  static=0
INFO [05-07|07:10:39.090] Looking for peers                        peercount=2 tried=124 static=0
INFO [05-07|07:10:49.112] Looking for peers                        peercount=2 tried=234 static=0
INFO [05-07|07:10:59.149] Looking for peers                        peercount=2 tried=204 static=0

beacon-chain日志查询

/data/docker-compose/eth# docker logs -f --tail 10 prysm-beacon-chain 
time="2024-05-07 07:11:09" level=error msg="Could not connect to execution client endpoint" error="403 Forbidden: invalid host specified
: 403 Forbidden: invalid host specified
" prefix=execution
time="2024-05-07 07:11:14" level=info msg="Processing blocks" batchSize=63 blocksPerSecond=3.1 estimatedTimeRemaining=1m39s latestProcessedSlot/currentSlot="9019841/9020154" peers=57 prefix=initial-sync startingFrom=0xbacdf551...
time="2024-05-07 07:11:23" level=warning msg="Skip processing batched blocks" error="could not process block in batch: got an unexpected error in JSON-RPC response: 403 Forbidden: invalid host specified
: received an undefined execution engine error" prefix=initial-sync
time="2024-05-07 07:11:23" level=warning msg="Skip processing batched blocks" error="beacon node doesn't have a parent in db with root: 0x7b382457f4227a872fd1cd583cb3e676cf606c4f0fa661f2b7f3c968f6543810 (in processBatchedBlocks, slot=9019905)" prefix=initial-sync
time="2024-05-07 07:11:23" level=warning msg="Skip processing batched blocks" error="beacon node doesn't have a parent in db with root: 0xcbd1a46c0325b4cb82b2f76f4cb5c4772de1d2769fd1a5fbc41c3571bb9b991e (in processBatchedBlocks, slot=9019969)" prefix=initial-sync
time="2024-05-07 07:11:23" level=warning msg="Skip processing batched blocks" error="beacon node doesn't have a parent in db with root: 0x08eff305d908b90e38b4f4ef82d77b2c23ceadf6a5b2546da144a0701e54f60b (in processBatchedBlocks, slot=9020033)" prefix=initial-sync
time="2024-05-07 07:11:40" level=info msg="Peer summary" activePeers=49 inbound=0 outbound=49 prefix=p2p
http://www.lryc.cn/news/348271.html

相关文章:

  • 前端人员如何理解进程和线程
  • Linux下网络命令
  • Php swoole和mqtt
  • Spring STOMP-连接到消息代理
  • Excel中的`MMULT`函数
  • 孩子多大可以接触python?学习python的好处
  • 四川汇昌联信:拼多多网点怎么开?大概需要多少钱?
  • ROS 2边学边练(43)-- 利用GTest写一个基本测试(C++)
  • 3.整数运算
  • uri.getQueryParameters(name)返回一个列表(List)
  • 鸿蒙ArkUI开发:常用布局【主轴】
  • Spring Security 入门 2
  • C++初阶学习第七弹——探索STL奥秘(二)——string的模拟实现
  • 5.nginx常用命令和日志定时切割
  • Redis-详解(基础)
  • 记录minio的bug(Object name contains unsupported characters.)
  • 【嵌入式开发 Linux 常用命令系列 7.6 -- sed 替换指定字符串】
  • C++语言的字符数组
  • 24届电信红队实习生面经
  • linux下使用jexus部署aspnet站点
  • 代码随想录训练营Day 27|理论基础、力扣 77. 组合
  • Spring框架深度解析:打造你的Java应用梦工厂
  • Python 正则表达式(一)
  • Cocos Creator 3.8.x报错:5302
  • 网页如何集成各社区征文活动
  • 【知识碎片】2024_05_13
  • Day53代码随想录动态规划part13:300.最长递增子序列、674. 最长连续递增序列、718. 最长重复子数组
  • 自己动手为wordpress注册一个Carousel轮播区块
  • 基于Springboot的实习生管理系统(有报告)。Javaee项目,springboot项目。
  • 良心实用的电脑桌面便利贴,好用的便利贴便签小工具