Bitcoin Forum
May 05, 2024, 05:36:12 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to run testnet and bitcoind on same server  (Read 2097 times)
Bungeebones (OP)
Full Member
***
Offline Offline

Activity: 178
Merit: 100



View Profile
September 06, 2014, 11:16:24 PM
 #1

Hi all,

If understand correctly, bitcoind and testnet can be run on the same server at the same time provided they are configured to use different ports. I know bitcoind uses 8332 and 8333 while testnet is usually set to 18332 and 18333. I understand that the ports that are to be used can be configured in the bitcoin.conf file. So in order to run both bitcoind and testnet at the same time do I make two bitcoin.conf files and place one in the .bitcoin directory and one in testnet3 directory with different port settings?

Basically I'm running these on two separate VPS and would like to combine them to save costs.

Thanks
1714887372
Hero Member
*
Offline Offline

Posts: 1714887372

View Profile Personal Message (Offline)

Ignore
1714887372
Reply with quote  #2

1714887372
Report to moderator
1714887372
Hero Member
*
Offline Offline

Posts: 1714887372

View Profile Personal Message (Offline)

Ignore
1714887372
Reply with quote  #2

1714887372
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714887372
Hero Member
*
Offline Offline

Posts: 1714887372

View Profile Personal Message (Offline)

Ignore
1714887372
Reply with quote  #2

1714887372
Report to moderator
2112
Legendary
*
Offline Offline

Activity: 2128
Merit: 1065



View Profile
September 07, 2014, 01:36:58 AM
Last edit: September 07, 2014, 02:18:47 AM by 2112
 #2

So in order to run both bitcoind and testnet at the same time do I make two bitcoin.conf files and place one in the .bitcoin directory and one in testnet3 directory with different port settings?
It works just fine (and for more than one coin) provided:

1) don't change the coin's default P2P port, you'll get de-prioritized and will get less connections
2) the arguments processing is somewhat convoluted and the "testnet" daemon will look into "mainnet" .conf file, therefore it is better to have single such file and set the "testnet" (and others that you want to differ) through the command line. You can leave "port" and "rpcport" at the defaults.

I've been running 4 coin daemons on a single computer with a single hard-linked *.conf file for many years now.

Edit: I forgot about one thing:

3) it seems like some hackers monitor coins P2P networks for IP addresses running multiple daemons and do extremely aggressive scans for hackable services on those addresses. Maybe they think that they discovered a coin exchange or some such high-value target? Don't know the real reason, but observed this effect multiple times. So if you are e.g. running sshd on the default port on the same IP address prepare to have serious CPU load from failed ssh login attempts.

Please comment, critique, criticize or ridicule BIP 2112: https://bitcointalk.org/index.php?topic=54382.0
Long-term mining prognosis: https://bitcointalk.org/index.php?topic=91101.0
gmaxwell
Staff
Legendary
*
Offline Offline

Activity: 4158
Merit: 8382



View Profile WWW
September 08, 2014, 01:42:59 AM
 #3

So if you are e.g. running sshd on the default port on the same IP address prepare to have serious CPU load from failed ssh login attempts.
Off-topic, I know, but a useful tip: Switch to ssh key auth only, the brute forcing tools detect that its hopeless and give up.
Bungeebones (OP)
Full Member
***
Offline Offline

Activity: 178
Merit: 100



View Profile
September 12, 2014, 08:38:04 PM
 #4

Thanks for the great feedback.

One question regarding

Quote
2) the arguments processing is somewhat convoluted and the "testnet" daemon will look into "mainnet" .conf file, therefore it is better to have single such file and set the "testnet" (and others that you want to differ) through the command line. You can leave "port" and "rpcport" at the defaults.

You are talking about setting either testnet or bitcoin ports at something other than default right? And not about how I would start the two servers correct? So I would just install bitcoin core, add "testnet=1" to the bitcoin.conf file and then, when I start bitcoind from the command line both are running? I didn't notice that behavior before? After I first installed and ran testnet it looked like it only downloaded the blockchain for the testnet. So It was also downloading the regular blockchain in the background and I couldn't see it?
deepceleron
Legendary
*
Offline Offline

Activity: 1512
Merit: 1028



View Profile WWW
September 14, 2014, 03:40:38 PM
 #5

Bitcoin mainnet and testnet are unfortunately woven so they will access the same config file. The best way to keep track of what's running:

1. Make a separate copy of the program directory for testnet, and rename the bitcoind executable there to testnetd or such, so you will be able to monitor and identify which process is running.
2. Start both with an explicit and independent -datadir option so there is no chance of misconfiguration. I would put the start command line in a shell script for each so you don't have to remember it when you restart one. Also you can put arguments in a script so you don't have to type out the datadir for issuing RPC commands:
Code:
#!/bin/bash
/home/username/testnet/testnetd -datadir /home/username/testnetdata -testnet $1 $2 $3 $4 $5

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!