> For the complete documentation index, see [llms.txt](https://wiki.aptos.movemove.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.aptos.movemove.org/wen-ti-faq/ru-he-yun-xing-duo-ge-jie-dian.md).

# 如何运行多个节点

如果您拥有一台高性能服务器，想运行多个节点，那么您可以参考这个教程。

{% hint style="info" %}
注意：

* 官方建议，单个全节点的最低配置为 2 核 8GB 内存；
* 使用本教程前，请确保已阅读并了解如何运行节点（Docker 方式）；[教程地址](/jiao-cheng/kai-fa-wang-devnet/yun-xing-quan-jie-dian-she-qu-jiao-cheng.md)
* 若您的服务器性能较低，运行多个节点，可能会导致宕机、无法连接等情况！
  {% endhint %}

## 1. 创建新的节点目录

#### Windows 用户

在 C 盘或 D 盘下新建文件夹 `aptos-node-1`，注意不是之前节点的目录。

#### Mac/Linux 用户

前面的教程中，默认创建了名为 `aptos-node` 的目录，为了运行新的节点，需要创建新的目录：

```shell
# 创建 aptos-node 目录并进入该目录，之后的操作都会在该目录下进行
mkdir -p ~/aptos-node-1 && cd ~/aptos-node-1
```

## 2. 下载 Aptos 节点运行所需文件

在新的目录（`aptos-node-1`）下重新下载节点所需文件，您也可以从之前的目录中拷贝。

## 3. 修改配置

### 3.1 修改新的静态身份

新的节点需要生成新的静态身份，您可以参照社区教程的命令生成并修改 `public_full`\_node`.yaml` 文件。

```yaml
base:
    # This is the location Aptos will store its database. It is backed by a dedicated docker volume
    # for persistence.
    data_dir: "/opt/aptos/data"
    role: "full_node"
    waypoint:
        # This is a checkpoint into the blockchain for added security.
        from_file: "/opt/aptos/etc/waypoint.txt"

execution:
    # Path to a genesis transaction. Note, this must be paired with a waypoint. If you update your
    # waypoint without a corresponding genesis, the file location should be an empty path.
    genesis_file_location: "/opt/aptos/etc/genesis.blob"

full_node_networks:
    - network_id: "public"
      discovery_method: "onchain"
      identity:
        type: "from_config"
        key: "这里换成自己生成的私钥"
        peer_id: "这里换成自己生成的PeerID"
      # The network must have a listen address to specify protocols. This runs it locally to
      # prevent remote, incoming connections.
      listen_address: "/ip4/0.0.0.0/tcp/6180"
      # Define the upstream peers to connect to
      seeds:
        bb14af025d226288a3488b4433cf5cb54d6a710365a2d95ac6ffbd9b9198a86a:
            addresses:
            - "/dns4/pfn0.node.devnet.aptoslabs.com/tcp/6182/ln-noise-ik/bb14af025d226288a3488b4433cf5cb54d6a710365a2d95ac6ffbd9b9198a86a/ln-handshake/0"
            role: "Upstream"
        7fe8523388084607cdf78ff40e3e717652173b436ae1809df4a5fcfc67f8fc61:
            addresses:
            - "/dns4/pfn1.node.devnet.aptoslabs.com/tcp/6182/ln-noise-ik/7fe8523388084607cdf78ff40e3e717652173b436ae1809df4a5fcfc67f8fc61/ln-handshake/0"
            role: "Upstream"
        f6b135a59591677afc98168791551a0a476222516fdc55869d2b649c614d965b:
            addresses:
            - "/dns4/pfn2.node.devnet.aptoslabs.com/tcp/6182/ln-noise-ik/f6b135a59591677afc98168791551a0a476222516fdc55869d2b649c614d965b/ln-handshake/0"
            role: "Upstream"

api:
    # This specifies your REST API endpoint. Intentionally on public so that Docker can export it.
    address: 0.0.0.0:8080

```

修改后的结果如下：

![](/files/QS3nt7SK0HuvVuWT8dYV)

### 3.2 修改 docker-compose 编排文件

这是最重要的一步，打开 `docker-compose.yaml` 编排文件，并修改端口配置。

找到 ports 属性，并修改冒号左侧的端口，这里我将 8080 修改为 8081，将 9101 修改为 9102，将 6180 修改为 6181。

{% hint style="info" %}
注意：

* 修改后的端口一定要是可用的，没有其他程序占用，否则节点将无法运行；
* "6180:6180" 默认不存在，可以不修改。
* 注意本步骤中，将 9101 端口修改为 9102，最后检查节点时，命令也有所修改。
  {% endhint %}

修改结果如下图所示：

![](/files/rbFgUAbvQUo5TAiVqRYe)

## 4. 运行新的全节点

在 `aptos-node-1` 目录下，输入如下命令运行节点：

```
# 更新镜像
sudo docker-compose pull

# 运行节点
sudo docker-compose up -d
```

查看节点运行状态：

```
sudo docker ps -a 
```

![node container running](/files/BmEphmeJ0arO5tZfLD4R)

至此，新的节点已经启动完成。

## 5. 检查新节点

{% hint style="info" %}
注：

* 确保节点是运行中，否则执行下面的命令会出错！
* <mark style="color:orange;">新节点的端口有变化，在第三步中，将 9101 修改为 9102，因此命令也有所修改</mark>。
  {% endhint %}

#### Windows 用户

在浏览器中访问：[http://127.0.0.1:9102/metrics](http://127.0.0.1:9101/metrics)

#### MacOS/Linux 用户

执行如下命令查看同步状态：

```
curl 127.0.0.1:9102/metrics 2> /dev/null | grep aptos_state_sync_version | grep type
```
