本文主要是介绍lotus miner 元数据 删除 重建,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
lotus miner 元数据重建
- 主网 lotus-miner backup
- 测试网模拟lotus-miner元数据损坏,重建
- 指定原来的矿工号重新初始化
- 环境变量配置miner API
- 运行 lotus-worker
- 修改LevelDB
- 扇区ID 从27开始
- 修改nextid 大的数字
- 参考
主网 lotus-miner backup
Backup and restore
测试网模拟lotus-miner元数据损坏,重建
# echo $LOTUS_MINER_PATH
/raid0/calibnet/miner
删除miner目录下所有内容
# rm -rf /raid0/calibnet/miner/*
指定原来的矿工号重新初始化
lotus-miner init --no-local-storage --actor=t矿工号 --owner=t3钱包 --sector-size=32GiB
- 运行miner
nohup lotus-miner run >> /var/log/calibnet/miner.log 2>&1 &
lotus-miner info
- 修改lotus-miner配置文件
config.toml
和storage.json
lotus-miner stop
# cat $LOTUS_MINER_PATH/config.toml | grep -Ev '^$|#'
[API]ListenAddress = "/ip4/192.168.1.92/tcp/2345/http"RemoteListenAddress = "192.168.1.92:2345"
[Backup]
[Libp2p]
[Pubsub]
[Subsystems]
[Dealmaking][Dealmaking.RetrievalPricing][Dealmaking.RetrievalPricing.Default][Dealmaking.RetrievalPricing.External]
[Sealing]BatchPreCommits = falseAggregateCommits = false
[Storage]AllowAddPiece = falseAllowPreCommit1 = falseAllowPreCommit2 = falseAllowCommit = falseAllowUnseal = false
[Fees][Fees.MaxPreCommitBatchGasFee][Fees.MaxCommitBatchGasFee]
[Addresses]
[DAGStore]
- 存储目录重新init会报错
# lotus-miner storage attach --init --store /store/
ERROR: path is already initialized
- 存储目录可以直接修改
# cat $LOTUS_MINER_PATH/storage.json
{"StoragePaths": null
}
# cat $LOTUS_MINER_PATH/storage.json
{"StoragePaths": [{"Path": "/store"}]
}
lotus-miner storage list
看不到扇区列表
lotus-miner sectors list
环境变量配置miner API
lotus-miner auth api-info --perm admin
运行 lotus-worker
nohup lotus-worker run >> /var/log/calibnet/worker.log 2>&1 &
修改LevelDB
- pledge 扇区编号ID会从0开始,需要修改
nextid
- 查看扇区的最新ID,最新扇区ID为
26
lotus-miner proving deadlines
lotus-miner proving deadline <Index>
lotus-miner proving check <Index>
# mkdir leveldb_nextid
# cd leveldb_nextid/
# go mod init leveldb_nextid
# vim leveldb_nextid.go
- 停止mienr
lotus-miner stop
cat leveldb_nextid.go
package main
import ("fmt""log""github.com/syndtr/goleveldb/leveldb""encoding/binary"
)func main(){// 打开数据库db, err := leveldb.OpenFile("/raid0/calibnet/miner/datastore/metadata", nil)if err != nil { log.Fatal(err) } // 关闭数据库defer db.Close()// 遍历数据fmt.Println("遍历数据")iter := db.NewIterator(nil, nil) for iter.Next() { fmt.Printf("key:%s, value:%s\n", iter.Key(), iter.Value()) //fmt.Printf("key:%s \n", iter.Key()) } iter.Release() buf := make([]byte, binary.MaxVarintLen64)size := binary.PutUvarint(buf, 26)fmt.Print(size)fmt.Printf("%v \n", buf[:size])db.Put([]byte("/storage/nextid"), buf[:size], nil) nextid, _ := db.Get([]byte("/storage/nextid"), nil) fmt.Printf("读取单条数据 nextid: %v\n", nextid)}
go get github.com/syndtr/goleveldb/leveldb
# go run leveldb_nextid.go
遍历数据
key:/backupds/log/head, value:1647508356.log.cbor;5364dd4d-2ff9-4302-82a5-cb513421b5ca;1647509713
key:/datatransfer/provider/transfers/versions/current, value:2
key:/deals/provider/storage-ask/1/latest, value:�cAsk�ePriceE�emVerifiedPriceE���lMinPieceSizelMaxPieceSizMinerD�iTimestamp�fExpiryeSeqNoiSignatureXa�|o��T�k}ֿ�)����SW�����(\�E &��+���!�4/J�;�"
�ܳ%��y�g����K!��5���m��IFh��6��.
key:/deals/provider/storage-ask/versions/current, value:1
key:/deals/provider/versions/current, value:1
key:/miner-address, value:�
key:/retrievals/provider/retrieval-ask/1/latest, value:�lPricePerByte@kUnsealPrice@oPaymentIntervalwPaymentIntervalIncrease
key:/retrievals/provider/retrieval-ask/versions/current, value:1
key:/retrievals/provider/versions/current, value:1
key:/storagemarket/cid-infos/versions/current, value:1
key:/storagemarket/pieces/versions/current, value:1
1[26]
读取单条数据 nextid: [26]
扇区ID 从27开始
# lotus-miner sectors pledge
Created CC sector: 27
# lotus-miner sectors list
ID State OnChain Active Expiration Deals
27 Packing NO NO n/a CC
修改nextid 大的数字
- nextid 修改为1600
buf := make([]byte, binary.MaxVarintLen64)size := binary.PutUvarint(buf, 1600)fmt.Print(size)fmt.Printf("%v \n", buf[:size])db.Put([]byte("/storage/nextid"), buf[:size], nil)
读取单条数据 nextid: [192 12]
# lotus-miner sectors pledge
Created CC sector: 1601
参考
- /storage/nextid
- leveldb 修改
- 原语云
- goleveldb
- Go语言中调用levelDB
这篇关于lotus miner 元数据 删除 重建的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!