linux虚拟机中安装geth

linux虚拟机中安装geth,第1张

linux环境下的geth安装

git clone git://github.com/ethereum/go-ethereum

出现以下信息

正克隆到 'go-ethereum'...
remote: Enumerating objects: 101980, done.
接收对象中: 100% (101980/101980), 169.42 MiB | 108.00 KiB/s, done.
remote: Total 101980 (delta 0), reused 0 (delta 0), pack-reused 101980
处理 delta 中: 100% (60878/60878), done.

进入到go-ethereum下

cd go-ethereum

使用dir命令查看包下的东西

accounts      COPYING		   ethstats	  Makefile     rpc
appveyor.yml  COPYING.LESSER	   event	  metrics      SECURITY.md
AUTHORS       core		   go.mod	  miner        signer
build	      crypto		   go.sum	  mobile       swarm
circle.yml    Dockerfile	   graphql	  node	       tests
cmd	      Dockerfile.alltools  interfaces.go  oss-fuzz.sh  trie
common	      docs		   internal	  p2p
consensus     eth		   les		  params
console       ethclient		   light	  README.md
contracts     ethdb		   log		  rlp

我们直接使用make geth命令进行安装,出现以下的结果证明安装成功

build/env.sh go run build/ci.go install ./cmd/geth
>>> /usr/lib/golang/bin/go install -ldflags -X main.gitCommit=4bcc0a37ab70cb79b16893556cffdaad6974e7d8 -v ./cmd/geth
github.com/ethereum/go-ethereum/vendor/golang.org/x/sys/unix
github.com/ethereum/go-ethereum/vendor/github.com/elastic/gosigar
github.com/ethereum/go-ethereum/common/math
github.com/ethereum/go-ethereum/crypto/secp256k1
github.com/ethereum/go-ethereum/rlp
github.com/ethereum/go-ethereum/crypto
github.com/ethereum/go-ethereum/vendor/github.com/allegro/bigcache/queue
github.com/ethereum/go-ethereum/vendor/github.com/allegro/bigcache
github.com/ethereum/go-ethereum/common/prque
github.com/ethereum/go-ethereum/vendor/github.com/go-stack/stack
github.com/ethereum/go-ethereum/log
github.com/ethereum/go-ethereum/metrics
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/util
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/cache
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/comparer
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/storage
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/errors
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/filter
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/iterator
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/journal
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/memdb
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/opt
github.com/ethereum/go-ethereum/vendor/github.com/golang/snappy
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb/table
github.com/ethereum/go-ethereum/vendor/github.com/syndtr/goleveldb/leveldb
github.com/ethereum/go-ethereum/ethdb
github.com/ethereum/go-ethereum/trie
github.com/ethereum/go-ethereum/core/types
github.com/ethereum/go-ethereum
github.com/ethereum/go-ethereum/vendor/github.com/aristanetworks/goarista/monotime
github.com/ethereum/go-ethereum/common/mclock
github.com/ethereum/go-ethereum/event
github.com/ethereum/go-ethereum/accounts
github.com/ethereum/go-ethereum/vendor/github.com/deckarep/golang-set
github.com/ethereum/go-ethereum/vendor/github.com/pborman/uuid
github.com/ethereum/go-ethereum/vendor/github.com/rjeczalik/notify
github.com/ethereum/go-ethereum/vendor/golang.org/x/crypto/pbkdf2
github.com/ethereum/go-ethereum/vendor/golang.org/x/crypto/scrypt
github.com/ethereum/go-ethereum/accounts/keystore
github.com/ethereum/go-ethereum/cmd/internal/browser
github.com/ethereum/go-ethereum/common/fdlimit
github.com/ethereum/go-ethereum/vendor/github.com/hashicorp/golang-lru/simplelru
github.com/ethereum/go-ethereum/vendor/github.com/hashicorp/golang-lru
github.com/ethereum/go-ethereum/core/state
github.com/ethereum/go-ethereum/p2p/netutil
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/context
github.com/ethereum/go-ethereum/vendor/github.com/rs/xhandler
github.com/ethereum/go-ethereum/vendor/github.com/rs/cors
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/websocket
github.com/ethereum/go-ethereum/rpc
github.com/ethereum/go-ethereum/consensus
github.com/ethereum/go-ethereum/consensus/misc
github.com/ethereum/go-ethereum/consensus/clique
github.com/ethereum/go-ethereum/vendor/github.com/edsrzf/mmap-go
github.com/ethereum/go-ethereum/common/bitutil
github.com/ethereum/go-ethereum/consensus/ethash
github.com/ethereum/go-ethereum/core/rawdb
github.com/ethereum/go-ethereum/vendor/golang.org/x/sys/cpu
github.com/ethereum/go-ethereum/crypto/bn256/cloudflare
github.com/ethereum/go-ethereum/crypto/bn256
github.com/ethereum/go-ethereum/vendor/golang.org/x/crypto/ripemd160
github.com/ethereum/go-ethereum/core/vm
github.com/ethereum/go-ethereum/core
github.com/ethereum/go-ethereum/crypto/ecies
github.com/ethereum/go-ethereum/p2p/enr
github.com/ethereum/go-ethereum/p2p/enode
github.com/ethereum/go-ethereum/p2p/discover
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/httpu
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/scpd
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/soap
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/ssdp
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/html/atom
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/html
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/internal/identifier
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/transform
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/internal
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/charmap
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/japanese
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/korean
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/simplifiedchinese
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/traditionalchinese
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/internal/utf8internal
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/runes
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/unicode
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/internal/tag
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/language
github.com/ethereum/go-ethereum/vendor/golang.org/x/text/encoding/htmlindex
github.com/ethereum/go-ethereum/vendor/golang.org/x/net/html/charset
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/dcps/internetgateway1
github.com/ethereum/go-ethereum/vendor/github.com/huin/goupnp/dcps/internetgateway2
github.com/ethereum/go-ethereum/vendor/github.com/jackpal/go-nat-pmp
github.com/ethereum/go-ethereum/p2p/nat
github.com/ethereum/go-ethereum/p2p/discv5
github.com/ethereum/go-ethereum/p2p
github.com/ethereum/go-ethereum/vendor/github.com/mohae/deepcopy
github.com/ethereum/go-ethereum/dashboard
github.com/ethereum/go-ethereum/core/bloombits
github.com/ethereum/go-ethereum/eth/downloader
github.com/ethereum/go-ethereum/eth/fetcher
github.com/ethereum/go-ethereum/eth/filters
github.com/ethereum/go-ethereum/vendor/github.com/davecgh/go-spew/spew
github.com/ethereum/go-ethereum/internal/ethapi
github.com/ethereum/go-ethereum/eth/gasprice
github.com/ethereum/go-ethereum/eth/tracers/internal/tracers
github.com/ethereum/go-ethereum/vendor/gopkg.in/olebedev/go-duktape.v3
github.com/ethereum/go-ethereum/eth/tracers
github.com/ethereum/go-ethereum/miner
github.com/ethereum/go-ethereum/vendor/github.com/golang/protobuf/proto
github.com/ethereum/go-ethereum/vendor/github.com/golang/protobuf/protoc-gen-go/descriptor
github.com/ethereum/go-ethereum/accounts/usbwallet/internal/trezor
github.com/ethereum/go-ethereum/vendor/github.com/karalabe/hid
github.com/ethereum/go-ethereum/accounts/usbwallet
github.com/ethereum/go-ethereum/metrics/exp
github.com/ethereum/go-ethereum/vendor/github.com/fjl/memsize
github.com/ethereum/go-ethereum/vendor/github.com/fjl/memsize/memsizeui
github.com/ethereum/go-ethereum/vendor/github.com/mattn/go-isatty
github.com/ethereum/go-ethereum/vendor/github.com/mattn/go-colorable
github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1
github.com/ethereum/go-ethereum/internal/debug
github.com/ethereum/go-ethereum/vendor/github.com/prometheus/prometheus/util/flock
github.com/ethereum/go-ethereum/node
github.com/ethereum/go-ethereum/eth
github.com/ethereum/go-ethereum/les/flowcontrol
github.com/ethereum/go-ethereum/light
github.com/ethereum/go-ethereum/les
github.com/ethereum/go-ethereum/ethstats
github.com/ethereum/go-ethereum/vendor/github.com/influxdata/influxdb/pkg/escape
github.com/ethereum/go-ethereum/vendor/github.com/influxdata/influxdb/models
github.com/ethereum/go-ethereum/vendor/github.com/influxdata/influxdb/client
github.com/ethereum/go-ethereum/metrics/influxdb
github.com/ethereum/go-ethereum/vendor/golang.org/x/sync/syncmap
github.com/ethereum/go-ethereum/whisper/whisperv6
github.com/ethereum/go-ethereum/cmd/utils
github.com/ethereum/go-ethereum/internal/jsre/deps
github.com/ethereum/go-ethereum/vendor/github.com/fatih/color
github.com/ethereum/go-ethereum/vendor/gopkg.in/sourcemap.v1/base64vlq
github.com/ethereum/go-ethereum/vendor/gopkg.in/sourcemap.v1
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/file
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/token
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/ast
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/dbg
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/parser
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto/registry
github.com/ethereum/go-ethereum/vendor/github.com/robertkrimen/otto
github.com/ethereum/go-ethereum/internal/jsre
github.com/ethereum/go-ethereum/internal/web3ext
github.com/ethereum/go-ethereum/vendor/github.com/peterh/liner
github.com/ethereum/go-ethereum/console
github.com/ethereum/go-ethereum/ethclient
github.com/ethereum/go-ethereum/vendor/github.com/maruel/panicparse/stack
github.com/ethereum/go-ethereum/vendor/github.com/mattn/go-runewidth
github.com/ethereum/go-ethereum/vendor/github.com/mitchellh/go-wordwrap
github.com/ethereum/go-ethereum/vendor/github.com/nsf/termbox-go
github.com/ethereum/go-ethereum/vendor/github.com/gizak/termui
github.com/ethereum/go-ethereum/vendor/github.com/naoina/go-stringutil
github.com/ethereum/go-ethereum/vendor/github.com/naoina/toml/ast
github.com/ethereum/go-ethereum/vendor/github.com/naoina/toml
github.com/ethereum/go-ethereum/cmd/geth
Done building.
Run "/root/go-ethereum/build/bin/geth" to launch geth.

