Akash Testnet 3 Week1 挑战4攻略

in hive-180932 •  3 years ago  (edited)

image.png

继上一篇攻略Akash Testnet 3 Week1 挑战1-3攻略, 这篇介绍怎么完成挑战4. (跳过设置,如果想了解设置,看上一篇攻略)

挑战4.1的要求是部署一个可存储的应用(数据库之类的)

https://github.com/ovrclk/awesome-akash 找到数据库类型的应用

我找了MongoDB,并做了一些修改。修改后的文件如下:

---
version: "2.0"

services:
  mongo:
    image: mongo:latest
    params:
      storage:
        data:
          mount: /var/lib/mongodb
    expose:
      - port: 27017
        to:
          - global: true
    env:
      - MONGO_INITDB_ROOT_USERNAME=root
      - MONGO_INITDB_ROOT_PASSWORD=rootpassword
profiles:
  compute:
    mongo:
      resources:
        cpu:
          units: 0.2
        memory:
          size: 256Mi
        storage:
          - size: 1Gi
          - name: data
            size: 1Gi
            attributes:
              persistent: true
              class: beta2
  placement:
    akash:
      pricing:
        mongo:
          denom: uakt
          amount: 1000.1
deployment:
  mongo:
    akash:
      profile: mongo
      count: 1

复制上面的内容到gist上:https://gist.github.com/ 并保存。复制创建好的gist链接到表格的挑战4.1里,这个挑战就算是完成了(因为上面的SDL我测试过是可以用的,并且表格没要求填部署的tx hash)

如果你找其他数据库类型的应用,按照下面步骤部署测试是否能用

创建部署文件

https://github.com/ovrclk/awesome-akash 找到数据库类型的应用,创建deploy.yaml 部署文件

创建部署

akash tx deployment create deploy.yaml --from $AKASH_KEY_NAME1 --node $AKASH_NODE --chain-id $AKASH_CHAIN_ID --gas-prices="0.025uakt" --gas="auto" --gas-adjustment=1.5 -y

从返回的数据中找到dseq号码,输入下面命令

AKASH_DSEQ=<DSEQ号码>

获取竞标的名单

akash query market bid list --owner=$AKASH_ACCOUNT_ADDRESS1 --node $AKASH_NODE --dseq $AKASH_DSEQ

如果没获得竞标,那就可能是配置高了,或者价格低了,修改一下再部署试试

如果有获得竞标名单,从名单里选一个provider,然后输入下面命令

AKASH_PROVIDER=<provider-address>

创建租借合约

akash tx market lease create --chain-id $AKASH_CHAIN_ID --node $AKASH_NODE --owner $AKASH_ACCOUNT_ADDRESS1 --dseq $AKASH_DSEQ --provider $AKASH_PROVIDER --from $AKASH_KEY_NAME1 --gas-prices="0.025uakt" --gas="auto" --gas-adjustment=1.5 -y

查看租借合约是否开启

akash query market lease list --owner $AKASH_ACCOUNT_ADDRESS1 --node $AKASH_NODE --dseq $AKASH_DSEQ

发送Manifest

akash provider send-manifest deploy.yaml --node $AKASH_NODE --dseq $AKASH_DSEQ --provider $AKASH_PROVIDER --home ~/.akash --from $AKASH_KEY_NAME1

如果输出显示Pass,代表成功部署了

获取部署的链接

akash provider lease-status --node $AKASH_NODE --home ~/.akash --dseq $AKASH_DSEQ --from $AKASH_KEY_NAME1 --provider $AKASH_PROVIDER

我部署的mongodb获得的链接是这样子的

{
  "services": {
    "mongo": {
      "name": "mongo",
      "available": 1,
      "total": 1,
      "uris": null,
      "observed_generation": 1,
      "replicas": 1,
      "updated_replicas": 1,
      "ready_replicas": 1,
      "available_replicas": 1
    }
  },
  "forwarded_ports": {
    "mongo": [
      {
        "host": "provider.edgenet-3.ca.aksh.pw",
        "port": 27017,
        "externalPort": 31628,
        "proto": "TCP",
        "available": 1,
        "name": "mongo"
      }
    ]
  }
}

连接数据库也没有问题

image.png

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!