본문 바로가기

BlockChain

openethereum 메인넷 구축

이더리움 메인넷 구축

1. Docker 실행

 

아래 명령어로 docker에서 ubuntu로 컨테이너를 연다.

뒤에 bash를 붙여서 바로 bash shell 실행한다.

 

docker run -it ubuntu:latest bash

 

 

1-1. docker에 필요 파일 다운로드

 

apt-get update
​
# curl및 필요한 라이브러리 다운
apt-get install -y curl
​
apt-get install -y gcc g++ pkg-config file make cmake git clang libssl-dev
​
# rustup 다운
curl https://sh.rustup.rs -sSf | sh
​
source $HOME/.cargo/env
​
# rustup 버전을 낮춰준다.
rustup override set 1.51.0
​
# 버전 확인
rustc --version
​
# yasm 다운
apt-get install -y yasm

 

 

1-2. git clone

 

클론할 git 주소

https://github.com/openethereum/openethereum.git

 

 

GitHub - openethereum/openethereum: The fast, light, and robust client for the Ethereum mainnet.

The fast, light, and robust client for the Ethereum mainnet. - GitHub - openethereum/openethereum: The fast, light, and robust client for the Ethereum mainnet.

github.com

git clone https://github.com/openethereum/openethereum.git
​
cd openethereum

 

 

1-3. build

build 명령어 사용

 

cargo build --release --features final

 

 

1-4. 환경변수 설정

 

원래는 ./target/release/openethereum안에 있는 내용을 사용하기 위해서 위에 있는 명령어를 전부 입력해 줘야 하는데 그명령어를 openethereum한 단어로 줄이기 위해서 환경변수를 설정해 준다.

 

# vi 명령어를 위해서 vim install
apt-get install vim
​
vi ~/.bashrc
​
# 환경변수 설정파일 바로 뒤에 파일을 위치로 설정한다.
export PATH=/openethereum/target/release:$PATH
​
# Path 초기화
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
​
# 변경 path 적용
source ~/.bashrc

2. 컨테이너 이미지화

 

exit 명령어로 local terminal로 나간다.

아래 명령어로 방금 만든 container id 를 확인한다.

 

docker ps -a

 

아이디를 확인했으면 아래 명령어로 컨테이너를 이미지로 만든다

 

docker commit [containerId] [이미지명:태그]
​
예) docker commit 2db427dfd358 heini/ethnetwork:v1

3. docker-compose 파일로 container로 만든 이미지 실행시키기

 

Docker-compose 만들기

목적

  1. 컨테이너 생성
  2. Volume 쉽게 잡으려고

 

필요한 파일

  1. Docker-compose.yaml > 컨테이너 생성및 볼륨 설정
  2. Config.toml > 데몬의 기본 설정을 바꿀 수 있는 파일 (.env)
  3. genesis.json > 블럭정보 내용을 담고 있음. (chain.json으로 많이 씀)
  4. Password > account new 할때 만든 비밀번호
  5. Nodes > 피어 관련 내용
  6. Keys > account 관련된 내용들

 

 

3-1. 계정 만들기

 

container 다시 실행 후 bash shell 열기

 

docker start [컨테이너 명]
docker attach [컨테이너 명]

 

이제 openethereum account new를 이용해서 계정을 생성해 줄 것 이다.

패스워드 설정 하기 (2번)

그다음에 16진수 값이 나오는데 미리 메모해 주기

Local 디렉토리 안에 nodes, password 파일을 확장자 없이 만들기

Docker-compose.yaml도 만들어주기

위에서 설정해 뒀던 account password값을 password 파일에 넣어준다.

 

 

3-2. Docker-compose 파일에서 image를 내가 만든 이미지로 변경

 

 

3-3. Genesis.json파일 변경

genesis.json파일에서 lists에 방금 생성한 계정 4개를 입력해준다.

그 아래 코인이 들어갈 account도 바꿔준다.

 

 

3-4. Keys 파일 넣어주기

 

cd $HOME/.local/share/openethereum/keys/ethereum

 

위 폴더 안에서 ls -al 로 파일을 확인해보면 3-1 에서 만들었던 계정들의 비밀키가 UTC로 시작하는 파일안에 들어가 있다.

그 파일내용을 keys안에 계정들에 넣어주고 같은 내용을 UTC로 시작하는 비밀키 파일을 만든후 넣어준다.

 

 

3-5. config.toml

 

각각의 config.toml파일에는 하나씩 늘어나는 포트번호를 적어준다.

이렇게 한후 docker-compose up을 해주면 도커로 mainnet을 돌리게 된다.

'BlockChain' 카테고리의 다른 글

부트스트랩 노드  (1) 2022.03.28
[EVM] 이더리움 가상머신  (0) 2022.03.21
머클 패트리시아 트리  (0) 2022.03.14
스마트 컨트랙트 연산 gas(가스) 소모  (0) 2021.10.26
스마트 컨트렉트, WEB3, 솔리디티  (0) 2021.10.12