Install 0G Storage Node di Ubuntu-Linux
Spec VPS
CPU: 4 Core
RAM: 16 GB
Disk: 500GB
Note: disarankan menjalankan skrip di tmux atau screen, untuk menghindari vps terputus dari laptop/pc anda.
#Update dan install dependencies
sudo apt-get update
sudo apt-get install clang cmake build-essential openssl pkg-config libssl-dev jq -y
#Install go (skip step ini jika sudah install da node)
cd $HOME && \
ver="1.22.0" && \
wget "https://golang.org/dl/go$ver.linux-amd64.tar.gz" && \
sudo rm -rf /usr/local/go && \
sudo tar -C /usr/local -xzf "go$ver.linux-amd64.tar.gz" && \
rm "go$ver.linux-amd64.tar.gz" && \
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> ~/.bash_profile && \
source ~/.bash_profile && \
go version
#Install rustup (skip step ini jika sudah install da node)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. "$HOME/.cargo/env"
#Download and install binary storage node
cd $HOME
rm -rf 0g-storage-node
git clone https://github.com/0glabs/0g-storage-node.git
cd 0g-storage-node
git checkout v0.7.3
git submodule update --init
#Build storage node
cargo build --release
#Download sample config dari wak josephtran
wget -O $HOME/0g-storage-node/run/config-testnet-turbo.toml https://josephtran.co/config-testnet-turbo.toml
#Set define variable miner key (copy paste skrip di bawah ini, dan masukkan private key Anda, memang tidak terlihat, copy paste dan enter saja)
printf '\033[34mPaste private key Anda: \033[0m' && read -s PRIVATE_KEY && echo && printf '\033[32m%s\033[0m\n' "$PRIVATE_KEY"
#Set miner key (copy paste skrip di bawah ini)
sed -i 's|^\s*#\?\s*miner_key\s*=.*|miner_key = "'"$PRIVATE_KEY"'"|' $HOME/0g-storage-node/run/config-testnet-turbo.toml && echo -e "\033[32mPrivate key has been successfully added to the config file.\033[0m"
#Verifikasi config (copy paste saja, pastikan private key/miner key Anda sudah benar)
grep -E "^(miner_key|network_dir|network_enr_address|network_enr_tcp_port|network_enr_udp_port|network_libp2p_port|network_discovery_port|rpc_listen_address|rpc_enabled|db_dir|log_config_file|log_contract_address|mine_contract_address|reward_contract_address|log_sync_start_block_number|blockchain_rpc_endpoint|auto_sync_enabled|find_peer_timeout)" $HOME/0g-storage-node/run/config-testnet-turbo.toml
#Buat Service Node (supaya node berjalan otomatis, copy paste skrip di bawah ini)
sudo tee /etc/systemd/system/zgs.service > /dev/null <<EOF
[Unit]
Description=ZGS Node
After=network.target
[Service]
User=$USER
WorkingDirectory=$HOME/0g-storage-node/run
ExecStart=$HOME/0g-storage-node/target/release/zgs_node --config $HOME/0g-storage-node/run/config-testnet-turbo.toml
Restart=on-failure
RestartSec=10
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
#Start Node (copy paste saja)
sudo systemctl daemon-reload && \
sudo systemctl enable zgs && \
sudo systemctl restart zgs && \
sudo systemctl status zgs
#Cek Logs (stop, ctrl c)
tail -f ~/0g-storage-node/run/log/zgs.log.$(TZ=UTC date +%Y-%m-%d)
Use snapshot (untuk copy data Storage node, karena LogSyncHeight sudah sangat jauh, alias singkron jadi sangat lama, wak joseph kasi solusi untuk copy snapshotnya dia, memang baik uwak ni)
#Stop node terlebih dahulu
sudo systemctl stop zgs
#Install Tools
sudo apt-get update
sudo apt-get install wget lz4 aria2 pv -y
#Download snapshot (Download data Storage node, data sekitar 14GB)
cd $HOME
rm storage_0gchain_snapshot.lz4
aria2c -x 16 -s 16 -k 1M https://josephtran.co/storage_0gchain_snapshot.lz4
#Extract data
rm -rf $HOME/0g-storage-node/run/db
lz4 -c -d storage_0gchain_snapshot.lz4 | pv | tar -x -C $HOME/0g-storage-node/run
#Restart Node
sudo systemctl restart zgs && sudo systemctl status zgs
#Cek Logs lagi (pastikan tx_seq jalan, stop, ctrl c)
tail -f ~/0g-storage-node/run/log/zgs.log.$(TZ=UTC date +%Y-%m-%d)
#DONE (Cek Node Anda)
https://storagescan-newton.0g.ai/
REF:
https://service.josephtran.xyz/testnet/zero-gravity-0g/0g-storage-node/installation
0 komentar:
Posting Komentar