Geth搭建私链的一些错误尝试

本文记录了使用Geth在Ubuntu环境中搭建私链的过程,包括遇到的错误,如节点无法连接、端口冲突和区块同步问题。最终通过指定--rpcaddr为0.0.0.0成功开启RPC服务,使得Remix可以通过外网IP连接到私链,但如何在SSH终端关闭后保持区块链运行仍然是个挑战。
摘要由CSDN通过智能技术生成

安装环境

  • Vmware虚拟机Ubuntu 18.04(后来改用云服务器)
  • go ethereum
  • 腾讯云服务器Ubuntu18.04,外网ip隐藏,内网ip为172.17.0.5
  • remix IDE

建私链的一些错误尝试(skip)

一开始在虚拟机中安装geth,尝试搭建私链

$ geth --datadir="/tmp/eth/60/01" -verbosity 6 --ipcdisable --port 30301 --http.port 8101 console 2>> /tmp/eth/60/01.log
Welcome to the Geth JavaScript console!

instance: Geth/v1.10.8-stable-26675454/linux-amd64/go1.16.4
at block: 0 (Thu Jan 01 1970 08:00:00 GMT+0800 (CST))
 datadir: /tmp/eth/60/01
 modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

To exit, press ctrl-d
> admin.nodeInfo.enode
"enode://a89d0b488a4f4042e869132b8d85a62c762a4c812cc7a5d4c3e8d8861fd0cc3ebce6be992ff4dae49c462c3dd14fad6f4e61be1f16920942d1f705e2b158ec8f@(本机校园网出口ip):30301?discport=58206"

$ geth account new
INFO [08-27|10:56:52.278] Maximum peer count                       ETH=50 LES=0 total=50
INFO [08-27|10:56:52.278] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
Your new account is locked with a password. Please give a password. Do not forget this password.
Password: (resGeth123)
Repeat password: 

Your new key was generated

Public address of the key:   0xADCf546F36B664cD750aFFa2eae36A977801a113
Path of the secret key file: /home/lxr/.ethereum/keystore/UTC--2021-08-27T02-57-05.623018726Z--adcf546f36b664cd750affa2eae36a977801a113

- You can share your public address with anyone. Others need it to interact with you.
- You must NEVER share the secret key with anyone! The key controls access to your funds!
- You must BACKUP your key file! Without the key, it's impossible to access account funds!
- You must REMEMBER your password! Without the password, it's impossible to decrypt the key!

$ geth account list
INFO [08-27|10:57:48.335] Maximum peer count                       ETH=50 LES=0 total=50
INFO [08-27|10:57:48.335] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
WARN [08-27|10:57:48.336] Sanitizing cache to Go's GC limits       provided=1024 updated=820
INFO [08-27|10:57:48.337] Set global gas cap                       cap=50,000,000
Account #0: {375f3522d25490c78ffcede5d4b22147c9550345} keystore:///home/lxr/.ethereum/keystore/UTC--2021-08-26T13-55-39.906605360Z--375f3522d25490c78ffcede5d4b22147c9550345
Account #1: {adcf546f36b664cd750affa2eae36a977801a113} keystore:///home/lxr/.ethereum/keystore/UTC--2021-08-27T02-57-05.623018726Z--adcf546f36b664cd750affa2eae36a977801a113

$ geth init --datadir ./ genesis.json
INFO [08-27|11:21:22.926] Maximum peer count                       ETH=50 LES=0 total=50
INFO [08-27|11:21:22.926] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
WARN [08-27|11:21:22.927] Sanitizing cache to Go's GC limits       provided=1024 updated=820
INFO [08-27|11:21:22.927] Set global gas cap                       cap=50,000,000
INFO [08-27|11:21:22.928] Allocated cache and file handles         database=/home/lxr/ethereum/geth/chaindata cache=16.00MiB handles=16
INFO [08-27|11:21:22.931] Writing custom genesis block 
INFO [08-27|11:21:22.933] Persisted trie from memory database      nodes=3 size=397.00B time="384.296µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [08-27|11:21:22.934] Successfully wrote genesis state         database=chaindata                         hash=288009..fd03f5
INFO [08-27|11:21:22.934] Allocated cache and file handles         database=/home/lxr/ethereum/geth/lightchaindata cache=16.00MiB handles=16
INFO [08-27|11:21:22.938] Writing custom genesis block 
INFO [08-27|11:21:22.938] Persisted trie from memory database      nodes=3 size=397.00B time="54.488µs"  gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值