흔자
article thumbnail
반응형

2022.12.07 수정

geth 서비스 파일 내용 

--cache=8192를 --cache=2048로 수정.

 

2023.02.27 수정

geth datadir 
/var/lib/geth => /data/ether/geth로 수정.


Reference

카페에 가입 후 정보를 받아보는 것을 추천.

 

Ethereum 2.0 Staking... : 네이버 카페

Ethereum 2.0 Staking 에 대해 정보를 공유하는 카페입니다.

cafe.naver.com

 

Ubuntu20.04에 geth(1.10.25 버전이상)와 lighthouse 세팅하기

 

 

우분투 환경 업데이트

sudo apt update -y && sudo apt upgrade -y && sudo apt dist-upgrade -y && sudo apt autoremove -y

 

 

시간 설정

sudo timedatectl set-timezone Asia/Seoul
timedatectl status

2. 시간 설정 / 완료 화면

 

 


JWT 파일 생성하기

cd ~
sudo mkdir -p /var/lib/jwtsecret
openssl rand -hex 32 | sudo tee /var/lib/jwtsecret/jwt.hex > /dev/null

1. 최상위 폴더로 이동

2. jwtsecret 디렉토리 생성

3. 임의의 암호 생성(jwt)

 

 



JWT 파일 확인하기

sudo nano /var/lib/jwtsecret/jwt.hex

4. JWT 파일 확인하기 / 완료 화면



geth 설치하기

sudo add-apt-repository -y ppa:ethereum/ethereum

sudo apt-get update
sudo apt-get install ethereum -y

 

 

geth 계정 생성

sudo useradd --no-create-home --shell /bin/false geth

 

 

geth datadir 생성

sudo mkdir -p /data/ether/geth

테스트 환경의 경우 data 디렉토리에 용량이 할당되어 있기 때문에 datadir를 /data/geth로 지정했다.
사용자의 설정에 따라 경로는 자유롭게 지정해도 된다.

 

 

geth datadir 권한 변경

sudo chown -R geth:geth /data/ether/geth

 

 

geth 서비스 파일 생성

sudo nano /etc/systemd/system/geth.service

 

 


서비스 파일 내용
[Unit]
Description=Geth
After=network-online.target

[Service]
Type=simple
User=geth
ExecStart=geth \
  --datadir /data/ether/geth \
  --metrics \
  --pprof \
  --http \
  --http.addr=127.0.0.1 \
  --http.port=20002 \
  --http.api=personal,eth,web3,net,console \
  --allow-insecure-unlock \
  --cache=2048 \
  --port=20001 \
  --authrpc.jwtsecret /var/lib/jwtsecret/jwt.hex \
  --authrpc.vhosts="*"

Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

geth 실행 옵션에 대해서는 사용하고자 하는 목적에 따라 다를 수 있으니 참고. 

geth datadir와 jwtsecret의 경로를 확인.

 

 

서비스 파일 설정 후 새로고침

sudo systemctl daemon-reload

 

 

Lighthouse 설치

lighthouse 최신 release를 확인한 후에 설치해 주세요.

 

Releases · sigp/lighthouse

Ethereum consensus client in Rust. Contribute to sigp/lighthouse development by creating an account on GitHub.

github.com

 


버전에 맞게 수정 후에 설치
curl -LO https://github.com/sigp/lighthouse/releases/download/v3.1.2/lighthouse-v3.1.2-x86_64-unknown-linux-gnu.tar.gz

 


압축 풀기
tar xvf lighthouse-v3.1.2-x86_64-unknown-linux-gnu.tar.gz

 


lighthouse 사용 경로로 복사 후에 설치 파일 삭제 
sudo cp lighthouse /usr/local/bin
sudo rm lighthouse lighthouse-v3.1.2-x86_64-unknown-linux-gnu.tar.gz
cd ~

 

Lighthousebeacon 계정 생성

sudo useradd --no-create-home --shell /bin/false lighthousebeacon

 

 

Lighthouse Beacon 노드 설정

 

lighthousebeacon에 대한 datadir 생성 후 권한 설정

geth datadir와 마찬가지로 환경에 맞게 설정

sudo mkdir -p /data/ether/lighthouse/beacon
sudo chown -R lighthousebeacon:lighthousebeacon /data/ether/lighthouse/beacon
sudo chmod 700 /data/ether/lighthouse/beacon

 

lighthousebeacon 서비스 파일 생성

sudo nano /etc/systemd/system/lighthousebeacon.service

 


서비스 파일 내용
[Unit]
Description=Lighthouse Beacon Node
After=geth.target

[Service]
Type=simple
User=lighthousebeacon
Group=lighthousebeacon

ExecStart=/usr/local/bin/lighthouse bn \
  --network mainnet \
  --datadir /data/ether/lighthouse \
  --http \
  --http-address=0.0.0.0 \
  --validator-monitor-auto \
  --metrics \
  --execution-endpoint http://localhost:8551 \
  --execution-jwt /var/lib/jwtsecret/jwt.hex \
  --port 9002 \
  --discovery-port 9002 \
  --checkpoint-sync-url https://beaconstate.ethstaker.cc \
  --builder http://localhost:18550

Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

 


서비스 파일 변경 후엔 새로고침을 해야 한다.
sudo systemctl daemon-reload

 

 

geth, beacon 실행

sudo systemctl start geth
sudo systemctl start lighthousebeacon

 

 

실행 후에 로그 확인

sudo journalctl -f -u geth.service
sudo journalctl -f -u lighthousebeacon.service
반응형
profile

흔자

@heun_n

즐겁게 개발하고 싶은 사람입니다.