Storage KV Node

1. Install Rust

2. Download the source code

rm -rf 0g-storage-kvgit clone -b v1.2.1 https://github.com/0glabs/0g-storage-kv.git

3. Build the source code

cd 0g-storage-kvgit submodule update --init --recursivecargo build --release

4. Copy the config_example.toml to config.toml and update the parameters

cp ~/0g-storage-kv/run/config_example.toml ~/0g-storage-kv/run/config.tomlnano ~/0g-storage-kv/run/config.toml

Paste this content:

##########################################################################                   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

sudo tee /etc/systemd/system/0gkv.service > /dev/null <<EOF[Unit]Description=0G-KV NodeAfter=network.target
[Service]User=rootWorkingDirectory=/root/0g-storage-kv/runExecStart=/root/0g-storage-kv/target/release/zgs_kv --config /root/0g-storage-kv/run/config.tomlRestart=alwaysRestartSec=10LimitNOFILE=65535StandardOutput=journalStandardError=journalSyslogIdentifier=zgs_kv
[Install]WantedBy=multi-user.targetEOF

6. Start service

sudo systemctl daemon-reload && \sudo systemctl enable 0gkv && \sudo systemctl start 0gkv && \sudo systemctl status 0gkv

Check log:

sudo journalctl -u 0gkv -f -o cat

# Stop & Remove node

sudo systemctl stop 0gkv
sudo systemctl disable 0gkvsudo rm /etc/systemd/system/0gkv.servicerm -rf $HOME/0g-storage-kv

Last updated