Aptos开发者文档
  • Aptos 开发者文档
  • 开发环境准备
  • 开发者教程
    • 你的第一笔交易
    • 你的第一个 Move 模块
    • 第一个代币
    • 你的第一个 DApp
    • 第一个 NFT
  • 概念
    • 交易和状态
    • 帐户
    • 事件
    • 燃料和交易费用
    • 验证
    • 全节点
    • 验证节点
    • 节点网络和同步
    • 质押
    • 治理
  • Guides 指南
    • 交易的生命周期
    • 创建签名交易
    • 与 Aptos 区块链交互
    • 安装 Petra 扩展
    • 构建钱包扩展
    • 系统集成商指南
    • 基于本地测试网的开发流程
    • Move 教程
      • 在 Aptos 上使用 Move 语言开发
      • Move 包更新
      • Move 事务测试
  • 节点
    • 不同环境下的 Aptos 区块链部署
    • AIT-3
      • AIT-3的新功能
      • AIT-3的参与步骤
      • 节点要求
      • 节点活跃度标准
      • 链接到Aptos激励测试网
      • 激励测试网的附加文档
    • Validators
      • 在 AWS 上运行
      • 在 Azure 上运行
      • 在 GCP 上运行
      • 使用 Docker
      • 使用 Aptos-core 源代码
    • FullNode for Devnet
      • 用Aptos源或Docker来搭建全节点
      • 通过新版本来更新全节点
      • 全节点的网络身份
      • 全节点设置故障排除
      • 在 CGP 上运行全节点
    • 本地测试网
      • 用 CLI 运行本地测试网
      • 用验证器运行本地测试网
    • 节点健康检测器
    • Aptos 节点健康检查器
  • SDKs
    • Python SDK
    • Typescript
      • Typescript SDK
      • Typescript SDK 概览
    • Rust SDK
  • Aptos CLI
    • 安装 Aptos CLI
    • 使用 Aptos CLI
  • Telemetry
    • Telemetry 遥测
  • Aptos White Paper
  • Glossary 术语表
    • Glossary 词汇表
Powered by GitBook
On this page
  • 先决条件
  • GCP 设置
  • 入门
  • 验证
  • 使用新版本更新全节点
  • 配置身份和种子对等点
  • 检查日志记录
  • 检查监控
  • 故障排除
  • 全节点“NoAvailablePeers”错误消息
  1. 节点
  2. FullNode for Devnet

在 CGP 上运行全节点

Previous全节点设置故障排除Next本地测试网

Last updated 2 years ago

本教程介绍了如何配置和部署公共全节点以使用 Google Cloud (GCP) 连接到 Aptos 开发网。与在笔记本电脑上运行相比,在云中运行全节点通常可以提供更好的稳定性和可用性。如果您正在寻找部署生产级全节点,我们建议您将其部署在云上。

注意:如果您想要其他部署替代方案,请阅读运行全节点,使用云需要付费,具体取决于您的配置方式。

先决条件

您可以运行本指南中的命令,从您想要的任何机器上在 Google Kubernetes Engine 上部署您的完整节点。从 、 或您的个人计算机上的虚拟机。

Cloud Shell 预装了以下软件包。如果您选择使用 Cloud Shell,请务必查看有关 。但是,如果您是从笔记本电脑或另一台机器上运行安装,则需要安装:

  • Terraform 1.1.7:

  • Kubernetes cli:

  • Google Cloud cli:

安装 gcloud CLI 后,使用 gcloud 登录 GCP

()

$ gcloud auth login --update-adc

如果您已经设置了 GCP 帐户,请直接跳至“”,如果还没有,请按照以下部分创建和配置您的 GCP 帐户。

GCP 设置

注册 90 天免费试用

创建一个新的 GCP 项目

启用计费/升级您的帐户

您仍然可以使用免费试用积分,但启用计费功能可以让您完全访问 GCP 的所有功能,并且不会遇到任何节点中断。

更多 GCP 资源

