Minecraft server - How To


263 posts   Page 1 of 11   1, 2, 3, 4, 5 ... 11
by randrade » Tue Jan 01, 2013 6:44 pm
Hi guys.

After tinkering with my Pi for a while, I found out a way of creating a Minecraft server.

This guide isn't too complicated or hard to follow, but it's a bit long!

I used a Model B rev 2 Pi for this.

1) Flash an SD card (I'm using a 2GB) with Raspbian wheezy (follow the instructions on http://www.raspberrypi.org/downloads)

2) Put the SD card in the Pi, connect an Ethernet cable (I have no idea how Wifi performance is for this) and connect a Micro USB cable. You'll want to connect your Pi to a screen using HDMI or the SDTV connector before you connect the Micro USB cable.

3) raspi-config should come up on your screen. Set timezone, locale and keyboard layout, fix any overscan settings if you have to and then choose Overclock and set it to modest (this will NOT void your warranty).

4) Now, select memory split and set the GPU memory to 16mb (you won't need to run startx for this guide so you'll want to set as much RAM free as you can for the server)

5) Select Finish and restart the Pi.

(from here on in, you can ssh into the Pi using PuTTY or any other tool and do this, and unplug the Pi from your screen. If you don't like a headless pi, please don't disconnect anything)

6) Now, you'll want to set a static IP so that you can forward ports on your router afterwards.

7) Log in (username: pi, password: raspberry) and then:

Code: Select all
cd /etc/networks
sudo nano interfaces


8) After nano comes up on your screen, change "iface eth0 inet dhcp" to:

Code: Select all
iface eth0 inet static
address (any free network ip, for example 192.168.1.4 - you'll have to check what IPs your router assigns to network devices)
netmask 255.255.255.0
gateway (your router's ip)
nameserver (your router's ip)


9) Press control+x, press Y, enter and then type sudo reboot.

10) Now, you'll want to open port 25565 on your router. Since everyone has their own router, I'm not going to post a guide for this - check your router documentation or google for instructions.

11) Unfortunately, we can't wget the official Java VM package from Oracle, so you will need to download the package to your computer and send it via SSH (use WinSCP for Windows) to /home/pi. Download link: http://jdk8.java.net/fxarmpreview/index.html

12) Once you have ssh'd the package to /home/pi, do the following:

Code: Select all
mkdir -p /opt
sudo tar zxvf (name of package) -C /opt
rm (name of package)
sudo /opt/jdk1.8.0/bin/java -version


13) If you don't get any error messages after executing the last command, give yourself a pat on the back - you're getting there!

14) Now, you will need to go to the official Minecraft website to download the server jar: https://s3.amazonaws.com/MinecraftDownl ... server.jar (either wget this to /home/pi or ssh it from your computer to /home/pi)

15) After this, type this into the terminal: cd /home/pi

16) To run the actual server," sudo /opt/jdk1.8.0/bin/java -Xms128M -Xmx256M -jar /home/pi/minecraft_server.jar nogui"

NOTE: Change the Xms and the Xmx parameters if you haven't set memory split to 16mb GPU. The total has to be less than the 2nd value in -/+ buffer/cache when you type "free -m" into terminal. If you change the parameters, make sure you only use multiples of 8, such as 8, 16, 32, 64, 128 or 256. Xms has to be smaller than Xmx.

17) It will take a while to create a map. In my case, it took 200 seconds, which amounts to approximately 3 and a half minutes. If you turn your server on after the map has been generated (let's say, after restarting your Pi or something) it shouldn't take more than 30 seconds.

18) if you ever need to edit server.properties, type "stop" while the server is running, and then type "sudo nano /home/pi/server.properties" .

And there you go. Your minecraft server is up and running.

I connected to mine using my laptop and it would run well for myself. I would only have some chunks not being downloaded from time to time, but it's a rare thing.

