본문 바로가기
IT/이더리움 Ethereum

이더리움 클라이언트 Geth 설치하기 . 실행 환경 설정

by SidePower 2022. 9. 19.

나만의 블록체인을 만드는 게 목표입니다.
이더리움 소개는 구글링하면 자료가 많으니 생략합니다.

이더리움 클라이언트는
이더리움 블록체인 네트워크에 참여하는 노드(컴퓨터)입니다.

이더리움이 프로그램에서 어떻게 동작하는지 알아보기 위해
이더리움 클라이언트를 설치 한 후에 테스트 네트워크를 구축해서
채굴도 해보고 거래도 해볼거에요.

이더리움 클라이언트 종류

클라이언트 개발 언어
go-ethereum (geth) Go
Parity Rust
cpp-ethereum C++
pyethapp Python
ethereumjs-lib JavaScript
Ethereum(J) Java



다양한 클라이언트 중에서 가장 많이 사용되는 go-ethereum (geth)를 선택했어요.

github 저장소에 있는 geth 소스를 다운로드합니다.

[root@localhost ~]# cd /usr/local
[root@localhost ~]$ git clone https://github.com/ethereum/go-ethereum.git
Cloning into 'go-ethereum'...
remote: Enumerating objects: 102941, done.
remote: Total 102941 (delta 0), reused 0 (delta 0), pack-reused 102941
Receiving objects: 100% (102941/102941), 170.97 MiB | 11.19 MiB/s, done.
Resolving deltas: 100% (61452/61452), done.

[root@localhost local]# ll
total 4
drwxr-xr-x. 2 root root 18 Dec 3 03:00 bin
drwxr-xr-x. 2 root root 6 Apr 11 2018 etc
drwxr-xr-x. 2 root root 6 Apr 11 2018 games
drwxr-xr-x. 10 root root 257 Nov 4 10:04 go
drwxr-xr-x. 36 root root 4096 Dec 3 02:59 go-ethereum
drwxr-xr-x. 2 root root 6 Apr 11 2018 include
drwxr-xr-x. 2 root root 6 Apr 11 2018 lib
drwxr-xr-x. 2 root root 6 Apr 11 2018 lib64
drwxr-xr-x. 2 root root 6 Apr 11 2018 libexec
drwxr-xr-x. 2 root root 6 Apr 11 2018 sbin
drwxr-xr-x. 5 root root 49 Nov 18 03:44 share
drwxr-xr-x. 2 root root 6 Apr 11 2018 src


geth 빌드하기

[root@localhost local]# cd go-ethereum
[root@localhost go-ethereum]$ make geth
env GO111MODULE=on go run build/ci.go install ./cmd/geth
go: downloading github.com/cespare/cp v0.1.0
go: downloading github.com/Azure/azure-storage-blob-go v0.7.0
go: downloading golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
go: downloading github.com/Azure/azure-pipeline-go v0.2.2
go: downloading github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d
>>> /usr/local/go/bin/go build -ldflags -X main.gitCommit=85064ed09b7243647ffd8c31a93c2abdbc3850d2 -X main.gitDate=20211202 -extldflags -Wl,-z,stack-size=0x800000 -trimpath -v -o /home/tmach/go-ethereum/build/bin/geth ./cmd/geth
go: downloading github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e
go: downloading github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416
go: downloading gopkg.in/urfave/cli.v1 v1.20.0
go: downloading github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea
go: downloading github.com/google/uuid v1.1.5
..
..
crypto/rand
runtime/cgo
# runtime/cgo
cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH
github.com/ethereum/go-ethereum/rlp
github.com/ethereum/go-ethereum/params
..
..
github.com/naoina/toml
util.go:46: exit status 2
exit status 1
make: *** [geth] Error 1

흑.. 빌드 에러가 발생하네요.
에러 내용을 보니 gcc가 설치 안되어 있거나 PATH가 안 잡혔네요.

gcc 먼저 설치할게요.


gcc 설치하기

[root@localhost ~]# yum list installed gcc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.kakao.com
* extras: mirror.kakao.com
* updates: mirror.kakao.com
Error: No matching Packages to list
gcc 설치 안되어 있네요. ^^;;

