Full sync
Run the Bitcoin Indexer from scratch.
What You'll Learn
In this guide, you'll learn how to:
Prerequisites
To start the indexer, you'll need:
txindex=1
If you haven't already, consider bootstrapping from archives to save days of indexing time.
Start indexing services
The Bitcoin Indexer runs separate services for each metaprotocol. Navigate to your indexer directory:
$cd ~/bitcoin-indexer/bitcoin-indexer
Index Ordinals (includes BRC-20)
$./target/release/bitcoin-indexer ordinals service start --config-path=bitcoin-indexer-config.toml[32m✓[0m Loading configuration from bitcoin-indexer-config.toml[32m✓[0m Connected to Bitcoin node at 127.0.0.1:8332[32m✓[0m Connected to PostgreSQL databases[32m✓[0m Starting Ordinals indexer from block 819542[1mProcessing block 819543...[0m
Index Runes
In a separate terminal:
$./target/release/bitcoin-indexer runes service start --config-path=bitcoin-indexer-config.toml[32m✓[0m Loading configuration from bitcoin-indexer-config.toml[32m✓[0m Connected to Bitcoin node at 127.0.0.1:8332[32m✓[0m Starting Runes indexer from block 840000[1mProcessing block 840001...[0m
Each service uses the CPU cores and memory specified in your configuration. Ensure your system has enough resources to run multiple services simultaneously.
Monitor indexing progress
Check service logs
The indexer outputs detailed progress information:
$tail -f ~/bitcoin-indexer/bitcoin-indexer/ordinals.log2024-12-15 10:30:45 [INFO] Processing block 8196002024-12-15 10:30:46 [INFO] Found 23 new inscriptions2024-12-15 10:30:46 [INFO] Updated 45 transfers2024-12-15 10:30:47 [INFO] Block 819600 processed in 1.2s
Query indexer status via API
Once the API server starts (usually after a few blocks):
$curl http://localhost:3000/ordinals/v1/status{"block_height": 819600,"inscriptions_indexed": 52342567,"latest_inscription_number": 52342567,"sync_percentage": 99.93,"blocks_behind": 523}
Monitor system resources
Use htop
to monitor resource usage:
$htop# Look for:# - bitcoin-indexer processes using 60-80% CPU# - Memory usage within limits# - Disk I/O activity
Service management
Stop services gracefully
$ps aux | grep bitcoin-indexeruser 12345 75.2 8.3 bitcoin-indexer ordinals serviceuser 12346 68.1 6.2 bitcoin-indexer runes service$# Stop with SIGTERM for clean shutdown$kill -TERM 12345 12346
Restart after interruption
The indexer automatically resumes from the last processed block:
$./target/release/bitcoin-indexer ordinals service start --config-path=bitcoin-indexer-config.toml[32m✓[0m Detected previous state at block 819600[32m✓[0m Resuming indexing from block 819601
Systemd service setup
For production deployments, use systemd to manage services:
Create Ordinals service
[Unit]Description=Bitcoin Indexer - Ordinals ServiceAfter=network.target postgresql.service bitcoind.service[Service]Type=simpleUser=bitcoin-indexerWorkingDirectory=/home/bitcoin-indexer/bitcoin-indexerExecStart=/home/bitcoin-indexer/bitcoin-indexer/target/release/bitcoin-indexer ordinals service start --config-path=bitcoin-indexer-config.tomlRestart=on-failureRestartSec=30[Install]WantedBy=multi-user.target
Create Runes service
[Unit]Description=Bitcoin Indexer - Runes ServiceAfter=network.target postgresql.service bitcoind.service[Service]Type=simpleUser=bitcoin-indexerWorkingDirectory=/home/bitcoin-indexer/bitcoin-indexerExecStart=/home/bitcoin-indexer/bitcoin-indexer/target/release/bitcoin-indexer runes service start --config-path=bitcoin-indexer-config.tomlRestart=on-failureRestartSec=30[Install]WantedBy=multi-user.target
Enable and start services
$sudo systemctl daemon-reload$sudo systemctl enable bitcoin-indexer-ordinals bitcoin-indexer-runes$sudo systemctl start bitcoin-indexer-ordinals bitcoin-indexer-runes$sudo systemctl status bitcoin-indexer-ordinals[32m●[0m bitcoin-indexer-ordinals.service - Bitcoin Indexer - Ordinals ServiceLoaded: loaded (/etc/systemd/system/bitcoin-indexer-ordinals.service; enabled)Active: [32mactive (running)[0m since Mon 2024-12-15 10:30:00 UTC
Performance optimization
During initial sync
Optimize for throughput during catch-up:
[resources]# Use more cores during initial synccpu_core_available = 12bitcoind_rpc_threads = 10
After reaching chain tip
Reduce resource usage for steady-state operation:
[resources]# Reduce for normal operationcpu_core_available = 4bitcoind_rpc_threads = 4
Verify successful indexing
Check API endpoints
Test that APIs are returning data:
$curl http://localhost:3000/ordinals/v1/inscriptions/0$curl http://localhost:3000/runes/v1/runes
Monitor metrics
If Prometheus metrics are enabled:
$curl http://localhost:9153/metrics | grep bitcoin_indexerbitcoin_indexer_blocks_processed_total{protocol="ordinals"} 52600bitcoin_indexer_inscriptions_total 52342567bitcoin_indexer_api_requests_total{endpoint="/ordinals/v1/inscriptions"} 1523
Troubleshooting
Service won't start
ERROR: Failed to connect to Bitcoin node
Solutions:
- 1Verify Bitcoin node is running:
bitcoin-cli getblockcount
- 2Check RPC credentials match configuration
- 3Ensure ZMQ ports are not blocked
Slow indexing speed
If processing less than 1 block/second:
- 1Check Bitcoin node performance
- 2Verify PostgreSQL isn't bottlenecked
- 3Monitor disk I/O with
iotop
- 4Consider archive bootstrap if starting from scratch
Database connection pool exhausted
ERROR: connection pool timeout
Solutions:
- 1Increase max_connections in PostgreSQL
- 2Reduce bitcoind_rpc_threads in config
- 3Check for long-running queries