4

Well, first of all, I can't keep monerod running on my VPS through an ssh session. When I close the ssh session it stops running.

Second question is do I need to open the port? Is it TCP or UDP port that needs to open? A quick command?

Seriously, the official guide is way too simple...it just tells to "simply run monerod" then you are running a node.

Thanks

Alex
  • 85
  • 2
  • 5

2 Answers2

8

Method 1) A one-time start of monerod

You can use 'screen' to keep it running when you log out.

Ubuntu: apt-get install screen

CentOS: yum install screen

screen monerod --rpc-bind-ip <your external IP address> --rpc-bind-port 18089 --restricted-rpc --confirm-external-bind

Replace with the IP address of your VPS.

When monerod is running inside of screen, you can press Control-a-d to detach from the screen session and return to the command line. You use screen -r to reattach to the session.

Method 2) Keep monerod running perpetually

Create a new blank file called monerod-cron and add the following line. Be sure to enter the full path to your monerod binary and your external IP address.

0 * * * * <full/path/to/monerod> --detach --rpc-bind-ip <your_ip> --rpc-bind-port 18089 --restricted-rpc --confirm-external-bind

Example:

0 * * * * /usr/local/bin/monerod --detach --rpc-bind-ip 100.22.33.44 --rpc-bind-port 18089 --restricted-rpc --confirm-external-bind

Save the file and load it into your crontab by running crontab monerod-cron. This will start monerod automatically every hour. If monerod is already running, it will not start a second copy.

To view the monerod logfile: tail -f ~/.bitmonero/bitmonero.log

To view the crontab logfile: tail -f /var/log/cron

Notes

Your firewall will need to accept incoming connections to TCP port 18089.

There's some more info at https://moneroworld.com/#nodes

apexio
  • 106
  • 3
2

@apexio's answer should work fine, but you might want to create a systemd unit if that's what your distro uses.

You can grab a pre-made systemd service spec from the source tree if you didn't want to write it yourself. Copy that file to /etc/systemd/system/monerod.service.

After that you can load it in with sudo systemctl daemon-reload, start it with sudo systemctl start monerod, and make it start on reboot with sudo systemctl enable monerod.

You can check if the daemon is running with sudo systemctl status monerod, and check the logs with sudo journalctl -u monerod.service.

Here's the commands that you need to run to download the spec, load it, enable it and start it.

sudo curl -O /etc/systemd/system/monerod.service https://github.com/monero-project/monero/raw/master/utils/systemd/monerod.service
sudo systemctl daemon-reload
sudo systemctl enable monerod
sudo systemctl start monerod

ninja edit: You probably want the daemon running as its own user, you can make one with sudo useradd -r -s /bin/false monero

Second question is do I need to open the port? Is it TCP or UDP port that needs to open? A quick command?

Everything will work if you left it as-is, but it would help the network if you opened ports. I believe you need to open TCP port 18080, but you can configure that with the --p2p-bind-port parameter.

Matthew Smith
  • 451
  • 3
  • 9