Is it possible to run two separate bitcoind instances on one system at the same time, one for mainnet, other for testnet?
3 Answers
Yes, you can. Just be sure to specify different data directories and configure them to use different ports.
- 51,308
- 6
- 106
- 177
-
I assume that the "specify different data directories" is now obsolete, right? – o0'. Jun 15 '13 at 18:53
I don't see any reason why not. I've read somewhere in this thread that people run various instances of multicoin for similar purposes.
- 578
- 2
- 7
I am running two nodes in the same server just as you wanted, you can follow below steps:
1. create two separate config files:
bitcoin_mainnet.conf and bitcoin_testnet3.conf in ~/.bitcoin
2. make the rpc port and datadir different from each other
sample conf:
testnet
# This config should be placed in following path:
# ~/.bitcoin/bitcoin_testnet3.conf
# [core]
# Specify the location of the configuration file. To use non-default location, create a default location config file containing this setting.
conf=~/.bitcoind/bitcoin_testnet3.conf
# Specify a non-default location to store blockchain and other data.
datadir=/mnt/bitcoin
# [debug]
# Run this node on the Bitcoin Test Network.
testnet=1
# [rpc]
# Accept command line and JSON-RPC commands.
server=1
# Accept public REST requests.
rest=1
# RPC user
rpcuser=rpcuser
# RPC password
rpcpassword=rpcpass
# RPC allow ip (allow all)
rpcallowip=0.0.0.0/0
# RPC bind
rpcbind=0.0.0.0
# get all transaction
txindex=1
mainnet
# This config should be placed in following path:
# ~/.bitcoin/bitcoin_mainnet.conf
# [core]
# Specify the location of the configuration file. To use non-default location, create a default location config file containing this setting.
conf=~/.bitcoind/bitcoin_mainnet.conf
# Specify a non-default location to store blockchain and other data.
datadir=/mnt/bitcoin/mainnet
# [debug]
# Run this node on the Bitcoin Test Network.
#testnet=1
# [rpc]
# Accept command line and JSON-RPC commands.
server=1
# Accept public REST requests.
rest=1
# RPC user
rpcuser=rpcuser
# RPC password
rpcpassword=rpcpass
# RPC allow ip (allow all)
rpcallowip=0.0.0.0/0
# RPC bind
rpcbind=0.0.0.0
# get all transaction
txindex=1
3. use below commands to get the node up: bitcoind -conf=/root/.bitcoin/bitcoin_testnet3.conf -daemon bitcoind -conf=/root/.bitcoin/bitcoin_mainnet.conf -daemon
4. now you can use rpc to interactive testnet & mainnet in different port.
5. this approch has a downside, that is when using CLI to interactive you can only connect to one network,you can check which network you are connecting with by:
bitcoin-cli getblockchaininfo which will returns info something like below. "chain": "test" means it's testnet.
{
"chain": "test",
"blocks": 1443057,
"headers": 1443057,
"bestblockhash": "00000000000000e9f4078f12d44ee643fd9711e93ad4ddaab5af1977741ce053",
"difficulty": 11974980.94624031,
"mediantime": 1542001244,
"verificationprogress": 0.9999998425668387,
"initialblockdownload": false,
"chainwork": "0000000000000000000000000000000000000000000000d119525c684f1418b3",
"size_on_disk": 22997637713,
"pruned": false,
"softforks": [
{
"id": "bip34",
"version": 2,
"reject": {
"status": true
}
},
{
"id": "bip66",
"version": 3,
"reject": {
"status": true
}
},
{
"id": "bip65",
"version": 4,
"reject": {
"status": true
}
}
],
"bip9_softforks": {
"csv": {
"status": "active",
"startTime": 1456790400,
"timeout": 1493596800,
"since": 770112
},
"segwit": {
"status": "active",
"startTime": 1462060800,
"timeout": 1493596800,
"since": 834624
}
},
"warnings": "Warning: unknown new rules activated (versionbit 28)"
}
6. to avoid this downside, you can create two user in liunx and make bitcoind instant run by different linux users, I have done it before, it works.
- 31
- 3