# 搭建0G Storage Node

By [Untitled](https://paragraph.com/@0x09b8e0b96322ce8d86032bcf8612eedbc1684b13) · 2024-04-17

---

**前言：我寫既文章只係紀錄最適合我而令我最簡單做到既方法，如果需要其他功能設定，請自行Google**

**硬體需求**

*   `Memory: 16 GB RAM`
    
*   `CPU: 4 cores`
    
*   `Disk: 500GB / 1T NVME SSD`
    
*   `Bandwidth: 500 Mbps for Download / Upload`
    

**安裝依賴項**

    sudo apt-get update
    sudo apt-get install clang cmake build-essential
    

**安裝rustup**

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    

**安裝Go**

    wget https://go.dev/dl/go1.22.2.linux-amd64.tar.gz
    

    sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.22.2.linux-amd64.tar.gz
    

    export PATH=$PATH:/usr/local/go/bin
    

**下載原始碼**

    git clone https://github.com/0glabs/0g-storage-node.git
    

**建構原始碼**

    cd 0g-storage-node
    git submodule update --init
    

    cargo build --release
    

更新`run/config.toml`

miner\_id 可以用 `echo -n "your_miner_id" | sha256sum`隨機新成，要改your\_miner\_id既值

miner\_key 係任何EVM錢包既private key，唔好輸入開頭0x

    nano run/config.toml
    

    network_dir = "network"
    network_listen_address = "0.0.0.0"
    network_libp2p_port = 1234
    network_discovery_port = 1234
    network_target_peers = 3
    network_boot_nodes = ["/ip4/54.219.26.22/udp/1234/p2p/16Uiu2HAmPxGNWu9eVAQPJww79J32pTJLKGcpjRMb4Qb8xxKkyuG1","/ip4/52.52.127.117/udp/1234/p2p/16Uiu2HAm93Hd5azfhkGBbkx1zero3nYHvfjQYM2NtiW4R3r5bE2g"]
    network_libp2p_nodes = []
    network_private = false
    network_disable_discovery = false
    
    blockchain_rpc_endpoint = "https://rpc-testnet.0g.ai"
    log_contract_address = "0x22C1CaF8cbb671F220789184fda68BfD7eaA2eE1"
    log_sync_start_block_number = 512567
    
    rpc_enabled = true
    rpc_listen_address = "0.0.0.0:5678"
    
    db_dir = "db"
    
    log_config_file = "log_config"
    
    mine_contract_address = "0x8B9221eE2287aFBb34A7a1Ef72eB00fdD853FFC2"
    
    # set these two fields if you want to become a miner
    # your miner id, can be arbitrary hex string with 64 length
    # do not include leading 0x
    # need to set a unique id, otherwise it will raise error when you send reward tx
    miner_id
    # your private key with 64 length
    # do not include leading 0x
    # do not omit leading 0
    miner_key
    

**運行儲存服務**

    cd run
    
    # consider using tmux in order to run in background
    ../target/release/zgs_node --config config.toml
    

**常用命令**

**查看日誌**

自已改日期

    tail -f /root/0g-storage-node/run/log/zgs.log.2024-04-11*
    

**重啟節點**

**停止節點**

    sudo systemctl stop zgs
    

**從伺服器刪除節點**

在刪除節點之前，您可能需要儲存設定檔中的`miner_id`和。`miner_key`使用以下命令列印這些值：

    grep 'miner_id' $ZGS_CONFIG_FILE
    grep 'miner_key' $ZGS_CONFIG_FILE
    

    sudo systemctl stop zgs
    sudo systemctl disable zgs
    sudo rm /etc/systemd/system/zgs.service
    rm -rf $HOME/0g-storage-node
    

**升級節點**

    cd $HOME/0g-storage-node
    git fetch
    git checkout tags/<version>
    git submodule update --init
    cargo build --release
    sudo mv $HOME/0g-storage-node/target/release/zgs_node /usr/local/bin
    

完…

---

*Originally published on [Untitled](https://paragraph.com/@0x09b8e0b96322ce8d86032bcf8612eedbc1684b13/0g-storage-node)*
