# Setup Aptos Node

By [QuantumValkyrie](https://paragraph.com/@quantumvalkyrie) · 2024-11-27

---

Prerequisites
-------------

Before proceeding, ensure you have the following:

1.  **Server Requirements**:
    
    *   **CPU**: 4+ cores
        
    *   **RAM**: 8GB or more
        
    *   **Storage**: 100GB SSD or higher
        
    *   **OS**: Ubuntu 20.04 or higher
        
2.  **Tools Installed**:
    
    *   `curl`
        
    *   `git`
        
    *   `docker`
        
    *   `docker-compose`
        

To install these tools, run:

    sudo apt update && sudo apt upgrade -y
    sudo apt install -y curl git docker.io docker-compose
    sudo systemctl enable docker --now
    

* * *

Step 1: Clone the Aptos Repository
----------------------------------

Clone the Aptos Networks repository:

    git clone https://github.com/aptos-labs/aptos-networks.git
    cd aptos-networks
    

* * *

Step 2: Install Aptos CLI
-------------------------

The Aptos CLI is necessary to interact with the network. Install it by running:

    # Download the Aptos CLI binary
    curl -sSfL https://aptos.dev/cli-tools/install-cli.sh | sh
    
    # Verify installation
    aptos --version
    

* * *

Step 3: Generate Keys and Configuration
---------------------------------------

Generate a key pair and configuration file for your node:

    aptos genesis generate-keys --output-dir $HOME/aptos
    aptos genesis set-validator-configuration \
      --keys-dir $HOME/aptos \
      --validator-host <YOUR_VALIDATOR_IP>:6180 \
      --full-node-host <YOUR_VALIDATOR_IP>:6182 \
      --output-dir $HOME/aptos
    

Replace `<YOUR_VALIDATOR_IP>` with your server's public IP address.

* * *

Step 4: Join the Aptos Network
------------------------------

Fetch the latest configuration files from the Aptos testnet or mainnet (depending on your goal):

    # Example: For testnet
    wget -qO $HOME/aptos/testnet.yaml https://testnet.aptos.dev/genesis.yaml
    

* * *

Step 5: Run Your Node
---------------------

Use Docker to launch your Aptos node:

1.  Create a `docker-compose.yml` file in the `aptos-networks` directory:
    
        version: "3.8"
        services:
          aptos-node:
            image: aptoslab/validator:latest
            container_name: aptos-node
            restart: always
            ports:
              - "6180:6180" # Validator communication
              - "6182:6182" # Full node communication
            volumes:
              - $HOME/aptos:/opt/aptos
            command: [
              "--config",
              "/opt/aptos/testnet.yaml",
              "--genesis",
              "/opt/aptos/genesis.blob",
            ]
        
    
2.  Start the node:
    
        docker-compose up -d
        
    
3.  Verify that your node is running:
    
        docker logs -f aptos-node
        
    

* * *

Step 6: Monitor Your Node
-------------------------

### Check Sync Status

Use the CLI to check the node's sync status:

    curl http://<YOUR_VALIDATOR_IP>:6180/metrics | grep aptos_state_sync_version
    

### Logs

For real-time logs:

    docker logs -f aptos-node
    

* * *

Step 7: Update Your Node
------------------------

Regular updates ensure compatibility with the Aptos network:

1.  Pull the latest Docker image:
    
        docker pull aptoslab/validator:latest
        
    
2.  Restart your node:
    
        docker-compose down && docker-compose up -d
        
    

* * *

Troubleshooting
---------------

### Node Is Not Syncing

*   Ensure your ports `6180` and `6182` are open:
    
        sudo ufw allow 6180/tcp
        sudo ufw allow 6182/tcp
        
    
*   Verify connectivity to peers.
    

### Logs Show Errors

*   Check Docker logs for specific issues:
    
        docker logs aptos-node

---

*Originally published on [QuantumValkyrie](https://paragraph.com/@quantumvalkyrie/setup-aptos-node)*
