Running a Minecraft Server

I used to run a small Minecraft server with some friends, these are my notes on how I setup the machine.

So for server specification required I looked on the forums (but the wiki has a better page now). For the machine I went with BuyVM after finding them on low end box. For the OS, I used Ubuntu 10.04 32 bit server. Mostly because I’ve been using Ubuntu for years. First adding some extra repos.

sudo nano /etc/apt/sources.list
deb http://uk.archive.ubuntu.com/ubuntu/ lucid main restricted universe multiverse
deb http://uk.archive.ubuntu.com/ubuntu/ lucid-security main restricted universe multiverse
deb http://uk.archive.ubuntu.com/ubuntu/ lucid-updates main restricted universe multiverse
deb http://archive.canonical.com/ubuntu lucid partner

Then install Java

sudo apt-get install sun-java6-jre sun-java6-bin sun-java6-fonts

Added an account for the minecraft server to run as, to keep things nice and separate. Then followed mostly following some good instructions from the forums. First logging into the server with the minecraft account, then sftp’d the latest server jar over and ran it with

java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

which is fine for testing but means you need to be logged into a terminal all the time. Running using screen is much more useful.

screen -dmS minecraft java -Xms768M -Xmx768M -jar minecraft_server.jar nogui

xms is the size of the memory the server starts with. xmx is the size of the memory the server can expand upon. I took the directory structure from another forum post. One other thing to watch out for is IP6 vs. IP4

screen -dS $SCREEN_NAME java -Xmx${MEMORY}M -Xms${MEMORY}M -Djava.net.preferIPv4Stack=true -jar $SERVER_PATH/minecraft_server.jar nogui

screen is great but no use if the server crashes when you are away from an ssh client, so I used a auto backup script called from cron. With another copy used to restart the Minecraft server if it was not already running.

Leave a Reply

Your email address will not be published. Required fields are marked *