Synchronization

比特幣核心無法將記憶體寫入磁碟

  • August 16, 2022

我現在一直在擺弄這個錯誤,想知道出了什麼問題。我在相對較低規格的 EC2 實例(2MB 記憶體,40gb 磁碟)上執行比特幣核心的測試網實例

它無法正確同步。無論 dbcache 和 mempool 的大小,它總是會在清空之前崩潰。debug.log 中沒有錯誤消息,只有最新的 UpdateTip。

DBcache=4, mempool=52022-08-15T13:25:48Z UpdateTip: new best=00000000781c1335e275cb33c0f16be3eb60c803482995f6fdf88fc1cc9cce8b height=21799 version=0x00000002 log2_work=48.609020 tx=33303 date='2012-08-30T16:51:17Z' progress=0.000525 cache=4.1MiB(22817txo) Killed 的例子:增加 dbcache/mempool 將允許它執行更長時間,但它不可避免地會以同樣的方式被殺死。

更多調試日誌:

bitcoin@localhost:~$ bitcoind -testnet -rpcuser="user" -rpcpassword="password" -dbcache=20 -maxmempool=5 
2022-08-15T16:04:02Z Bitcoin Core version v23.0.0 (release build)
2022-08-15T16:04:02Z Assuming ancestors of block 00000000000163cfb1f97c4e4098a3692c8053ad9cab5ad9c86b338b5c00b8b7 have valid signatures.
2022-08-15T16:04:02Z Setting nMinimumChainWork=00000000000000000000000000000000000000000000064728c7be6fe4b2f961
2022-08-15T16:04:02Z Using the 'x86_shani(1way,2way)' SHA256 implementation
2022-08-15T16:04:02Z Using RdSeed as additional entropy source
2022-08-15T16:04:02Z Using RdRand as an additional entropy source
2022-08-15T16:04:02Z Default data directory /home/bitcoin/.bitcoin
2022-08-15T16:04:02Z Using data directory /home/bitcoin/.bitcoin/testnet3
2022-08-15T16:04:02Z Config file: /home/bitcoin/.bitcoin/bitcoin.conf (not found, skipping)
2022-08-15T16:04:02Z Command-line arg: dbcache="20"
2022-08-15T16:04:02Z Command-line arg: maxmempool="5"
2022-08-15T16:04:02Z Command-line arg: rpcpassword=****
2022-08-15T16:04:02Z Command-line arg: rpcuser=****
2022-08-15T16:04:02Z Command-line arg: testnet=""
2022-08-15T16:04:02Z Using at most 125 automatic connections (1024 file descriptors available)
2022-08-15T16:04:02Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2022-08-15T16:04:02Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2022-08-15T16:04:02Z Script verification uses 0 additional threads
2022-08-15T16:04:02Z scheduler thread start
2022-08-15T16:04:02Z HTTP: creating work queue of depth 16
2022-08-15T16:04:02Z Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcauth for rpcauth auth generation.
2022-08-15T16:04:02Z HTTP: starting 4 worker threads
2022-08-15T16:04:02Z Using wallet directory /home/bitcoin/.bitcoin/testnet3/wallets
2022-08-15T16:04:02Z init message: Verifying wallet(s)…
2022-08-15T16:04:02Z Using /16 prefix for IP bucketing
2022-08-15T16:04:02Z init message: Loading P2P addresses…
2022-08-15T16:04:02Z Loaded 0 addresses from peers.dat  6ms
2022-08-15T16:04:02Z init message: Loading banlist…
2022-08-15T16:04:02Z SetNetworkActive: true
2022-08-15T16:04:02Z Failed to read fee estimates from /home/bitcoin/.bitcoin/testnet3/fee_estimates.dat. Continue anyway.
2022-08-15T16:04:02Z Cache configuration:
2022-08-15T16:04:02Z * Using 2.0 MiB for block index database
2022-08-15T16:04:02Z * Using 8.0 MiB for chain state database
2022-08-15T16:04:02Z * Using 10.0 MiB for in-memory UTXO set (plus up to 4.8 MiB of unused mempool space)
2022-08-15T16:04:02Z init message: Loading block index…
2022-08-15T16:04:02Z Switching active chainstate to Chainstate [ibd] @ height -1 (null)
2022-08-15T16:04:02Z Opening LevelDB in /home/bitcoin/.bitcoin/testnet3/blocks/index
2022-08-15T16:04:02Z Opened LevelDB successfully
2022-08-15T16:04:02Z Using obfuscation key for /home/bitcoin/.bitcoin/testnet3/blocks/index: 0000000000000000
2022-08-15T16:04:02Z LoadBlockIndexDB: last block file = 0
2022-08-15T16:04:02Z LoadBlockIndexDB: last block file info: CBlockFileInfo(blocks=0, size=0, heights=0...0, time=1970-01-01...1970-01-01)
2022-08-15T16:04:02Z Checking all blk files are present...
2022-08-15T16:04:02Z Initializing databases...
2022-08-15T16:04:02Z Opening LevelDB in /home/bitcoin/.bitcoin/testnet3/chainstate
2022-08-15T16:04:02Z Opened LevelDB successfully
2022-08-15T16:04:02Z Using obfuscation key for /home/bitcoin/.bitcoin/testnet3/chainstate: fb97b88490e524df
2022-08-15T16:04:02Z init message: Verifying blocks…
2022-08-15T16:04:02Z  block index              49ms
2022-08-15T16:04:02Z loadblk thread start
2022-08-15T16:04:02Z UpdateTip: new best=000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943 height=0 version=0x00000001 log2_work=32.000022 tx=1 date='2011-02-02T23:16:42Z' progress=0.000000 cache=0.0MiB(0txo)
2022-08-15T16:04:02Z block tree size = 1
2022-08-15T16:04:02Z nBestHeight = 0
2022-08-15T16:04:02Z AddLocal(-:18333,1)
2022-08-15T16:04:02Z Discover: IPv4 - eth0: 
2022-08-15T16:04:02Z Bound to 127.0.0.1:18334
2022-08-15T16:04:02Z Bound to [::]:18333
2022-08-15T16:04:02Z Bound to 0.0.0.0:18333
2022-08-15T16:04:02Z Failed to open mempool file from disk. Continuing anyway.
2022-08-15T16:04:02Z loadblk thread exit
2022-08-15T16:04:02Z torcontrol thread start
2022-08-15T16:04:02Z 0 block-relay-only anchors will be tried for connections.
2022-08-15T16:04:02Z init message: Starting network threads…
2022-08-15T16:04:02Z init message: Done loading
2022-08-15T16:04:02Z addcon thread start
2022-08-15T16:04:02Z opencon thread start
2022-08-15T16:04:02Z msghand thread start
2022-08-15T16:04:02Z dnsseed thread start
2022-08-15T16:04:02Z Loading addresses from DNS seed testnet-seed.bluematt.me.
2022-08-15T16:04:02Z net thread start
2022-08-15T16:04:03Z Loading addresses from DNS seed testnet-seed.bitcoin.jonasschnelli.ch.
2022-08-15T16:04:03Z Loading addresses from DNS seed seed.testnet.bitcoin.sprovoost.nl.
2022-08-15T16:04:03Z Loading addresses from DNS seed seed.tbtc.petertodd.org.
2022-08-15T16:04:03Z 62 addresses found from DNS seeds
2022-08-15T16:04:03Z dnsseed thread exit
2022-08-15T16:09:21Z UpdateTip: new best=000000000e74e1d0d23ec2ad5ea79b01df8a7f423c0f1676cdef2d21ec9f43cf height=56054 version=0x00000002 log2_work=52.424615 tx=93808 date='2013-03-08T16:20:21Z' progress=0.001480 cache=13.3MiB(85444txo)
Killed

如果 Bitcoin Core 在將任何內容寫入磁碟之前不斷被殺死,而與您的 dbcache 和 mempool 配置無關,並且 debug.log 中沒有錯誤日誌,那麼您很可能缺少足夠的記憶體。

您可以通過更密切地監控您的 ram 來檢查是否是這種情況sudo free -h

如果您的系統允許,您可以創建一個交換文件,它為我解決了這個問題,以及在此處找到的命令。

引用自:https://bitcoin.stackexchange.com/questions/114894