Setting up your MC Server

As of Minecraft snapshot 20W16A minecraft servers now have jmx monitoring enabled. This means that using external programs you can measure the performance of your minecraft server and graph it or use data analytics to generate notifications if performance begins to degrade. This guide assumes you have some idea how to use linux, docker and how to run a minecraft server.

mkdir snapshot
cd snapshot
wget https://launcher.mojang.com/v1/objects/754bbd654d8e6bd90cd7a1464a9e68a0624505dd/server.jar 

Now lets run the server really quick to generate the eula and server.properties

java -jar server.jar

Now we can agree to the eula.

nano eula.txt

Change false to true and save using ctrl+x and hit y.

Now edit the server.properties file

nano server.properties

Change enable-jmx-monitoring to true and save.

Setting up start.sh

Lets make our start.sh

nano start.sh
#!/bin/sh
screen -d -m -S "snapshot" java -Xms1G -Xmx6G -jar server.jar

This makes a start script that makes a screen in the backgroud that runs the server. If you don't know about screen read about it here.

My complete start.sh looks like most of the extra flags are from Aikar's website which I found through the optimizations guide for servers.

#!/bin/sh

screen -d -m -S "snapshot" java -Xms1G -Xmx6G -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=100 -XX:+DisableExplicitGC -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 -XX:G1MaxNewSizePercent=80 -XX:G1MixedGCLiveThresholdPercent=35 -XX:+AlwaysPreTouch -XX:+ParallelRefProcEnabled -Dusing.aikars.flags=mcflags.emc.gs -jar server.jar

Make sure you add run permissions to your start.sh before running it.

chmod +x start.sh