在CentOS7.9上搭建以太坊私链
为了方便了解以太坊的操作流程,故在CentOS7上搭建以太坊的私链。下面,介绍在CentOS7.9 x64上部署以太坊的私链。
常用的以太坊源码是用Go语言编写的,所以要安装Go。这里选择Go 1.15.6。
1、搭建Go软件环境
安装方法,请参考这篇文章:
https://blog.csdn.net/sanqima/article/details/113623784
2、设置Go访问代理
go env -w GOPROXY=https://goproxy.cn,direct
3、设置CentOS的镜像源
将CentOS的镜像源设置为阿里云,具体请参考这篇文章:
https://blog.csdn.net/sanqima/article/details/117634934
4、安装工具软件
5、下载以太坊源码(Go Ethereum)
5.1 下载源码并编译
这里选择 Go Ethereum v1.9.25
下载地址: https://github.com/ethereum/go-ethereum/archive/refs/tags/v1.9.25.tar.gz
将go-ethereum-1.9.25.tar.gz存放到如下目录:
/home/levent/myProject/unit01/ethBase
依次使用如下命令:
5.2 设置geth环境
a) 打开/etc/profile
vim /etc/profile
1
b) 在/etc/profile里,添加如下语句:
c) 使能profile
source /etc/profile
d) 查看geth的版本信息
geth version
1
效果如下:

图(1) 查看geth的版本信息
若可以查看geth的版本信息,则说明geth环境配置成功。7、升级cmake到3.x
8、启动网络时间同步
9、关闭防火墙
geth会用到8078和30303端口,放开防火墙端口 8078与30303
10、设置ETH环境
其目录结构如下:

图(2) ethdata的目录结构
b) 初始化
初始化之后,会生成db/geth、db/keystore等文件夹; 其中,db/geth/chaindata中存放的是区块数据,db/keystore中存放的是账户数据。
c)启动私有链
d) 创建用户
用户的公钥文件保存在 ethdata/db/keystore里
e) 开启挖矿
f) 停止挖矿


浙公网安备 33010602011771号