Skip to content

Installation

0G banner”

Hardware Requirement
1. Follow the same steps to install dependencies and Rust in Storage node
2. Download the source code
Terminal window
rm -rf 0g-storage-kv
git clone -b v1.2.1 https://github.com/0glabs/0g-storage-kv.git
3. Build the source code
Terminal window
cd 0g-storage-kv
git submodule update --init --recursive
cargo build --release
4. Copy the config_example.toml to config.toml and update the parameters
Terminal window
cp ~/0g-storage-kv/run/config_example.toml ~/0g-storage-kv/run/config.toml
nano ~/0g-storage-kv/run/config.toml

Paste this content:

Terminal window
#######################################################################
### Key-Value Stream Options ###
#######################################################################
# In KV Senario, each independent KV database abstraction has an unique stream id.
# Streams to monitor.
stream_ids = ["000000000000000000000000000000000000000000000000000000000000f2bd", "000000000000000000000000000000000000000000000000000000000000f009", "0000000000000000000000000000000000000000000000000000000000016879", "0000000000000000000000000000000000000000000000000000000000002e3d"]
#######################################################################
### DB Config Options ###
#######################################################################
# Directory to store data.
db_dir = "db"
# Directory to store KV Metadata.
kv_db_dir = "kv.DB"
#######################################################################
### Log Sync Config Options ###
#######################################################################
blockchain_rpc_endpoint = "https://evmrpc-testnet.0g.ai"
log_contract_address = "0x0460aA47b41a66694c0a73f667a1b795A5ED3556"
log_sync_start_block_number = 595059
#######################################################################
### RPC Config Options ###
#######################################################################
# Whether to provide RPC service.
rpc_enabled = true
# HTTP server address to bind for public RPC.
rpc_listen_address = "0.0.0.0:6789"
# Zerog storage nodes to download data from.
zgs_node_urls = "http://127.0.0.1:5678,http://127.0.0.1:5679"
#######################################################################
### Misc Config Options ###
#######################################################################
log_config_file = "log_config"
5. Creat service
Terminal window
sudo tee /etc/systemd/system/0gkv.service > /dev/null <<EOF
[Unit]
Description=0G-KV Node
After=network.target
[Service]
User=root
WorkingDirectory=/root/0g-storage-kv/run
ExecStart=/root/0g-storage-kv/target/release/zgs_kv --config /root/0g-storage-kv/run/config.toml
Restart=always
RestartSec=10
LimitNOFILE=65535
StandardOutput=journal
StandardError=journal
SyslogIdentifier=zgs_kv
[Install]
WantedBy=multi-user.target
EOF
6. Start service
Terminal window
sudo systemctl daemon-reload && \
sudo systemctl enable 0gkv && \
sudo systemctl start 0gkv && \
sudo systemctl status 0gkv

Check log:

Terminal window
sudo journalctl -u 0gkv -f -o cat
# Stop & Remove node
Terminal window
sudo systemctl stop 0gkv
Terminal window
sudo systemctl disable 0gkv
sudo rm /etc/systemd/system/0gkv.service
rm -rf $HOME/0g-storage-kv