[root@localhost ~]# yum install gcc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.kakao.com
* extras: mirror.kakao.com
* updates: mirror.kakao.com
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.8.5-44.el7 will be installed
--> Processing Dependency: cpp = 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: libmpfr.so.4()(64bit) for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: libmpc.so.3()(64bit) for package: gcc-4.8.5-44.el7.x86_64
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-44.el7 will be installed
---> Package glibc-devel.x86_64 0:2.17-325.el7_9 will be installed
--> Processing Dependency: glibc-headers = 2.17-325.el7_9 for package: glibc-devel-2.17-325.el7_9.x86_64
--> Processing Dependency: glibc = 2.17-325.el7_9 for package: glibc-devel-2.17-325.el7_9.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.17-325.el7_9.x86_64
---> Package libmpc.x86_64 0:1.0.1-3.el7 will be installed
---> Package mpfr.x86_64 0:3.1.1-4.el7 will be installed
--> Running transaction check
---> Package glibc.x86_64 0:2.17-317.el7 will be updated
--> Processing Dependency: glibc = 2.17-317.el7 for package: glibc-common-2.17-317.el7.x86_64
---> Package glibc.x86_64 0:2.17-325.el7_9 will be an update
---> Package glibc-headers.x86_64 0:2.17-325.el7_9 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.17-325.el7_9.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.17-325.el7_9.x86_64
--> Running transaction check
---> Package glibc-common.x86_64 0:2.17-317.el7 will be updated
---> Package glibc-common.x86_64 0:2.17-325.el7_9 will be an update
---> Package kernel-headers.x86_64 0:3.10.0-1160.49.1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================
Package Arch Version Repository Size
==============================================================================
Installing:
gcc x86_64 4.8.5-44.el7 base 16 M
Installing for dependencies:
cpp x86_64 4.8.5-44.el7 base 5.9 M
glibc-devel x86_64 2.17-325.el7_9 updates 1.1 M
glibc-headers x86_64 2.17-325.el7_9 updates 691 k
kernel-headers x86_64 3.10.0-1160.49.1.el7 updates 9.0 M
libmpc x86_64 1.0.1-3.el7 base 51 k
mpfr x86_64 3.1.1-4.el7 base 203 k
Updating for dependencies:
glibc x86_64 2.17-325.el7_9 updates 3.6 M
glibc-common x86_64 2.17-325.el7_9 updates 12 M

Transaction Summary
=============================================================================
Install 1 Package (+6 Dependent packages)
Upgrade ( 2 Dependent packages)

Total download size: 48 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/9): cpp-4.8.5-44.el7.x86_64.rpm | 5.9 MB 00:00:02
(2/9): glibc-2.17-325.el7_9.x86_64.rpm | 3.6 MB 00:00:02
(3/9): glibc-devel-2.17-325.el7_9.x86_64.rpm | 1.1 MB 00:00:00
(4/9): libmpc-1.0.1-3.el7.x86_64.rpm | 51 kB 00:00:00
(5/9): mpfr-3.1.1-4.el7.x86_64.rpm | 203 kB 00:00:00
(6/9): glibc-common-2.17-325.el7_9.x86_64.rpm | 12 MB 00:00:03
(7/9): glibc-headers-2.17-325.el7_9.x86_64.rpm | 691 kB 00:00:02
(8/9): kernel-headers-3.10.0-1160.49.1.el7.x86_64.rpm | 9.0 MB 00:00:02
(9/9): gcc-4.8.5-44.el7.x86_64.rpm | 16 MB 00:00:04
------------------------------------------------------------------------------------------------------------------------------------
Total 9.8 MB/s | 48 MB 00:00:04
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : glibc-2.17-325.el7_9.x86_64 1/11
Updating : glibc-common-2.17-325.el7_9.x86_64 2/11
Installing : mpfr-3.1.1-4.el7.x86_64 3/11
Installing : libmpc-1.0.1-3.el7.x86_64 4/11
Installing : cpp-4.8.5-44.el7.x86_64 5/11
Installing : kernel-headers-3.10.0-1160.49.1.el7.x86_64 6/11
Installing : glibc-headers-2.17-325.el7_9.x86_64 7/11
Installing : glibc-devel-2.17-325.el7_9.x86_64 8/11
Installing : gcc-4.8.5-44.el7.x86_64 9/11
Cleanup : glibc-2.17-317.el7.x86_64 10/11
Cleanup : glibc-common-2.17-317.el7.x86_64 11/11
Verifying : mpfr-3.1.1-4.el7.x86_64 1/11
Verifying : glibc-devel-2.17-325.el7_9.x86_64 2/11
Verifying : gcc-4.8.5-44.el7.x86_64 3/11
Verifying : glibc-headers-2.17-325.el7_9.x86_64 4/11
Verifying : kernel-headers-3.10.0-1160.49.1.el7.x86_64 5/11
Verifying : libmpc-1.0.1-3.el7.x86_64 6/11
Verifying : glibc-common-2.17-325.el7_9.x86_64 7/11
Verifying : glibc-2.17-325.el7_9.x86_64 8/11
Verifying : cpp-4.8.5-44.el7.x86_64 9/11
Verifying : glibc-2.17-317.el7.x86_64 10/11
Verifying : glibc-common-2.17-317.el7.x86_64 11/11

