A few weeks ago I endeavored to find an alternate form of entertainment. All of the video games I desired to play, had yet to be released, and I can only focus on coding for so many hours a day.
This line of thought inevitably led me to the though, ‘Hey, why don’t you set-up a MineCraft server, it can’t be that hard!’.
First steps were installing Ubuntu 11.10 Server Edition as a Virtual Machine on my WIndows 7 desktop.
My first piece of advice, especially if you want to have maps of your world, is to not skimp on the size of the Virtual Machine. I started off with a pretty meager hard disk size and allocated very little RAM to it. Ubuntu is Linux, so why would it need much of anything? What I didn’t realize was, the MineCraft JAR file consumes RAM at an enormous rate and definitely has a few memory leaks (although this keeps getting better and better).
Additionally, many of the Minecraft Map generators, and inevitably the only one I could get working on Ubuntu, generate a lot of high quality images to represent the world. Any attempt to downsize the number of them or size of them, requires so much processing overhead, that the map generations take forever.
It’s better to let it produce 5,000 small images, then to have it generate 5,000 small images and then compress that down to a few hundred. However, this takes hard disk space, and Oracle’s Virtual Box does not dynamically resize like some other virtualization software. I ended up having to create a mounted shared drive that was on the host operating system, to store the enormous maps. Not a big deal, but there is some interesting buggy behavior with mounting these.
Additionally, from a resource perspective, although you can run a reasonably size world on very little, ideally, for performance, you want a quad-core machine ( so you can give the server 2 CPU’s and yourself 2 CPU’s), and 8GB of RAM. Currently I’m running only 2 CPU and 4 GB of RAM (split half to me and half to the VM), and although the world itself (being run by the minecraft_server.jar) runs fine, I can’t do any map generation while it is up.
Uptime is in no way guaranteed. I have about 4-6 friends playing on the server, and although it is up about 80% of the time, there are an incredible number of things that can take your server down when it’s just running on a machine in your house. One of the first few nights, our cat hit the power strip it was plugged in to, down goes the world. Later on, we blew a fuse, which took down the section of our apartment that has the server running. This also led to a corrupted world file with 22,000 entities (monsters) on one chunk, which made it impossible to the load the world until I ran the world files through a python cleanup script that deleted the extra entities.
Don’t be intimidated by the networking aspects of it. Although daunting if you’ve never dealt with port-forwarding or DNS entries before, a little research goes a long way. Everything is really just a pointer to something else. Like an exit sign for a city, or an address for a house. I used no-ip.com to point a pretty domain name to my house’s IP address, and then used the advanced networking section of my Linksys wireless router to port-forward the appropriate Minecraft port to the IP address of the virtual server (it needs to have a different one from the host machine it is running on). Ideally, if you can make that internal IP static, it would be helpful, unfortunately, it doesn’t appear my version of the Linksys Router allows that. This leads to having to adjust it whenever the virtual machine’s IP changes, which happens almost every time you restart it.
All-in-all, a novice’s project, but it makes you feel somewhat powerful when you can setup and run your own server. Saves the $15-$20/month it costs to run one on someone else’s virtual machines.