入门

  1. 为您的配置创建一个工作目录。

    • 选择一个工作区名称,例如devnet。注意:这定义了 terraform 工作空间名称,该名称又用于形成资源名称。

    $ export WORKSPACE=devnet
    • 为工作区创建目录

    $ mkdir -p ~/$WORKSPACE
  2. 创建一个存储桶,用于在 Google Cloud Storage 上存储 Terraform 状态。使用控制台或此 gcs 命令创建存储桶。存储桶的名称必须是唯一的。在此处查看 Google Cloud Storage 文档:

    $ gsutil mb gs://BUCKET_NAME
    # for example
    $ gsutil mb gs://<project-name>-aptos-terraform-dev
  3. 在您的工作目录中创建名为 main.tf 的 Terraform 文件

    $ cd ~/$WORKSPACE
    $ touch main.tf
  4. 修改 main.tf文件以配置 Terraform,并从 Terraform 模块创建全节点。 main.tf 的示例内容

    terraform {
      required_version = "~> 1.2.0"
      backend "gcs" {
        bucket = "BUCKET_NAME" # bucket name created in step 2
        prefix = "state/fullnode"
      }
    }
    
    module "fullnode" {
      # download Terraform module from aptos-labs/aptos-core repo
      source        = "github.com/aptos-labs/aptos-core.git//terraform/fullnode/gcp?ref=main"
      region        = "us-central1"  # Specify the region
      zone          = "c"            # Specify the zone suffix
      project       = "gcp-fullnode" # Specify your GCP project name
      era           = 1              # bump era number to wipe the chain
      image_tag     = "devnet"       # Specify the docker image tag to use, replace to `testnet` or other tag if needed
    
      fullnode_helm_values = {
        chain = {
        name = "devnet"              # replace with `ait3` or other values if connecting to different networks.
        }
      }
    }
  5. 在 main.tf文件的同一目录中初始化 Terraform

$ terraform init

这应该会在 .terraform 文件夹中为您下载所有 terraform 依赖项。

  1. 创建一个新的 Terraform 工作区以隔离您的环境:

    $ terraform workspace new $WORKSPACE
    # This command will list all workspaces
    $ terraform workspace list
  2. 应用配置。

    $ terraform apply

这可能需要一段时间才能完成(10 - 20 分钟),Terraform 将在您的云帐户上创建所有资源。

验证

一旦 Terraform 应用完成,您可以按照此部分验证您的部署。

  1. 配置您的 Kubernetes 客户端以访问您刚刚部署的集群

    $ gcloud container clusters get-credentials aptos-$WORKSPACE --zone <region_zone_name> --project <project_name>
    # for example:
    $ gcloud container clusters get-credentials aptos-devnet --zone us-central1-a --project aptos-fullnode
  2. 检查您的全节点 Pod 现在是否正在运行(这可能需要几分钟):

    $ kubectl get pods -n aptos
  3. 获得您全节点IP

    $ kubectl get svc -o custom-columns=IP:status.loadBalancer.ingress -n aptos
  4. 检查 REST API,确保 ledge 版本正在增加。

    $ curl http://<IP>/v1
    # Example command syntax: curl <http://104.198.36.142/v1>
  • 设置到 aptos-fullnode pod 的端口转发。使用 kubectl get pods -n aptos 获取 pod 的名称

    $ kubectl port-forward -n aptos <pod-name> 9101:9101
    # for example:
    $ kubectl port-forward -n aptos devnet0-aptos-fullnode-0 9101:9101
  • 打开一个新的 ssh 终端。执行以下 curl 调用以验证正确性

    $ curl -v <http://0:9101/metrics> 2> /dev/null | grep "aptos_state_sync_version{type=\\"synced\\"}"
    
    $ curl -v <http://0:9101/metrics> 2> /dev/null | grep "aptos_connections{direction=\\"outbound\\""
  • 完成后通过在终端中输入 control-c 退出端口转发

使用新版本更新全节点

可能有两种类型的版本,一种带有数据擦除以启动区块链,一种只是软件更新。

使用数据擦除升级

  1. 您可以在 main.tf中增加era编号以触发新数据卷的创建,这将在新数据库上启动节点。

  2. 更新 main.tf中的 image_tag

  3. 更新全节点的 Terraform 模块,在 main.tf 文件的同一目录中运行它

    $ terraform get -update
  4. 应用 Terraform 更改

$ terraform apply

升级无数据擦除

  1. 更新 main.tf中的image_tag

  2. 更新全节点的 Terraform 模块,在 main.tf文件的同一目录中运行它

    $ terraform get -update
  3. 应用 Terraform 更改

$ terraform apply
# if you didn't update the image tag, terraform will show nothing to change, in this case, force helm update
$ terraform apply -var force_helm_update=true

配置身份和种子对等点

