为了省钱,用了aws的m6g,真是没谁了,因为安全问题,不敢用第三方的镜像,centos7又不支持m6g,于是只能硬着头皮用cento 8 arm版本。

准备工作

服务器准备

比如禁用SELINUX,开启文件数量限制这种基本操作

#当前有效
setenforce 0
#重启也有效
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

ulimit -SHn 102400
cat >> /etc/security/limits.conf << EOF
*           soft   nofile       102400
*           hard   nofile       102400
*           soft   nproc        102400
*           hard   nproc        102400
EOF

服务器环境

yum搞好
一些工具包如telnet,wget,git等,可以提前安装

因为centos8不再维护的原因。repo进行了迁移,这样干

sudo sed -i -e "s|mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-*
sudo sed -i -e "s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g" /etc/yum.repos.d/CentOS-*

安装golang

我使用yum安装最新版go是1.16。使用1.16安装go-ethereum,make时各种出错,最终还是使用手动安装最新版本解决

1、下载文件

国内下载 https://golang.google.cn/dl/

wget https://golang.google.cn/dl/go1.19.1.linux-arm64.tar.gz

2、解压文件到 /usr/local

【重要】如果之前已经安装过go的版本,先清空下go下面src,不然可能会报一些previous declaration at /usr/local/go/src/runtime/internal/atomic/atomic_amd64.go:16:24的错误
rm -rf /usr/local/go
解压go包

tar -zxf go1.19.1.linux-arm64.tar.gz -C /usr/local

3、配置环境变量,vim指令编辑 .bashrc

有人喜欢用/etc/profile,我喜欢用这个,有一次编辑后source /etc/profile碰到一个系统级别的错误,你敢信
https://bugzilla.redhat.com/show_bug.cgi?id=2025709

vim ~/.bashrc

4、在/etc/profile文件末尾添加以下配置,输入 :wq保存

#golang config
export GOROOT=/usr/local/go 
export GOPATH=/data/gopath
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

创建go的path目录

mkdir /data/gopath

5、使换将变量配置生效,并查看golang的版本

source ~/.bashrc
go version

下载和部署

1 git下载

git clone https://github.com/ethereum/go-ethereum.git
cd go-ethereum
make all

2 把geth加到全局

export PATH=$PATH:$GOROOT/bin:$GOPATH/bin:{你的目录}/go-ethereum/build/bin

3 source生效

source ~/.bashrc

4 启动

具体参数就参照geth官方文档了
https://geth.ethereum.org/docs/install-and-build/installing-geth