首先还是说点废话吧,安装tendermint之前,你应该先安装好go。可以参考之前的博客:ubuntu18.04安装Go语言
跟go有关的很多库都被墙了,导致使用go get
去下载的相关包,很容易报错。要么是他本身无法下载,要么是他的依赖无法下载,真的超级鸡肋。
go get
可以根据要求和实际情况从互联网上下载或更新指定的代码包及其依赖包,并对它们进行编译和安装。个人认为他等同于以下两个命令:
git clone # 下载想安装的代码包以及编译、安装所需要的其他代码包
go install # 安装代码包
git clone
解决的。google.golang.org/grpc/credentials/credentials.go:35:2: cannot find package "github.com/golang/protobuf/proto" in any of:
/usr/local/go/src/github.com/golang/protobuf/proto (from $GOROOT)
/home/hadoop/GOPATH/src/github.com/golang/protobuf/proto (from $GOPATH)
# 解决办法
$ mkdir -p ~/GOPATH/src/github.com/golang
$ cd ~/GOPATH/src/github.com/golang
$ git clone https://github.com/golang/protobuf.git
github.com
开头的,虽然你能在github上找到的对应的包,但是都需要更改git clone
时的文件名。以grpc
为例:$ mkdir -p $GOPATH/src/google.golang.org/ # 创建存放路径
$ cd $GOPATH/src/google.golang.org/
$ git clone https://github.com/grpc/grpc-go grpc # clone下来的文件名为grpc-go,不满足要求,需要指定文件名grpc
$ mkdir -p $GOPATH/src/github.com/tendermint
$ cd $GOPATH/src/github.com/tendermint
$ git clone https://github.com/tendermint/tendermint.git
make get_tools
,编译tendermintmake get_tools
,编译tendermint就报错:$ cd tendermint
$ make get_tools
... # 省略中间输出,最后报错,提示找不到golang.org/x/tools/cmd/goimports
package golang.org/x/tools/cmd/goimports: unrecognized import path "golang.org/x/tools/cmd/goimports" (https fetch: Get https://golang.org/x/tools/cmd/goimports?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
Makefile:81: recipe for target 'get_tools' failed
make: *** [get_tools] Error 1
github.com/golang/tools
到$GOPATH/src/golang.org/x
目录并安装,其中tools中包含cmd/goimports
:$ mkdir -p $GOPATH/src/golang.org/x/
$ cd $GOPATH/src/golang.org/x/
$ git clone https://github.com/golang/tools.git
$ go install golang.org/x/tools/cmd/goimports
参考链接:
GO 工具包安装方法
make get_tools
,编译成功!全是各种Done
信息。$ make get_tools
--> Installing tools
./scripts/get_tools.sh
--> Installing golang/dep (22125cfaa6ddc71e145b1535d4b7ee9744fefff2)...
--> Done
... # 其他的省略
$ git config --global http.proxy 'socks5://127.0.0.1:1080'
$ git config --global https.proxy 'socks5://127.0.0.1:1080'
make get_vendor_deps
,让deps帮忙安装各种依赖包(可以直接跳过了,后面手动下载吧)make get_vendor_deps
,发现一直报错,就算自己使用s
进行了也没有用!$ make get_vendor_deps
--> Running dep
The following issues were found in Gopkg.toml:
✗ unable to deduce repository and source type for "google.golang.org/grpc": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://google.golang.org/grpc?go-get=1": Get http://google.golang.org/grpc?go-get=1: dial tcp 216.239.37.1:80: i/o timeout
ProjectRoot name validation failed
Makefile:90: recipe for target 'get_vendor_deps' failed
make: *** [get_vendor_deps] Error 1
clone
grpc到本地:$ mkdir -p $GOPATH/src/google.golang.org/
$ cd $GOPATH/src/google.golang.org/
$ git clone https://github.com/grpc/grpc-go grpc
grpc
,发现报错,缺少很多相关的依赖包:$ go install google.golang.org/grpc
google.golang.org/grpc/credentials/credentials.go:35:2: cannot find package "github.com/golang/protobuf/proto" in any of:
/usr/local/go/src/github.com/golang/protobuf/proto (from $GOROOT)
/home/hadoop/GOPATH/src/github.com/golang/protobuf/proto (from $GOPATH)
... # 忽略剩余的报错信息
mkdir
和cd
实现相同的操作目录)~/GOPATH/src/github.com/golang$ git clone [email protected]:golang/protobuf.git
~/GOPATH/src/golang.org/x$ git clone [email protected]:golang/net.git
~/GOPATH/src/golang.org/x$ git clone [email protected]:golang/sys.git
~/GOPATH/src/golang.org/x$ git clone [email protected]:golang/text.git
~/GOPATH/src/google.golang.org$ git clone [email protected]:google/go-genproto.git genproto
go install google.golang.org/grpc
安装grpc,成功安装,但是仍然没有解决问题,执行make get_vendor_deps
依然报错。。。。。make get_vendor_deps
就是替代你手动安装缺少的依赖包的过程,避免make install 时缺少依赖包。可以直接跳过make get_vendor_deps
,执行make install
,缺少什么包下载什么包,手动解决依赖。make install
,完成tendermint的安装make install
,发现报错,缺少很多的依赖包。$ make install
CGO_ENABLED=0 go install -ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short=8 HEAD`" -tags 'tendermint' ./cmd/tendermint
crypto/secp256k1/secp256k1.go:13:2: cannot find package "github.com/btcsuite/btcd/btcec" in any of:
/usr/local/go/src/github.com/btcsuite/btcd/btcec (from $GOROOT)
/home/hadoop/GOPATH/src/github.com/btcsuite/btcd/btcec (from $GOPATH)
... # 省略
Makefile:32: recipe for target 'install' failed
make: *** [install] Error 1
git clone
相关的依赖包,完成了手动解决依赖包的烦人过程!$ mkdir -p ~/GOPATH/src/github.com/btcsuite
$ cd ~/GOPATH/src/github.com/btcsuite
$ git clone https://github.com/btcsuite/btcd.git
$ mkdir -p ~/GOPATH/src/github.com/go-kit
$ cd ~/GOPATH/src/github.com/go-kit
$ git clone https://github.com/go-kit/kit.git
$ mkdir -p ~/GOPATH/src/github.com/go-logfmt
$ cd ~/GOPATH/src/github.com/go-logfmt
$ git clone https://github.com/go-logfmt/logfmt.git
$ mkdir -p ~/GOPATH/src/github.com/golang
$ cd ~/GOPATH/src/github.com/golang
$ git clone https://github.com/golang/protobuf.git
$ mkdir -p ~/GOPATH/src/github.com/gorilla
$ cd ~/GOPATH/src/github.com/gorilla
$ git clone https://github.com/gorilla/websocket.git
$ mkdir -p ~/GOPATH/src/github.com/pkg
$ cd ~/GOPATH/src/github.com/pkg
$ git clone https://github.com/pkg/errors.git
$ mkdir -p ~/GOPATH/src/github.com/prometheus
$ cd ~/GOPATH/src/github.com/prometheus
$ git clone https://github.com/prometheus/client_golang.git
$ mkdir -p ~/GOPATH/src/github.com/beorn7
$ cd ~/GOPATH/src/github.com/beorn7
$ git clone https://github.com/beorn7/perks.git
$ mkdir -p ~/GOPATH/src/github.com/prometheus
$ cd ~/GOPATH/src/github.com/prometheus
$ git clone https://github.com/prometheus/client_model.git
# 同一目录,所以没有执行mkdir和cd
$ git clone https://github.com/prometheus/common.git
$ mkdir -p ~/GOPATH/src/github.com/matttproud
$ cd ~/GOPATH/src/github.com/matttproud
$ git clone https://github.com/matttproud/golang_protobuf_extensions.git
$ mkdir -p ~/GOPATH/src/github.com/rcrowley
$ cd ~/GOPATH/src/github.com/rcrowley
$ git clone https://github.com/rcrowley/go-metrics.git
$ mkdir -p ~/GOPATH/src/github.com/rs
$ cd ~/GOPATH/src/github.com/rs
$ git clone https://github.com/rs/cors.git
$ mkdir -p ~/GOPATH/src/github.com/prometheus
$ cd ~/GOPATH/src/github.com/prometheus
$ git clone https://github.com/prometheus/procfs.git
$ mkdir -p ~/GOPATH/src/github.com/spf13
$ cd ~/GOPATH/src/github.com/spf13
$ git clone https://github.com/spf13/viper.git
$ mkdir -p ~/GOPATH/src/github.com/syndtr
$ cd ~/GOPATH/src/github.com/syndtr
$ git clone https://github.com/syndtr/goleveldb.git
$ mkdir -p ~/GOPATH/src/github.com/tendermint
$ cd ~/GOPATH/src/github.com/tendermint
$ git clone https://github.com/tendermint/go-amino.git
$ mkdir -p ~/GOPATH/src/github.com/magiconair
$ cd ~/GOPATH/src/github.com/magiconair
$ git clone https://github.com/magiconair/properties.git
$ mkdir -p ~/GOPATH/src/github.com/hashicorp
$ cd ~/GOPATH/src/github.com/hashicorp
$ git clone https://github.com/hashicorp/hcl.git
$ mkdir -p ~/GOPATH/src/github.com/fsnotify
$ cd ~/GOPATH/src/github.com/fsnotify
$ git clone https://github.com/fsnotify/fsnotify.git
$ mkdir -p ~/GOPATH/src/github.com/davecgh
$ cd ~/GOPATH/src/github.com/davecgh
$ git clone https://github.com/davecgh/go-spew.git
$ mkdir -p ~/GOPATH/src/github.com/golang
$ cd ~/GOPATH/src/github.com/golang
$ git clone https://github.com/golang/snappy.git
$ mkdir -p ~/GOPATH/src/github.com/mitchellh
$ cd ~/GOPATH/src/github.com/mitchellh
$ git clone https://github.com/mitchellh/mapstructure.git
$ mkdir -p ~/GOPATH/src/github.com/pelletier
$ cd ~/GOPATH/src/github.com/pelletier
$ git clone https://github.com/pelletier/go-toml.git
$ mkdir -p ~/GOPATH/src/github.com/spf13
$ cd ~/GOPATH/src/github.com/spf13
$ git clone https://github.com/spf13/afero.git
$ git clone https://github.com/spf13/cobra.git
$ git clone https://github.com/spf13/cast.git
$ git clone https://github.com/spf13/pflag.git
$ git clone https://github.com/spf13/jwalterweatherman.git
# 针对/home/hadoop/GOPATH/src/golang.org/x/crypto/chacha20poly1305
~/GOPATH/src/golang.org/x$ git clone https://github.com/golang/crypto.git
~/GOPATH/src/golang.org/x$ git clone https://github.com/golang/net.git
~/GOPATH/src/golang.org/x$ git clone https://github.com/golang/sys.git
~/GOPATH/src/golang.org/x$ git clone https://github.com/golang/text.git
# 针对/home/hadoop/GOPATH/src/google.golang.org/genproto/googleapis/rpc/status
~/GOPATH/src/google.golang.org$ git clone https://github.com/google/go-genproto.git genproto
# 针对/home/hadoop/GOPATH/src/gopkg.in/yaml.v2
$ mkdir -p ~/GOPATH/src/gopkg.in
$ cd ~/GOPATH/src/gopkg.in
$ git clone https://github.com/go-yaml/yaml.git yaml.v2
make install
,成功安装tendermint!$ make install
CGO_ENABLED=0 go install -ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short=8 HEAD`" -tags 'tendermint' ./cmd/tendermint
tendermint
的版本,顺带验证tendermint
安装是否成功!$ tendermint version
0.31.5-4253e67c
tendermint
的相关命令,我们经常会使用到的是init
和node
$ tendermint
$ tendermint init
I[2019-04-29|21:40:31.004] Generated private validator module=main keyFile=/home/hadoop/.tendermint/config/priv_validator_key.json stateFile=/home/hadoop/.tendermint/data/priv_validator_state.json
I[2019-04-29|21:40:31.004] Generated node key module=main path=/home/hadoop/.tendermint/config/node_key.json
I[2019-04-29|21:40:31.005] Generated genesis file module=main path=/home/hadoop/.tendermint/config/genesis.json
$ tendermint node --proxy_app=kvstore
I[2019-04-29|21:58:35.556] Version info module=main software=0.31.5 block=10 p2p=7
I[2019-04-29|21:58:36.525] Starting Node module=main impl=Node
I[2019-04-29|21:58:36.558] Started node module=main nodeInfo="{ProtocolVersion:{P2P:7 Block:10 App:1} ID_:3e1868bb9081b6dd43a8485e71ec7fd326259317 ListenAddr:tcp://0.0.0.0:26656 Network:test-chain-1w2a1c Version:0.31.5 Channels:4020212223303800 Moniker:master Other:{TxIndex:on RPCAddress:tcp://0.0.0.0:26657}}"
# block开始流入
I[2019-04-29|21:43:05.790] Executed block module=state height=1 validTxs=0 invalidTxs=0
I[2019-04-29|21:43:06.078] Committed state module=state height=1 txs=0 appHash=0000000000000000
I[2019-04-29|21:43:07.987] Executed block module=state height=2 validTxs=0 invalidTxs=0
I[2019-04-29|21:43:08.032] Committed state module=state height=2 txs=0 appHash=0000000000000000
...
abci-cli
的原因?还是应为下面的错误。E[2019-04-29|22:28:06.558] Couldn't connect to any seeds module=p2p
Couldn't connect to any seeds
确实是因为单节点启动的原因!