If you want to let someone from outside your network connect to your server, give them your IP (check it at http://www.omeuip.com).

Here's my server, running 24/7: randrade18.no-ip.org
If you want to test the speeds you get to my server, please go to http://randrade18.no-ip.org/mini (note: you don't have this - I set this up seperately when I configured my PHP server)

edit: Server down between 7PM and 9PM GMT on 1/1/13 - I'm using the Pi to wipe a flash drive!
Posts: 79
Joined: Thu Dec 27, 2012 8:42 pm
by randrade » Tue Jan 01, 2013 7:24 pm
The server is back up.
Posts: 79
Joined: Thu Dec 27, 2012 8:42 pm
by randrade » Tue Jan 01, 2013 7:56 pm
Alternatively, you can check if the server is up by going here: http://randrade18.no-ip.org/minecraft/demo/ (last server on the list, please do not abuse this as it takes up useful resources)

If the server feels slow or anything, tell me and I'll restart it.
Posts: 79
Joined: Thu Dec 27, 2012 8:42 pm
by Chapindad » Wed Jan 02, 2013 3:48 am
This is awesome. I really appreciate you doing this. I love playing with my son but we killed the rental server I had been paying because they had problems. He has been disappointed but I did not have spare PC to use to keeping it running. This is perfect for my Pi....
Posts: 23
Joined: Wed Dec 26, 2012 1:21 am
by drhitchcock » Wed Jan 02, 2013 5:48 am
Great work on this randrade. I'm looking forward to attempting this myself on my own Pi.

I was logged and tried your server and after a few minutes it would keep taking me back to the point I spawned at.

There was no wood being left behind when I was mining the tree. I'm not sure if this was a setting you had set on purpose. I've only just discovered Minecraft :)

Cheers,
Dr H
Posts: 7
Joined: Wed Jan 02, 2013 5:40 am
by drhitchcock » Wed Jan 02, 2013 11:46 am
Well I tried running this on my 512 Pi but no luck.

I get the warning:
Code: Select all
[WARNING] Can't keep up! Did the system time change, or is the server overloaded?

I had a fresh install of the OS and upgraded all the packages. I also overclocked mine to 1000mHz. My set-up is a little different, I used the Occidentalis V0.2 which is based on Wheezy. That might have had an effect.

Maybe next time ;)
Posts: 7
Joined: Wed Jan 02, 2013 5:40 am
by randrade » Wed Jan 02, 2013 11:51 am
drhitchcock wrote:Well I tried running this on my 512 Pi but no luck.

I get the warning:
Code: Select all
[WARNING] Can't keep up! Did the system time change, or is the server overloaded?

I had a fresh install of the OS and upgraded all the packages. I also overclocked mine to 1000mHz. My set-up is a little different, I used the Occidentalis V0.2 which is based on Wheezy. That might have had an effect.

Maybe next time ;)


I also get lots of warnings, but I find the server runs fine when I'm on it. Very occasionally, when I go to a place very distant from the spawn area, I get read time out errors and lose connection ( problem downloading map chunks), but this usually goes away after trying again.

In regards to your first post, that means I might have to restart the server. I'll get on it!
Posts: 79
Joined: Thu Dec 27, 2012 8:42 pm
by randrade » Wed Jan 02, 2013 4:59 pm
I think we got up to four people at once on the server! And it ran perfectly :D (though no mobs or animals, but that's because I had disabled them)

here are a couple of pictures:

http://i.imgur.com/hFiHR.jpg

http://i.imgur.com/hsybe.jpg

http://i.imgur.com/YyKtp.jpg (this one is from the Pi connected to my TV)

As you can see, the Pi throws a lot of warnings, and I'm not sure whether it has to do with a) general lag or b) the fact that there is no RTC clock on the Pi (therefore Minecraft has a hard time handling the fake hwclock's changes).

