가상 환경에서 실행해도 되나 본 포스팅은 개인 노트북에 멀티 부팅 (Linux & Windows) 환경을 구축하고 Linux 환경에서 진행하였다.
OS는 Ubuntu 18.04.LTS.
자세한 것은 go-ethereum git을 참고
사양은 크게 요구되지 않으나 추후 실습이 진행되면 Geth 클라우드 서비스인 Infura나 Ganache를 사용할 예정.
1. git 설치 후 go-ethereum 소스 가져오기
sudo apt-get install git -y
mkdir ethereum
cd ethereum
git clone https://github.com/ethereum/go-ethereum.git
ll
cd go-ethereum
sudo apt-get install -y build-essential golang
2. go 소스를 build 후 version 체크
make all
cd build/bin
./geth version
3. 환경변수 설정
pwd
# /home/d425/Downloads/ethereum/go-ethereum/build/bin <-- 본인 PC 경로
sudo apt-get install vim -y
vim 에디터를 설치해준 다음에 .bash_profile 안에 path 내용에 GETH의 위치를 추가해 줌.
.bash_profile은 가장 최상위 root 경로에 있음
cd ~
sudo vim .bash_profile
# .bash_profile에 입력
GETH=/home/d425/Downloads/ethereum/go-ethereum/
PATH="$PATH:$GETH/build/bin"
source .bash_profile
이렇게 하면 Geth가 전역 환경 변수에 등록되면서 빌드된 파일을 실행할 수 있게 됨.
이후 ethereum 디렉터리 위치에 test_data 디렉터리를 하나 만듬.
cd /home/d425/Downloads/ethereum
mkdir test_data
cd test_data
touch password ## To create password file
cd ..
실제 password 파일에는 아무내용도 없으며 이 password를 토대로 account를 새로 생성하겠다는 의미임.
4. 다음 command 실행
cd home/d425/Downloads/ethereum/test_data
geth --datadir test_data account new --password password
두번째 command를 10번정도 반복하는데 이는 계정을 생성하는 작업이다.
이렇게 되면 test_net 경로에 keystore라는 새로운 디렉터리가 생긴 것을 ls -al 명령어를 통해 알 수 있다.
자세한 것은 keystore 내부 파일을 확인해보면 된다.
이후 블록체인을 형성하기 위해 가장 최초의 블록(genesis.json)을 만들어주어야 한다.
vim /home/d425/Downloads/ethereum/test_data/genesis.json
genesis.json 내용
{
"config": {
"chainId": 8484,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc" : {},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x20",
"extraData" : "",
"gasLimit" : "0x47e7c5",
"nonce" : "0x0000000000000042",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00"
}
5. geth 초기화
cd /home/d425/Downloads/ethereum/test_data
geth --datadir test_data init genesis.json
6. geth 실행
cd ..
geth --networkid 8484 --nodiscover --datadir test_data --rpcaddr 0.0.0.0 --rpc --rpcport 8545 --rpccorsdomain "*" --rpcapi="db,eth,net,web3,personal,miner,admin" --miner.threads 1 console 2>> test_data/geth.log
이러면 이제 백그라운드에서 geth가 동작하고 있다.
'개발(Dev) 이야기 > etc' 카테고리의 다른 글
[Linux] Putty 에서 터미널 연결 시 백스페이스(삭제되지 않는 현상) 해결 방법 (0) | 2022.08.04 |
---|---|
ipTime 공유기에서 포트포워딩하는 방법 (0) | 2019.08.06 |
AVX (Advanced Vector eXtensions) 란? (0) | 2019.08.02 |