静态身份

  1. 修改 main.tf以在 fullnode_helm_values 中添加fullnode_identity,这将配置 fullnode 的键,例如:

    module "fullnode" {
      # download Terraform module from aptos-labs/aptos-core repo
      source        = "github.com/aptos-labs/aptos-core.git//terraform/fullnode/gcp?ref=main"
      region        = "us-central1"  # Specify the region
      zone          = "c"            # Specify the zone suffix
      project       = "gcp-fullnode" # Specify your GCP project name
      era           = 1              # bump era number to wipe the chain
      image_tag     = "devnet"       # Specify the docker image tag to use
    
      fullnode_helm_values = {
        chain = {
          name = "devnet"
        }
        # create fullnode from this identity config, so it will always have same peer id and address
        fullnode_identity = {
          type = "from_config"
          key = "B8BD811A91D8E6E0C6DAC991009F189337378760B55F3AD05580235325615C74"
          peer_id = "ca3579457555c80fc7bb39964eb298c414fd60f81a2f8eedb0244ec07a26e575"
        }
      }
    }
  2. 应用 Terraform 更改

    $ terraform apply

添加上游种子节点

您可以添加上游种子对等点以允许您的节点状态从特定的全节点同步,这在全节点由于拥塞而无法连接到网络时很有帮助。

  1. module "fullnode" {
        # download Terraform module from aptos-labs/aptos-core repo
        source        = "github.com/aptos-labs/aptos-core.git//terraform/fullnode/gcp?ref=main"
        region        = "us-central1"  # Specify the region
        zone          = "c"            # Specify the zone suffix
        project       = "gcp-fullnode" # Specify your GCP project name
        era           = 1              # bump era number to wipe the chain
        image_tag     = "dev_5b525691" # Specify the docker image tag to use
    
        fullnode_helm_values = {
          # add a list of peers as upstream
          aptos_chains = {
            devnet = {
              seeds = {
                "bb14af025d226288a3488b4433cf5cb54d6a710365a2d95ac6ffbd9b9198a86a" = {
                addresses = ["/dns4/pfn0.node.devnet.aptoslabs.com/tcp/6182/noise-ik/bb14af025d226288a3488b4433cf5cb54d6a710365a2d95ac6ffbd9b9198a86a/handshake/0"]
                role = "Upstream"
                },
                "7fe8523388084607cdf78ff40e3e717652173b436ae1809df4a5fcfc67f8fc61" = {
                addresses = ["/dns4/pfn1.node.devnet.aptoslabs.com/tcp/6182/noise-ik/7fe8523388084607cdf78ff40e3e717652173b436ae1809df4a5fcfc67f8fc61/handshake/0"]
                role = "Upstream"
                },
                "f6b135a59591677afc98168791551a0a476222516fdc55869d2b649c614d965b" = {
                addresses = ["/dns4/pfn2.node.devnet.aptoslabs.com/tcp/6182/noise-ik/f6b135a59591677afc98168791551a0a476222516fdc55869d2b649c614d965b/handshake/0"]
                role = "Upstream"
                }
              }
            }
          }
        }
      }

    如果您要连接到其他网络,请确保将 aptos_chains.devnet 更新到相应的网络

  2. 应用 Terraform 更改

$ terraform apply

检查日志记录

要检查 pod 的日志,请使用以下命令

# Get a list of the pods
$ kubectl get pods -n aptos

# Get logs of the pod
$ kubectl logs <pod-name> -n aptos
# for example:
$ kubectl logs devnet0-aptos-fullnode-0 -n aptos

使用 GKE 时,集群和 pod 的日志会自动显示在 Google Cloud 控制台中。从控制台菜单中,选择 Kubernetes Engine。从侧面菜单中,选择Workloads。您将看到列出的集群中的所有 pod。

devnet0-aptos-fullnode 是运行 aptos fullnode 容器的 pod。单击吊舱以查看详细信息。您将看到有关 pod 的一些指标和其他详细信息。

单击 LOGS选项卡可直接从 pod 中查看日志。如果 pod 中有错误,您将在此处看到它们。

单击open in new window图标以在日志资源管理器中查看日志。此屏幕允许在日志中进行高级搜索。

日志仪表板中提供了其他日志记录见解

检查监控

谷歌云从集群中捕获许多指标,并让它们在控制台中轻松查看。从控制台菜单中,选择 Kubernetes Engine。单击 aptos 部署到的集群。点击右上角的Operations链接。单击“Metrics”子选项卡以查看特定的集群指标。

故障排除

常见的故障排除解决方案。

Terraform“连接被拒绝”错误消息