Oh, and all of the 127.0.0.1:* lost connection things are from people who checked the Minecraft server status using the PHP web page I posted above. It'll run a request (server-side, so from localhost) every time someone opens the page. Not a bug :)
Posts: 79
Joined: Thu Dec 27, 2012 8:42 pm
by randrade » Wed Jan 02, 2013 6:22 pm
If anyone has a problem with anything on my server or with the tutorial and you need a fast answer, feel free to tweet at me: @RuAn03
Posts: 79
Joined: Thu Dec 27, 2012 8:42 pm
by .not » Wed Jan 02, 2013 7:15 pm
Just built a small house somewhere near the water. But without anything to hunt for every player will soon be starved to death. The performance was surprisingly smooth, well done!
| Debian, FreeBSD | Raspberry Pi, Model B, 512MB RAM |
User avatar
Posts: 17
Joined: Wed Aug 01, 2012 8:33 pm
Location: /dev/at
by randrade » Wed Jan 02, 2013 7:19 pm
.not wrote:Just built a small house somewhere near the water. But without anything to hunt for every player will soon be starved to death. The performance was surprisingly smooth, well done!


Yep, I saw! (here's a pic for everyone: http://i.imgur.com/YPTQb.png )

I just enabled animals. I wonder if the server can handle it. If it can, I'll enable mobs :)
Posts: 79
Joined: Thu Dec 27, 2012 8:42 pm
by randrade » Wed Jan 02, 2013 7:34 pm
This is near the spawn area (you'll notice it because it's huge and has torches on top).

Written with much love for you all! http://i.imgur.com/OWrtP.png

Feel free to leave comments on the other side of the wall.
Posts: 79
Joined: Thu Dec 27, 2012 8:42 pm
by Chapindad » Thu Jan 03, 2013 3:25 am
Okay. I have it up and running. The problem is, Lag is terrible. What does you server.properties look like? I have mobs and npcs turned off, and view set to 3.
Posts: 23
Joined: Wed Dec 26, 2012 1:21 am
by randrade » Thu Jan 03, 2013 5:15 pm
Guys, would you like to see the map? :)

http://randrade18.no-ip.org/minecraft/map/

I generated this on my laptop. Using unmined, it takes all generated map chunks and converts them to a Google Maps compatible format.

Try to find your houses!

Chapindad wrote:Okay. I have it up and running. The problem is, Lag is terrible. What does you server.properties look like? I have mobs and npcs turned off, and view set to 3.



Here's my server.properties:

Code: Select all
#Minecraft server properties
#Thu Jan 03 16:16:28 WET 2013

white-list=false
level-seed=
view-distance=10
server-ip=
allow-nether=false
gamemode=0
enable-query=false
hardcore=false
level-type=DEFAULT
enable-rcon=false
motd=Raspberry Pi server
spawn-monsters=false
spawn-protection=16
difficulty=1
allow-flight=false
generator-settings=
spawn-npcs=false
level-name=world
texture-pack=
generate-structures=true
online-mode=false
max-players=20
server-port=25565
max-build-height=256
pvp=true
spawn-animals=true
snooper-enabled=true



I also disabled nether, forgot to mention this!
Posts: 79
Joined: Thu Dec 27, 2012 8:42 pm
by randrade » Sun Jan 06, 2013 6:41 pm
Good news guys -- this guide might be published in the MagPi magazine! If they publish the address of my server we might even get some new players :)
Posts: 79
Joined: Thu Dec 27, 2012 8:42 pm
by tzj » Sun Jan 06, 2013 7:11 pm
Wish I knew a way to convert a pocket edition building to a standard one...
Shame I can't see your map :/
And have you considered putting a 'safety' border around your map? That could help with risk of affecting the server when going too far out.
http://www.themagpi.com <---- Checkout the MagPi
(The MagPi - Co-Founder)
User avatar
Posts: 297
Joined: Thu Jan 05, 2012 3:09 pm
Location: Barnsley, SY, UK
by GeorgeFrench » Sun Jan 06, 2013 10:58 pm
Thanks for the post, it was really helpful!

