CODERJH

이더리움 프라이빗 네트워크 노드 구축 본문

Ethereum Nodediscovery v5

이더리움 프라이빗 네트워크 노드 구축

CODERJH 2022. 11. 25. 09:56

도커 컨테이너 이용 구축

Docker 설치 확인

sudo docker -v

 

Docker sudo 없이 사용

sudo usermod -aG docker [현재 사용자]

sudo systemctl reboot

 

Container Ubuntu 설치

docker create -i -t --name [Container 이름] ubuntu:20.04
docker start [Container 이름]

Container Ubuntu 터미널 접속

docker attach [Container 이름]

Go 설치

apt update
apt install golang
apt install -y libgmp3-dev tree make build-essential

Go 버전 업그레이드 (1.4이상 버전 필요)

wget https://go.dev/dl/go1.19.3.linux-amd64.tar.gz
sudo tar -C /usr/local -xvf go1.19.3.linux-amd64.tar.gz
echo "export GOROOT=/usr/local/go" >> ~/.profile
echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile
source ~/.profile
mkdir -p ~/gopath
echo "export GOPATH=$HOME/gopath" >> ~/.profile
source ~/.profile
echo $GOPATH
go get golang.org/x/tools/cmd/...
rm go1.19.3.linux-amd64.tar.gz

Geth 설치

Geth clone

cd ~
mkdir ethereum
cd ethereum
git clone https://github.com/ethereum/go-ethereum
cd go-ethereum
make geth

Geth 동작 확인

cd ./build/bin
./geth

Geth 환경변수 설정

# ./build/bin 디렉토리 절대경로 확인 
pwd
/root/ethereum/go-ethereum/build/bin
vi ~/.bash_profile 
export PATH=$PATH:/root/ethereum/go-ethereum/build/bin
wq!
source ~/.bash_profile

 

genesis.json 파일 생성

{
    "difficulty": "200000",
    "gasLimit": "3100000",
    "alloc": {
        "0xe7Cfd36ACfB1109Ac1080c30Ee7a2FAC263cAAe2": {
            "balance": "100100000000000000000"
        }
    },
    "config": {
        "chainId": 12001200,
        "homesteadBlock": 0,
        "eip150Block": 0,
        "eip155Block": 0,
        "eip158Block": 0
    }
}

  • config
    • chainId  :  블록체인 네트워크를 식별하는 체인 ID.
    • homesteadBlock  :  이더리움의 Release 버전.
    • eip는 Ethereum Improvement Proposal을 의미하며 적용할지 여부를 결정할 수 있다. 기본값은 0.
  • alloc  :  제네시스 블록 생성시 지정한 지갑에 할당된 양을 채워주게 된다.
  • gasLimit  :  체인 전체에 대한 블록 당 가스 지출 제한량 설정.
  • difficulty  :  nonce값을 발견하는 난이도 설정.

genesis.json 파일 생성

geth --datadir node init genesis.json
geth --datadir node --networkid 12001200 console

자신의 enode 확인

admin.nodeInfo.enode

도커 내부 접속

docker exec -it [CONTAINER_NAMES] bash

'Ethereum Nodediscovery v5' 카테고리의 다른 글

ubuntu wireshark 빌드 버전 설치  (0) 2022.05.20
ethereum geth 설치 방법  (0) 2022.05.20