How to Set Up a BTC Mainnet Node on CentOS

·

This guide provides step-by-step instructions for deploying a Bitcoin mainnet node on CentOS 7.2, covering installation, configuration, and management.


System Requirements


Installation Steps

1. Download Bitcoin Core

Navigate to the official download page and execute:

cd /opt/
wget https://bitcoin.org/bin/bitcoin-core-0.17.0.1/bitcoin-0.17.0.1-x86_64-linux-gnu.tar.gz

2. Extract and Configure Symlinks

tar zxf bitcoin-0.17.0.1-x86_64-linux-gnu.tar.gz
ln -fs /opt/bitcoin-0.17.0 /opt/bitcoin
ln -fs /opt/bitcoin/bin/bitcoind /usr/local/bin/bitcoind
ln -fs /opt/bitcoin/bin/bitcoin-cli /usr/local/bin/bitcoin-cli

Configuration

1. Create Data Directory

mkdir -p /data/btc_data
mkdir ~/.bitcoin

2. Edit Configuration File

Add these parameters to ~/.bitcoin/bitcoin.conf:

datadir=/data/btc_data
dbcache=10240
txindex=1
rpcuser=btc
rpcpassword=[YOUR_SECURE_PASSWORD]
daemon=1
server=1
rest=1
rpcbind=0.0.0.0:8332
rpcallowip=0.0.0.0/0
deprecatedrpc=accounts

👉 Best practices for secure RPC configuration


Node Management

Start the Node

bitcoind -daemon

Stop the Node

bitcoin-cli stop

Check Sync Status

bitcoin-cli getblockchaininfo
bitcoin-cli getmininginfo

RPC API Usage

Basic Query Example

curl -s -X POST --user btc:[PASSWORD] \
-H 'content-type: text/plain;' http://127.0.0.1:8332/ \
--data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getmininginfo", "params": [] }'

Key Configuration Parameters

ParameterPurpose
txindex=1Enables full transaction indexing
dbcache=10240Allocates 10GB RAM for UTXO cache
rpcallowipWhitelists IPs for remote access

👉 Advanced node optimization techniques


FAQ

Q1: How long does initial sync take?

A: Typically 3-7 days depending on hardware and network speed.

Q2: What if I get "Cannot obtain lock" error?

A: Delete the .lock file in your datadir and restart.

Q3: Is 500GB storage sufficient?

A: Yes for now, but plan for annual 50GB+ growth.

Q4: How to verify sync progress?

A: Compare blocks in getblockchaininfo with current block height.


Pro Tips

  1. SSD Recommended: HDDs may bottleneck during initial sync
  2. Port Forwarding: Enable port 8333 for better peer connections
  3. Security: Always use strong RPC passwords and IP whitelisting

For enterprise-grade node deployments, consider professional node hosting solutions.