Skip to content

tzasacky/mindcraft-server

Repository files navigation

Minecraft Server Setup

A high-performance Minecraft Java Edition 1.21.11 (Mounts of Mayhem) server optimized for small groups with far render distance support.

Features

  • High Performance: 12GB RAM allocation with Aikar's optimized JVM flags
  • Far Render Distance: 32 chunks view distance, 20 chunks simulation distance
  • Secure: Tailscale-only access (no public internet exposure)
  • Persistent: systemd service for auto-start on boot and auto-restart on crash
  • Automated Backups: Daily backups at 3 AM, retaining last 7 days
  • Easy Connection: Simple Tailscale setup for friends

Requirements

  • Java 21 (OpenJDK)
  • Tailscale installed and authenticated
  • Linux with systemd (tested on Ubuntu/Pop!_OS)
  • At least 12GB available RAM (uses 12GB heap)

Quick Start

1. Install Java 21

sudo apt update && sudo apt install -y openjdk-21-jre-headless

2. Install Tailscale

curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up

3. Download Server JAR

Download the latest Minecraft server JAR from https://www.minecraft.net/en-us/download/server and save as server.jar

Or for version 1.21.11 specifically:

curl -o server.jar https://piston-data.mojang.com/v1/objects/64bb6d763bed0a9f1d632ec347938594144943ed/server.jar

4. Configure Server

# Copy template and edit with your settings
cp server.properties.template server.properties

# Generate a strong RCON password
openssl rand -base64 32

# Edit server.properties and replace CHANGE_THIS_PASSWORD with your generated password
nano server.properties

5. Accept EULA

echo "eula=true" > eula.txt

6. Install systemd Services

# Copy service files
mkdir -p ~/.config/systemd/user
cp minecraft.service ~/.config/systemd/user/
cp minecraft-backup.service ~/.config/systemd/user/
cp minecraft-backup.timer ~/.config/systemd/user/

# Make scripts executable
chmod +x start.sh backup.sh

# Reload systemd and enable services
systemctl --user daemon-reload
systemctl --user enable minecraft.service
systemctl --user enable minecraft-backup.timer

7. Start the Server

systemctl --user start minecraft.service
systemctl --user start minecraft-backup.timer

Server Management

Control Commands

# Start server
systemctl --user start minecraft.service

# Stop server (graceful shutdown)
systemctl --user stop minecraft.service

# Restart server
systemctl --user restart minecraft.service

# Check status
systemctl --user status minecraft.service

# View live logs
journalctl --user -u minecraft.service -f

Backups

Automated daily backups run at 3 AM and keep the last 7 backups in the backups/ directory.

# Manual backup
./backup.sh

# List backups
ls -lh backups/

# Restore from backup
tar -xzf backups/minecraft-backup-TIMESTAMP.tar.gz

Connecting

See CONNECTION-GUIDE.md for detailed instructions on how to connect to the server using Tailscale.

Quick Summary:

  1. Install Tailscale from https://tailscale.com/download
  2. Log in with the same account or get invited to the network
  3. In Minecraft, add server with address: <YOUR_TAILSCALE_IP>

Performance Configuration

JVM Flags (start.sh)

Uses Aikar's optimized flags tuned for high-memory servers:

  • 12GB heap (-Xms12G -Xmx12G)
  • G1GC garbage collector optimized for Minecraft
  • Aggressive pre-touching for better performance

Server Settings

Key performance settings in server.properties:

  • view-distance=32 - Maximum client-supported render distance
  • simulation-distance=20 - Increased for smoother gameplay
  • sync-chunk-writes=false - Performance boost on modern hardware
  • enable-jmx-monitoring=true - Performance tracking enabled

File Structure

mindcraft-server/
├── start.sh                    # Server startup script with JVM flags
├── backup.sh                   # Backup script
├── server.jar                  # Minecraft server (gitignored)
├── server.properties           # Server config (gitignored - sensitive)
├── server.properties.template  # Template for server.properties
├── eula.txt                    # EULA acceptance
├── CONNECTION-GUIDE.md         # Instructions for connecting
├── README.md                   # This file
├── world/                      # World data (gitignored)
├── backups/                    # Backup storage (gitignored)
└── logs/                       # Server logs (gitignored)

systemd Service Files

Located in ~/.config/systemd/user/:

  • minecraft.service - Main server service with auto-restart
  • minecraft-backup.service - Backup execution service
  • minecraft-backup.timer - Daily backup scheduler

Security Notes

  • Server only accessible via Tailscale (private network)
  • No public internet exposure
  • RCON password-protected for admin access
  • server.properties excluded from git (contains RCON password)
  • World data excluded from git (personal/large files)

Troubleshooting

Server won't start

Check logs:

journalctl --user -u minecraft.service -n 50

Out of memory

Increase heap size in start.sh (change -Xms12G -Xmx12G to higher values)

Can't connect via Tailscale

Verify Tailscale is connected:

tailscale status
ping <TAILSCALE_IP>

Backups not running

Check timer status:

systemctl --user list-timers minecraft-backup.timer

Credits

  • JVM flags based on Aikar's Flags
  • Server setup optimized for high-performance with excess resources

License

Public domain - use as you wish!

About

High-performance Minecraft Java Edition 1.21.1 server with Tailscale networking, systemd services, and automated backups

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages