【问题标题】:Runnig geth in ec2 gives error, panic: runtime error: invalid memory address or nil pointer dereference在 ec2 中运行 geth 会出现错误,恐慌:运行时错误:无效的内存地址或 nil 指针取消引用
【发布时间】:2018-09-27 08:30:21
【问题描述】:

我想要实现的是在 aws EC2 上运行 ethereum/client-go 实例并能够从远程客户端访问它,用于玩 Rinkeby 测试网络

我正在尝试在 aws 上的 ec2 实例上运行 geth docker 映像。
当我使用以下命令运行 docker 时,出现以下错误。

sudo docker run -it -p 8545:8545 -p 30303:30303 ethereum/client-go --rpc --rinkeby --syncmode "fast" --rpc --rpcapi 'db,eth,net,web3,personal' --rpcaddr XXX.XX.XXX.XXX --cache=1024

其中 --rpcaddr XXX.XX.XXX.XXX 是我的弹性 IP

INFO [04-17|10:24:08] Maximum peer count                       ETH=25 LES=0 total=25
INFO [04-17|10:24:08] Starting peer-to-peer node               instance=Geth/v1.8.4-unstable-92c6d130/linux-amd64/go1.10.1
INFO [04-17|10:24:08] Allocated cache and file handles         database=/root/.ethereum/rinkeby/geth/chaindata cache=768 handles=1024
INFO [04-17|10:24:08] Writing custom genesis block 
INFO [04-17|10:24:08] Persisted trie from memory database      nodes=355 size=65.27kB time=1.082517ms gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [04-17|10:24:08] Initialised chain configuration          config="{ChainID: 4 Homestead: 1 DAO: <nil> DAOSupport: true EIP150: 2 EIP155: 3 EIP158: 3 Byzantium: 1035301 Constantinople: <nil> Engine: clique}"
INFO [04-17|10:24:08] Initialising Ethereum protocol           versions="[63 62]" network=4
INFO [04-17|10:24:08] Loaded most recent local header          number=0 hash=6341fd…67e177 td=1
INFO [04-17|10:24:08] Loaded most recent local full block      number=0 hash=6341fd…67e177 td=1
INFO [04-17|10:24:08] Loaded most recent local fast block      number=0 hash=6341fd…67e177 td=1
INFO [04-17|10:24:08] Regenerated local transaction journal    transactions=0 accounts=0
INFO [04-17|10:24:08] Starting P2P networking 
INFO [04-17|10:24:10] UDP listener up                          self=enode://350e33a2680260f24bd1837e59610173769023f6cf609ab59b1aca63dc867cce5d7cb520343ed9a04b8a98d5a7d08f57f9e2ee258502312fafad42d005179aab@[::]:30303
INFO [04-17|10:24:10] IPC endpoint opened                      url=/root/.ethereum/rinkeby/geth.ipc
INFO [04-17|10:24:10] IPC endpoint closed                      endpoint=/root/.ethereum/rinkeby/geth.ipc
INFO [04-17|10:24:10] Blockchain manager stopped 
INFO [04-17|10:24:10] Stopping Ethereum protocol 
INFO [04-17|10:24:10] RLPx listener up                         self=enode://350e33a2680260f24bd1837e59610173769023f6cf609ab59b1aca63dc867cce5d7cb520343ed9a04b8a98d5a7d08f57f9e2ee258502312fafad42d005179aab@[::]:30303
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa6e76b]

goroutine 76 [running]:
github.com/ethereum/go-ethereum/eth/filters.(*EventSystem).eventLoop(0xc42c694d00)
    /go-ethereum/build/_workspace/src/github.com/ethereum/go-ethereum/eth/filters/filter_system.go:434 +0x2eb
created by github.com/ethereum/go-ethereum/eth/filters.NewEventSystem
    /go-ethereum/build/_workspace/src/github.com/ethereum/go-ethereum/eth/filters/filter_system.go:113 +0x104
  1. 谁能帮忙,是什么导致了上述问题?
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa6e76b]

当我使用--rpcaddr 127.0.0.1 运行同一个 docker 时,它工作正常,但无法从远程客户端访问,

sudo docker run -it -p 8545:8545 -p 30303:30303 ethereum/client-go --rpc --rinkeby --syncmode "fast" --rpc --rpcapi 'db,eth,net,web3,personal' --rpcaddr 127.0.0.1 --cache=1024

我试过用,

  • 公共 DNS (IPv4),
  • IPv4 公共 IP 和
  • 弹性 IP

对于 --rpcaddr 值

我还授予了 aws TCP 入站和出站端口的安全权限。

我这样做对吗?这是运行 web3 提供程序的正确方法吗?

【问题讨论】:

  • 你能做到吗? --rpcaddr "0.0.0.0" 你需要允许所有(0.0.0.0)从远程客户端连接。
  • 它消除了恐慌:运行时错误:无效的内存地址或 nil 指针取消引用,但是当我尝试从同一个实例(使用 Web3)连接到提供程序时,我收到错误:无效的 JSON RPC回应:未定义@SudharsanSivasankaran
  • docker run -it -p 8545:8545 -p 30303:30303 ethereum/client-go --rpc --rinkeby --syncmode "fast" --rpc --rpcapi 'db,eth,net,web3,personal' --rpcaddr 0.0.0.0 --cache=1024 你能检查你的命令吗?它对我有用。
  • sudo docker ps 没有显示任何容器运行。
  • sudo docker ps -a 给出了最后一个命令的详细信息 31a421e78d30 ethereum/client-go "geth --rpc --rinkeb…" 12 分钟前退出 (2) 10 分钟前

标签: amazon-web-services docker amazon-ec2 ethereum geth


【解决方案1】:

在我看来你应该使用卷,因为客户端会尝试下载以太坊区块链,但在你当前的设置下,没有地方可以保存区块链。

看看这个页面: https://github.com/ethereum/go-ethereum/wiki/Running-in-Docker “要在容器启动之间持久保存下载的区块链数据,请使用 Docker 数据卷。将 /path/on/host 替换为您要存储数据的位置。”

$ docker run -it -p 30303:30303 -v /path/on/host:/root/.ethereum ethereum/client-go

试试看这是否有帮助。如果您仍然有问题,我很乐意尝试帮助或考虑查看 github 上的问题以获取 geth。我看到有人在 2017 年遇到了类似的错误并记录了一个问题,请参见此处: https://github.com/ethereum/go-ethereum/issues/15079

【讨论】:

  • 我已经附加了 28GB 卷,让我再次杀死所有进程来检查。
  • 您是否将卷附加到容器或您的 ec2 实例?
  • 仅限实例。
  • 尝试使用$ docker ...-v /location-to-volume-you-mountedt:/root/.ethereum ,如果您运行df -h,您可以检查卷在ec2实例上的安装位置
猜你喜欢
  • 2015-02-24
  • 2022-01-05
  • 1970-01-01
  • 1970-01-01
  • 2019-09-12
  • 2019-03-09
  • 1970-01-01
  • 2013-04-23
  • 2016-12-12
相关资源
最近更新 更多