接下来配置一下环境,我们需要在配置文件中将环境配置进去,否则每次我们重新打开终端时都需要配置,首先我们在终端输入vim /etc/profile,出现下面的界面:

/etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

pathmunge () {
    case ":${PATH}:" in
        *:"$1":*)
            ;;
        *)
            if [ "$2" = "after" ] ; then
                PATH=$PATH:$1
            else
                PATH=$1:$PATH
            fi
    esac
}
if [ -x /usr/bin/id ]; then
    if [ -z "$EUID" ]; then
        # ksh workaround
        EUID=`/usr/bin/id -u`
        UID=`/usr/bin/id -ru`
    fi
    USER="`/usr/bin/id -un`"
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
else
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
fi

HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
else
    export HISTCONTROL=ignoredups
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
    umask 002
else
    umask 022
fi

for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
    if [ -r "$i" ]; then
        if [ "${-#*i}" != "$-" ]; then
            . "$i"
        else
            . "$i" >/dev/null
        fi
    fi
done

unset i
unset -f pathmunge
export GOROOT=/go/work/go
export GOPATT=/go/work/gopath
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

此时我们需要在配置的最后一行加入下面的配置信息

export PATH=$PATH:/root/go-ethereum/build/bin

配置完了之后使用source /etc/profile命令使配置立即生效

这时候我们就可以查看下geth是否安装成功了

geth version

出现下面的结果则是证明安装成功

Geth
Version: 1.8.27-stable
Git Commit: 4bcc0a37ab70cb79b16893556cffdaad6974e7d8
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.15.14
Operating System: linux
GOPATH=
GOROOT=/usr/lib/golang

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/929533.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-17
下一篇 2022-05-17

发表评论

登录后才能评论

评论列表(0条)

保存