运行 terraform 时,命令出错,并显示连接被拒绝错误消息。

Error: Get "<http://localhost/api/v1/namespaces/aptos>": dial tcp 127.0.0.1:80: connect: connection refused

这可能意味着安装状态与存储桶中保存的 terraform 状态文件不同步。 (在 terraform init语句期间配置)。如果集群或其他组件在 terraform 之外被删除,则可能会发生这种情况。或者如果 terraform 出现错误并且没有完成。使用以下命令检查状态。删除与错误消息相关的状态。您可能需要运行 terraform destroy、清理环境并再次运行 terraform 脚本。

terraform state list

terraform state rm <state>

全节点“NoAvailablePeers”错误消息

Google Cloud 为每位新用户提供 。这 300 美元将作为积分存入您的帐户,您可以使用它们来了解 Google Cloud 产品。请注意,您在注册免费试用时需要添加付款信息。这是出于身份验证目的,。)。免费试用版中不提供某些 GCP 功能,例如 GPU 和 Windows 服务器。

您还需要在 GCP Console 上或使用 Google Cloud CLI 中的 glcoud 命令创建一个新项目。不过,在您这样做之前,熟悉 可能会有所帮助。

这应该足以让您的 GCP 设置准备好开始部署您的全节点。但是,如果您是 GCP 的新手,您可能需要查看我们的一些和

您可以使用 Aptos 全节点 Terraform 模块在 GCP 上部署公共全节点,本指南假设您已经设置了 GCP 帐户,并创建了一个用于部署 Aptos 全节点的新项目。如果您不这样做,请查看上述有关 。

为了验证您的,如全节点文档中所述,您需要在一个 ssh 终端中直接设置端口转发机制到 aptos pod,并在另一个 ssh 终端中对其进行测试

如果您想使用静态身份配置您的节点,请查看完整以了解如何生成密钥,并按照以下说明在您的 terraform 文件中进行配置。

按照的指南生成您自己的私钥并提取对等 ID

获取上游节点 ID 信息,您可以使用我们在中列出的信息;或从 #advertise-full-node 频道获取一个,这些是我们社区托管的节点。

https://aptos.dev/assets/images/tutorial-gcp-logging1-b2eed3ddcdc3f32fa0a98d156eb576c3.png
https://aptos.dev/assets/images/tutorial-gcp-logging2-7c7394435178b639ad3c49537270c5ca.png
https://aptos.dev/assets/images/tutorial-gcp-logging3-ce881ec60dd529f88fde99a3197bf2f1.png
https://aptos.dev/assets/images/tutorial-gcp-logging4-b79b3db6552a833070107f26138f72da.png
https://aptos.dev/assets/images/tutorial-gcp-logging5-78873facafd1c13b8963cf9520972f8f.png

其他可通过 获得,包括创建基于日志的指标、日志接收器和日志存储桶。

https://aptos.dev/assets/images/tutorial-gcp-mon1-8e519d888d8278e3905c2a853c735011.png

点击顶部的“View in Cloud Monitoring”链接以查看集群的内置 GKE 。

https://aptos.dev/assets/images/tutorial-gcp-mon2-daf3266735be444309cf6445df4e1c68.png

Google Cloud 还有许多其他功能可以轻松监控集群和 Pod。您可以为服务配置正常运行时间检查,并在指标达到特定阈值时配置警报。

如果您的节点无法状态同步,并且日志显示“NoAvailablePeers”,则可能是由于网络拥塞。您可以尝试为您的全节点添加一些额外的上游对等节点以进行状态同步。请参阅指南。

GCP
Google Cloud Shell
ephermability 的文档
https://www.terraform.io/downloads.html
https://kubernetes.io/docs/tasks/tools/
https://cloud.google.com/sdk/docs/install-sdk
https://cloud.google.com/sdk/gcloud/reference/auth/login
入门
90 天 300 美元的免费试用
在您升级到付费帐户并用完积分之前不会产生费用
Sign up for the $300 in credits here.
在此处注册 300 美元的积分。
GCP 上的资源层次结构
按照这些说明设置新项目
按照此处列出的步骤升级您的帐户。
快速入门指南
Google Cloud Skills Boost
GCP 设置的说明
https://cloud.google.com/storage/docs/creating-buckets#prereq-cli
全节点的正确性
节点高级指南
此处
全节点教程
Aptos Discord
功能
Cloud Logging
仪表板
Monitoring
添加上游种子节点