Installed:
gcc.x86_64 0:4.8.5-44.el7

Dependency Installed:
cpp.x86_64 0:4.8.5-44.el7 glibc-devel.x86_64 0:2.17-325.el7_9 glibc-headers.x86_64 0:2.17-325.el7_9
kernel-headers.x86_64 0:3.10.0-1160.49.1.el7 libmpc.x86_64 0:1.0.1-3.el7 mpfr.x86_64 0:3.1.1-4.el7

Dependency Updated:
glibc.x86_64 0:2.17-325.el7_9 glibc-common.x86_64 0:2.17-325.el7_9

Complete!

버전 확인
[root@localhost ~]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


다시 geth 빌드하기

[root@localhost ~]# cd /usr/local/go-ethereum
[root@localhost go-ethereum]$ make geth
env GO111MODULE=on go run build/ci.go install ./cmd/geth
>>> /usr/local/go/bin/go build -ldflags -X main.gitCommit=85064ed09b7243647ffd8c31a93c2abdbc3850d2 -X main.gitDate=20211202 -extldflags -Wl,-z,stack-size=0x800000 -trimpath -v -o /home/tmach/go-ethereum/build/bin/geth ./cmd/geth
runtime/cgo
github.com/ethereum/go-ethereum/crypto/secp256k1
github.com/ethereum/go-ethereum/crypto
github.com/ethereum/go-ethereum/core/types
..
github.com/ethereum/go-ethereum/eth/tracers/js
github.com/ethereum/go-ethereum/eth/tracers/native
github.com/ethereum/go-ethereum/cmd/geth
Done building.
Run "./build/bin/geth" to launch geth.

에러 없이 빌드가 정상이네요. 휴~~


PATH 잡아주기

모든 계정이 geth를 다 사용할수 있게 공통PATH를 잡아줍니다.

아래 공통PATH 입니다.
/usr/local/bin
/usr/bin
/usr/local/sbin
/usr/sbin

공통PATH 디렉터리안에 실행파일을 넣어두시면
모든 계정이 다 사용할수 있습니다.
저는 /usr/local/bin 로 정할게요.

[root@localhost bin]# pwd
/usr/local/go-ethereum/build/bin
[root@localhost bin]# ll
total 43292
-rwxr-xr-x. 1 root root 44329992 Dec 3 02:59 geth
[root@localhost bin]# cp geth /usr/local/bin

[root@localhost bin]# cd /usr/local/bin
[root@localhost bin]# ll
total 43292
-rwxr-xr-x. 1 root root 44329992 Dec 3 03:00 geth

tmach 계정에 PATH를 잡아주지 않았는데요.
geth명령어 실행이 되죠.
[tmach@localhost ~]$ geth version
Geth
Version: 1.10.14-unstable
Git Commit: 85064ed09b7243647ffd8c31a93c2abdbc3850d2
Git Commit Date: 20211202
Architecture: amd64
Go Version: go1.17.3
Operating System: linux
GOPATH=
GOROOT=go


감사합니다.

반응형

댓글