I tried the version from Minecraft.net, but the results were not the best, so I went for Spigot (http://www.spigotmc.org) and it runs really well if anyone is wondering how to improve performance.
Posts: 2
Joined: Thu Dec 13, 2012 8:37 am
by Chapindad » Mon Jan 07, 2013 1:08 am
Thanks. I will have to try it. The performance I was getting from the Mindcraft.jar was terrible...
Posts: 23
Joined: Wed Dec 26, 2012 1:21 am
by randrade » Mon Jan 07, 2013 10:13 am
tzj wrote:Wish I knew a way to convert a pocket edition building to a standard one...
Shame I can't see your map :/
And have you considered putting a 'safety' border around your map? That could help with risk of affecting the server when going too far out.


Hmm looking at the time of your post, the Pi was running OpenELEC (hooray football streams!) It should work now. :)

Via mobile
Posts: 79
Joined: Thu Dec 27, 2012 8:42 pm
by .not » Mon Jan 07, 2013 10:14 am
I guess (.. and it's an uneducated guess as I am not a programmer.) that the alternative implementations of the Minecraft server written in a language other than Java (such as MCServer or Mineserver - there are others but most of them are currently in an early stage of development) will give you better results in general. If I find some time I'll probably play around with them a little bit.
| Debian, FreeBSD | Raspberry Pi, Model B, 512MB RAM |
User avatar
Posts: 17
Joined: Wed Aug 01, 2012 8:33 pm
Location: /dev/at
by randrade » Mon Jan 07, 2013 4:34 pm
I'll be working on a border soon tzj, good idea! :)

Also guys, I think the server was down between 10pm GMT last night and 4:30pm today. There was an error (raspbian didn't mount my flash drive correctly, and that's where I currently have the MC files because I'm out of space on the SD card) and some people might have been locked out of the server. It should be fine now though.

Also, I'll be experimenting with other server software soon - just got to see if my current world files are compatible. They should be!
Posts: 79
Joined: Thu Dec 27, 2012 8:42 pm
by randrade » Mon Jan 07, 2013 4:54 pm
Guys, I'm going to enable mobs. Just be careful with the creepers!
Posts: 79
Joined: Thu Dec 27, 2012 8:42 pm
by nematus » Thu Jan 10, 2013 7:15 pm
Thank you so much for this! It was very useful. My son has been on my back for months to get him a 24/7 server. We are running the bukkit server with about 15 mods.
Posts: 1
Joined: Thu Jan 10, 2013 7:08 pm
by Chapindad » Fri Jan 11, 2013 5:42 pm
So I did two more things and unfortunately I did them both at the same time. The first thing I did was upgrade from a class 4 SD Card to a class 8 SD Card. It seemed to boot faster but no scientific data to back that up. My thinking was that it was using the card for cache and building out the world, so the slower card was killing things. The second thing I did was overlock to 900mhz. I rationalized this because I have nothing plugged into it except the wifi adapter, so far so good. The server is now performing great and my son loves it...
Posts: 23
Joined: Wed Dec 26, 2012 1:21 am
by randrade » Fri Jan 11, 2013 7:27 pm
Chapindad wrote:So I did two more things and unfortunately I did them both at the same time. The first thing I did was upgrade from a class 4 SD Card to a class 8 SD Card. It seemed to boot faster but no scientific data to back that up. My thinking was that it was using the card for cache and building out the world, so the slower card was killing things. The second thing I did was overlock to 900mhz. I rationalized this because I have nothing plugged into it except the wifi adapter, so far so good. The server is now performing great and my son loves it...


Technically, a higher class SD card should give you a speed increase (class 8 cards are really good, I have a class 8 for my camera and when I copy pics from the card itself it's amazing)

An overclock should also increase performance a lot. It seems that 1GHz and 900MHz OC's are the best - however, I don't want to void my warranty so I'm sticking to the 800MHz overclock.

To solve some speed bottlenecks, I moved the server to a USB flash drive. It's not ideal, but it's better than using a 2GB Class 4 SD Card (I'm going to get a 4GB Class 8 eventually)
Posts: 79
Joined: Thu Dec 27, 2012 8:42 pm