Skip to content

Instantly share code, notes, and snippets.

@dmdeklerk
Last active July 16, 2024 08:15
Show Gist options
  • Save dmdeklerk/93b31868767be788aa4cc541520afcd1 to your computer and use it in GitHub Desktop.
Save dmdeklerk/93b31868767be788aa4cc541520afcd1 to your computer and use it in GitHub Desktop.
CENTOS SETUP

Heat Server CENTOS setup

You can run a HEAT node on a 8 dollar a month digital ocean virtual machine, these are available here.

https://www.digitalocean.com/pricing/droplets#basic-droplets

When you create a droplet and choose CENTOS as its OS the below instructions will help you get started.

Important! Choose Intel nvme disk

We use the following droplet settings.

  • OS = CENTOS
  • Droplet type = Basic (shared cpu)
  • CPU = Premium Intel NVMe SSD
  • $8/mo

Preparation

Prepare your fresh CENTOS server with a single command (installs docker, sets up a heatledger user)

sudo yum update -y; sudo yum install -y yum-utils device-mapper-persistent-data lvm2; sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo; sudo yum install -y docker-ce docker-ce-cli containerd.io; sudo systemctl start docker; sudo systemctl enable docker; sudo adduser heatledger; sudo usermod -aG docker heatledger; echo "Setup complete. Docker and user 'heatledger' are ready."

Installation

Now create the starter script at /home/heatledger/starter.sh

sudo yum install nano -y
nano /home/heatledger/starter.sh

Copy the contents below to /home/heatledger/starter.sh

#!/bin/bash

# User Configuration: Set the location for the heatledger configuration folder.
# Uncomment the next line and replace '/path/to/heatledger' with your desired path.
#FOLDER_LOCATION="/path/to/heatledger"

# Choose which heat server version to run.
DOCKER_IMAGE=heatcrypto/heatledger:4.3.1

# Default to the script's directory appended with 'heatledger' if no custom path is provided.
: ${FOLDER_LOCATION:="$(dirname "$(readlink -f "$0")")/heatledger"}

echo "Starting HEAT server at $FOLDER_LOCATION"

# Ensure the configuration and blockchain directories exist
mkdir -p "${FOLDER_LOCATION}/conf"
mkdir -p "${FOLDER_LOCATION}/blockchain"

# Path to the properties file
PROPERTIES_FILE="${FOLDER_LOCATION}/conf/heat.properties"

# Write the heatledger configuration properties to the file using a heredoc
cat > "${PROPERTIES_FILE}" << EOF
heat.numberOfForkConfirmations=2
heat.enableAPIServer=true
heat.allowedBotHosts=*
heat.apiServerHost=0.0.0.0
heat.websocketServerHost=0.0.0.0
EOF

# Start the Docker container with the configuration directory mounted
# Add -d to run in  background
docker run -d \
  -p 7733:7733 \
  -p 7755:7755 \
  -p 7744:7744 \
  --restart=on-failure:1 \
  -v "${PROPERTIES_FILE}:/conf/heat.properties" \
  -v "${FOLDER_LOCATION}/blockchain:/blockchain" \
  --memory="8g" \
  -e JAVA_OPTS="-Xms1g -Xmx6g" \
  $DOCKER_IMAGE

If you wish to add configurations you can do so in the heredoc section above (like setup your forger key).

Important, we need to increase the RAM on our virtual machine

1. Update System

sudo yum update -y

2. Create and Enable a 16GB Swap File

sudo fallocate -l 16G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

3. Adjust Swappiness

sudo sysctl vm.swappiness=60
echo 'vm.swappiness=60' | sudo tee -a /etc/sysctl.conf

5. Verify Swap Space

sudo swapon --show
free -h

Run the server

Now run the starter.sh script to start your HEAT server.

bash /home/heatledger/starter.sh

Make sure you stop your docker container when making changes, the start it with the starter.sh script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment