区块链中文技术社区

Solana 部署bigtable持久化数据节点

安装 gcloud CLI

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates gnupg curl
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
sudo apt-get update && sudo apt-get install google-cloud-cli

启用IAM API

https://cloud.google.com/iam/docs/keys-create-delete?hl=zh-cn&cloudshell=true
注意:选择对应的项目,然后启用API

创建实例

实例ID和实例名称都设置为solana-ledger

创建密钥

新tab打开服务账号

点击创建服务账号

输入服务信息


点击创建并继续

选择Bigtable User


点击继续
最后一步可选,直接点击完成

创建密钥

刚新建完,是没有密钥的

点击该行最右侧的操作,管理密钥

添加键->创建新密钥

选择JSON格式

直接会弹出保存对话框,选择自己本地路径进行保存
例如名称为:bcskill-testnet-rpc-storage-93984f743890.json

创建数据表

blocks,entries,tx,tx-by-addr
创建完,挨个添加列族,列族名称都为x,基于版本的政策: 版本上限5

初始化

gcloud init

等待一段时间

Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.                                                                                                                                                            
Reachability Check passed.
Network diagnostic passed (1/1 checks passed).

You must sign in to continue. Would you like to sign in (Y/n)?  
Go to the following link in your browser, and complete the sign-in prompts:

    https://accounts.google.com/o/oauth2/auth?response_type=c......

然后将上面的链接,复制到浏览器中,通过对应的谷歌账号进行登录,授权后,将返回的Key,输入到终端里
然后选择对应的实例

You are signed in as: [c..@gmail.com].

Pick cloud project to use: 
 [1] august-outlet-389809
 [2] bpay-2204b
 [3] ethereal-fort-389810
 [4] g-gcp-202408-01
 [5] infinite-alcove-389904
 [6] sturdy-web-389809
 [7] Enter a project ID
 [8] Create a new project
Please enter numeric choice or text value (must exactly match list item):  4
gcloud config configurations list
NAME     IS_ACTIVE  ACCOUNT            PROJECT          COMPUTE_DEFAULT_ZONE  COMPUTE_DEFAULT_REGION
default  True       c...@gmail.com  g-gcp-202408-01
mkdir ./config
mkdir -p ./data/accounts
mkdir ./logs
./solana-keygen new -o ./config/identity.json
export GOOGLE_APPLICATION_CREDENTIALS=./config/bcskill-testnet-rpc-storage-93984f743890.json
./agave-validator \
        --ledger ./data \
        --identity ./config/identity.json \
        --entrypoint 172.18.39.93:8001 \
        --dynamic-port-range 9000-9020 \
        --only-known-rpc \
        --known-validator Fc9UXBuQyMYBow5fTwgrYQf4k1Pwqx8o53yYBuvFQmnc \
        --allow-private-addr \
        --enable-rpc-transaction-history \
        --rpc-port 8896 \
        --private-rpc \
        --log ./logs/agave-validator.logs \
        --no-voting \
        --wal-recovery-mode skip_any_corrupted_record \
        --limit-ledger-size \
        --enable-bigtable-ledger-upload \
        --enable-cpi-and-log-storage \
        --accounts ./data/accounts \
        --no-genesis-fetch \
        --no-snapshot-fetch

查看上传数据

tail -f logs/agave-validator.logs | grep -a 'bigtable'
2024-12-16T06:31:21.663829260Z INFO  solana_ledger::bigtable_upload] Preparing the next 3 blocks for upload
[2024-12-16T06:31:21.683000789Z INFO  solana_metrics::metrics] datapoint: storage-bigtable-upload-block slot=1924269i transactions=1i entries=65i bytes=3050i
[2024-12-16T06:31:21.683031739Z INFO  solana_metrics::metrics] datapoint: storage-bigtable-upload-block slot=1924270i transactions=1i entries=65i bytes=3050i
[2024-12-16T06:31:21.683641626Z INFO  solana_metrics::metrics] datapoint: storage-bigtable-upload-block slot=1924271i transactions=1i entries=65i bytes=3049i
[2024-12-16T06:31:21.683647257Z INFO  solana_ledger::bigtable_upload] Upload took 19ms for 3 blocks
[2024-12-16T06:31:21.683659731Z INFO  solana_ledger::bigtable_upload] entire upload took 29ms
[2024-12-16T06:31:21.683872194Z INFO  solana_ledger::bigtable_upload] blockstore upload took 2.205029ms for 3 blocks (1360.53 blocks/s) errors: 0
[2024-12-16T06:31:22.683968514Z INFO  solana_ledger::bigtable_upload] Loading ledger slots from 1924272 to 1924274
[2024-12-16T06:31:22.684083929Z INFO  solana_ledger::bigtable_upload] Found 3 slots in the range (1924272, 1924274)
[2024-12-16T06:31:22.684093327Z INFO  solana_ledger::bigtable_upload] Loading list of bigtable blocks between slots 1924272 and 1924274...
[2024-12-16T06:31:22.684136962Z INFO  solana_metrics::metrics] datapoint: bigtable_blocks read_rows=1i
[2024-12-16T06:31:22.689038044Z INFO  solana_ledger::bigtable_upload] 3 blocks to be uploaded to the bucket in the range (1924272, 1924274)

常见排查

查看日志错误

tail -f logs/agave-validator.logs | grep -a 'ERROR'

https://github.com/solana-labs/solana-bigtable
https://docs.anza.xyz/implemented-proposals/rpc-transaction-history/

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »