Toger Blog

Minecraft Server in AWS Done Too Well

A new Server

This series will go through how to host a MineCraft server, and go totally overboard on the configuration/management of it. I’ll be integrating a variety of management/monitoring tools that go far beyond the needs of the average ‘friends & family’ server, because it is fun. I’ll starting the basics and build up from there.

So, first we need a machine. I’m going to use a Amazon AWS machine for this. I’ll be using some AWS-specific features, but I don’t think any of them will be critical. In some cases I’ll show the non-AWS alternative.

  • Go the the EC2 Portal and the IAM service and select Roles. Create a role named app-minecraft. The type should be EC2, and choose No Permissions (for now). We’ll be using this later to allow the node to make backups of itself.
  • We’ll create a CentOS 7 machine on AWS. Visit https://aws.amazon.com/marketplace/pp/B00O7WM7QW and select Continue. CentOS is a free Linux distribution so you’re only paying for AWS time, not the software.
  • Select Launch with EC2 Console for US-EAST
  • Choose t2.medium (for now) and select Configure Instance Details. Choose app-minecraft for the IAM role.
  • Enable ‘Protect against accidental termination’, and choose Add Storage.
  • Make the root device 15 GB and add an additional EBS volume at 20GB. This is being done to protect the OS Select Delete On Termination for both. Select Tag Instance.
  • Set the name to ‘Minecraft Server #1’. select Configure Security Group.
  • Select Create a New Security Group. Call it sgMinecraft and allow All Traffic from ‘My Ip’. Choose Review and Launch.
  • You’ll be prompted to ensure you have access to your SSH keys and then choose Launch.
  • Connect to your new instance with SSH at centos@YOURIP.
  • First thing is to update the host and reboot:
1
sudo yum update -y; sudo shutdown -r now

You’ll get disconnected, wait a few minutes and reconnect.

  • Install java and wget:
1
sudo yum install -y java-1.7.0 wget
  • Format the 2nd drive. AWS says it mounted the drive on /dev/sdb which means it ended up on /dev/xvdb. Lets format and mount it:
1
sudo mkfs.xfs /dev/xvdb
  • Find out the device UUID. This is useful as you might move drives around and want reliable device mounting:
1
2
sudo xfs_admin -u /dev/xvdb
UUID = 3a8921a8-1fa5-4a4d-aca9-9d46a6e83418
  • Create the mountpoint for MineCraft:
1
sudo mkdir /minecraft
  • Modify /etc/fstab:
1
sudo vi /etc/fstab
  • Add the following (use your new UUID):
1
UUID=3a8921a8-1fa5-4a4d-aca9-9d46a6e83418 /minecraft xfs     defaults        1 1
  • Save the file, and mount the drive
1
mount /minecraft
  • Create a Minecraft user and proceed as that user:
1
2
3
useradd -d /minecraft minecraft
chown -Rh minecraft:minecraft /minecraft
sudo su - minecraft
  • Create /minecraft/bin and download MineCraft to it.
1
2
mkdir /minecraft/bin /minecraft/log /minecraft/var
wget https://s3.amazonaws.com/Minecraft.Download/versions/1.8.1/minecraft_server.1.8.1.jar -O /minecraft/bin/minecraft_server.jar
  • Perform a trial-launch of the server:
1
2
3
4
5
cd /minecraft/var
ln -s ../logs .
# Assuming you have read the Minecraft EULA at https://account.mojang.com/documents/minecraft_eula
echo eula=true >eula.txt
java -Xmx1024M -Xms1024M -jar /minecraft/bin/minecraft_server.jar nogui

You will get some output indicating certain files were not found. That is OK as the server is generating them for you:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
[05:55:11] [Server thread/INFO]: Starting minecraft server version 1.8.1
[05:55:11] [Server thread/INFO]: Loading properties
[05:55:11] [Server thread/WARN]: server.properties does not exist
[05:55:11] [Server thread/INFO]: Generating new properties file
[05:55:11] [Server thread/INFO]: Default game type: SURVIVAL
[05:55:11] [Server thread/INFO]: Generating keypair
[05:55:11] [Server thread/INFO]: Starting Minecraft server on *:25565
[05:55:11] [Server thread/INFO]: Using epoll channel type
[05:55:11] [Server thread/WARN]: Failed to load user banlist:
java.io.FileNotFoundException: banned-players.json (No such file or directory)
        at java.io.FileInputStream.open(Native Method) ~[?:1.7.0_71]
        at java.io.FileInputStream.<init>(FileInputStream.java:146) ~[?:1.7.0_71]
        at com.google.common.io.Files.newReader(Files.java:86) ~[minecraft_server.jar:?]
        at su.g(SourceFile:124) ~[minecraft_server.jar:?]
        at po.z(SourceFile:99) [minecraft_server.jar:?]
        at po.<init>(SourceFile:25) [minecraft_server.jar:?]
        at pp.i(SourceFile:172) [minecraft_server.jar:?]
        at net.minecraft.server.MinecraftServer.run(SourceFile:418) [minecraft_server.jar:?]
        at java.lang.Thread.run(Thread.java:745) [?:1.7.0_71]
[05:55:11] [Server thread/WARN]: Failed to load ip banlist:
java.io.FileNotFoundException: banned-ips.json (No such file or directory)
        at java.io.FileInputStream.open(Native Method) ~[?:1.7.0_71]
        at java.io.FileInputStream.<init>(FileInputStream.java:146) ~[?:1.7.0_71]
        at com.google.common.io.Files.newReader(Files.java:86) ~[minecraft_server.jar:?]
        at su.g(SourceFile:124) ~[minecraft_server.jar:?]
        at po.y(SourceFile:91) [minecraft_server.jar:?]
        at po.<init>(SourceFile:27) [minecraft_server.jar:?]
        at pp.i(SourceFile:172) [minecraft_server.jar:?]
        at net.minecraft.server.MinecraftServer.run(SourceFile:418) [minecraft_server.jar:?]
        at java.lang.Thread.run(Thread.java:745) [?:1.7.0_71]
[05:55:11] [Server thread/WARN]: Failed to load operators list:
java.io.FileNotFoundException: ops.json (No such file or directory)
        at java.io.FileInputStream.open(Native Method) ~[?:1.7.0_71]
        at java.io.FileInputStream.<init>(FileInputStream.java:146) ~[?:1.7.0_71]
        at com.google.common.io.Files.newReader(Files.java:86) ~[minecraft_server.jar:?]
        at su.g(SourceFile:124) ~[minecraft_server.jar:?]
        at po.A(SourceFile:107) [minecraft_server.jar:?]
        at po.<init>(SourceFile:29) [minecraft_server.jar:?]
        at pp.i(SourceFile:172) [minecraft_server.jar:?]
        at net.minecraft.server.MinecraftServer.run(SourceFile:418) [minecraft_server.jar:?]
        at java.lang.Thread.run(Thread.java:745) [?:1.7.0_71]
[05:55:11] [Server thread/WARN]: Failed to load white-list:
java.io.FileNotFoundException: whitelist.json (No such file or directory)
        at java.io.FileInputStream.open(Native Method) ~[?:1.7.0_71]
        at java.io.FileInputStream.<init>(FileInputStream.java:146) ~[?:1.7.0_71]
        at com.google.common.io.Files.newReader(Files.java:86) ~[minecraft_server.jar:?]
        at su.g(SourceFile:124) ~[minecraft_server.jar:?]
        at po.C(SourceFile:123) [minecraft_server.jar:?]
        at po.<init>(SourceFile:30) [minecraft_server.jar:?]
        at pp.i(SourceFile:172) [minecraft_server.jar:?]
        at net.minecraft.server.MinecraftServer.run(SourceFile:418) [minecraft_server.jar:?]
        at java.lang.Thread.run(Thread.java:745) [?:1.7.0_71]
[05:55:11] [Server thread/INFO]: Preparing level "world"
[05:55:12] [Server thread/INFO]: Preparing start region for level 0
[05:55:13] [Server thread/INFO]: Preparing spawn area: 7%
[05:55:14] [Server thread/INFO]: Preparing spawn area: 14%
[05:55:15] [Server thread/INFO]: Preparing spawn area: 27%
[05:55:16] [Server thread/INFO]: Preparing spawn area: 43%
[05:55:17] [Server thread/INFO]: Preparing spawn area: 59%
[05:55:18] [Server thread/INFO]: Preparing spawn area: 74%
[05:55:19] [Server thread/INFO]: Preparing spawn area: 88%
[05:55:19] [Server thread/INFO]: Done (8.267s)! For help, type "help" or "?"
  • In your minecraft client, add the IP of your new host and connect to it.

Hurray! You Minecraft sever works. It’ll run until you hit Ctrl-C or close your window. I’ll go on to making this more rubust in the next installment.