I was hoping to get the whole guide up before someone else got a word in, but it seems markdown toggle has failed me.
The three most important parts to making a server run on a raspberry pi 2 are:
Use the oracle JDK (openjdk isn't as fast)
Use spigot
Use the --server option when running spigot's jar
I don't know how the --server option works, but it does wonders for terrain generation. When we tried a server without this option, it only seemed to use one or two cores at a time, and the RPI2 has four cores. If you need more speed, you can use the world border plugin to pre-generate a bunch of terrain around spawn.
Obviously there's a limit to what the server can do (a hundred or so cows colliding in a pen caused us some trouble), but I think it's fun for a group of around 4 friends. I think we've gotten up to 6 without issue.
Any feedback is appreciated. I've considered adding bits on scheduling automatic backups and bukkit plugins, but I thought that might be jumping the gun. My favorite thing I did on the server is install the Minecraft Overviewer, which last I checked, does not have an Arm release. I had to build it myself, but it makes pretty pictures.
The ip from the previous tutorial only works for the netowrk the raspberry pi isconnected to, it does not work for the internet as a whole. In most houses, theonly thing that has an internet ip address is the router. In order to allowthe raspberry pi to use the internet ip address, the router must be configuredfor it. This is called "port forwarding".
The steps for port forwarding vary from router to router, but some things aresimilar. As in the previous tutorial, run 'ifconfig'. Again, this should listsomething like the following:
The ip for the server was "192.168.0.141". Usually, the ip of the router is thesame, but with a 1 at the end. In this case: "192.168.0.1". Go to this in a webbrowser, the same as any other webpage ("192.168.0.1" instead of"http://www.example.com"). It should be a webpage requesting a username andpassword. If these have not been configured, you can probably look up thedefault username and password for that router (google/bing/etc.).
Once logged in (which, honestly, might take a while to figure out), look aroundthe various menus for an option called "port forwarding". Once you find it, adda port with the following settings:
Internal IP: raspberry pi ip (eg. 192.168.0.141)
This tells the router who needs the internet address
Port: 25565 (this is the default minecraft server port)
This should be internal port start, internal port end, external port start, and external port end.
Or it could be any range containing your minecraft port. It just needs to move from the external to the internal.
Protocol: TCP or BOTH
You really only need TCP, or so I'm told
At this point, the raspberry pi server should be accessabe from anywhere onlineusing the router's external ip. The easiest way to find the external ip is toconnect to the router and search for "what is my ip" (on google/bing/etc.).Most search engines will reply with your ip address listed above the searchresults. Now is a good time to test the minecraft server, this time connectingwith the new ip address that can be used from anywhere.
URL
An external ip address works, but sometimes, it can change. It would be better to have a url from something like noip.com or freedns.afraid.org. This willredirect a url (eg. 'example.chickenkiller.com') to the ip address, and can be updated if the server moves or the ISP decides to change ip addresses.Here are the steps to setup a url by getting a subdomain from freedns.afraid.org.
Destination: your ip address (the router one. It might auto-fill)
Once the subdomain has been set up, the url '.' can be used to connect to the minecraft server instead of the ip address(eg. 'example.chickenkiller.com') the raspberry pi can be configured to automatically update the subdomain to point to the correct ip every so often.That way, if the raspberry pi moves, or the router's ip address changes,the url will be updated to point to the correct ip address.
Dynamic DNS
Dynamic DNS is the service that lets a url update when the ip changes
Go to the "Dynamic DNS" option on freedns.afriad.org page. Next to the newlycreated url, there should be a link to "quick cron example". Most of this filecontains comments, but the last line is an entry for the cron table, which isa linux tool for making tasks run automatically. To use it, run 'crontab -e' inthe terminal, wait for the crontab file to appear, then add the last line ofthe cron example to the end of the file. Copy and paste in the terminal, areoften 'Ctrol+shift+c' and 'Ctrol+shift+v' (for putty people, its hilight andright-click). Save and exit (eg. Ctrl+X and then Y at the prompt to save), andthe raspberry pi should now automatically keep the url up to date.
In summary:
'crontab -e'
copy last line of quick cron example to the end ('Ctrl+Shift+v')
'Ctrl+x'
'Y'
It may take a bit of time for the url to start working.
Static IP
As a final note, sometimes, the raspberry pi's ip address within rhe router(eg. 192.168.0.141) might change. To prevent this, the raspberry pi can requesta particular ip. A tutorial on this can be found at[https://www.modmypi.com/blog/tutorial-how-to-give-your-raspberry-pi-a-static-ip-address](https://www.modmypi.com/blog/tutorial-how-to-give-your-raspberry-pi-a-static-ip-address). It involves editing the file /etc/network/interfaces (using'sudo nano /etc/network/interfaces') to read like the following
auto lo
iface lo inet loopback
iface eth0 inet static
address 192.168.0.141
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254
allow-hotplug wlan0
iface default inet dhcp
The 'iface eth0 inet static' section is the important part, and it's largelyfilled out with data from 'ifconfig'. If you didn't get the pi's ip address fromthe eth0 section, swap out eth0 for whatever had it (eg.'iface wlan0 inet static'). The 'broadcast' and 'netmask' are listed in the samesection (as 'Bcast' and 'Mask'). 'network' and 'gateway' can be found by running'netstat -nr'. They will be listed as "Destination" and "Gateway", eg.
Address can the first three number from network, followed by any number below255 that is not in use. It's a good idea to pick something between 100 and 200,since these are probably available. Bear in mind that if the ip of theraspberry pi is changed to something new, the ip for the router's portforwarding must be changed as well.
Spigot is an alternative to the official minecraft server. Here's a quickfeature comparison:
Plugin Support YES NO
Speed FAST SLOW
Configuration Options MANY FEW
Official NO YES
Because the Raspberry Pi is slow, the extra speed of Spigot is vital.
Setup
Prerequisites
The spigot server requires two other programs: java and git. On Raspbian,these should already be installed. If they aren't, installation can be done with a program called apt-get, which can be used from the terminal with these commands:
#This is a comment. It doesn't do anything
sudo apt-get update #update installer
sudo apt-get install git #installs git
git config --global --unset core.autocrlf #configures git
#If java isn't already installed, this command will install it:
sudo apt-get install oracle-java8-jdk
Note: We use Oracle's JVM because OpenJDK is slow on the Pi's ARM processor.
Spigot
Installing Spigot itself isn't quite this easy. It's a good idea to put the server files in their own folder, named minecraft.
mkdir minecraft #make a folder called 'minecraft'
cd minecraft #go into that folder
Next, download the Spigot installer (BuildTools.jar):
java -jar BuildTools.jar #This might take a while
ls #List files in this folder
Once it finishes, there should be a file called spigot-x.jar, except instead of x, it will contain the Minecraft server version (eg. spigot-1.11.2.jar). This is the jar that runs the Minecraft server. Now is a good time to test it.
Test
Before starting the server, its a good idea to find out the raspberry pi's ip.Run `ifconfig` in the terminal, and look for a line with "inet addr". Something like the following will appear.
"inet addr" is the ip of the raspberry pi. Ignore the section labeled "lo" with "inet addr: 127.0.0.1". In the example above,the ip is "192.168.0.141". Write this down; it will be used to connect to the server later.
Note: Ips have four numbers, and most local ips start with 192.168.
To run the server:
java -jar -Xmx512m -server spigot-x.jar #replace x with the spigot version
The arguments are there for the following reasons:
`java` - The minecraft server is a java program
`-jar` - Tells java to run a jar file
`-Xmx512m` - Tells java to only allocate 512MB (0.5G) of ram, because theraspberry pi doesn't have much ram
`-server` - This option appears to make the server run across multiple cores
`spigot-x.jar` - The server jar that java will run
The first time it is run, it will crash, saying that you need to agree to the EULA:
[14:59:41 WARN]: Failed to load eula.txt
[14:59:41 INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
[14:59:41 INFO]: Stopping server
To do this, simply open eula.txt (`nano eula.txt`), and change eula=false to "eula=true". Save, exit, and run the server again.
This time, it will take a while to start up, but eventually it will finish preparing spawn.Now another computer on the same network can log in to the server using the ipfrom the `ifconfig` command (eg. 192.168.0.141). To close the server, simply enter `stop` into the minecraft console.
Tmux
The minecraft server is now running, but there's a problem. If you close the terminal (or ssh session) that the server is running in, the server will be killed. However, a program called `tmux` can run things in the background, even when you're not logged in.
First, close the server, and install tmux.
#If the minecraft server is running, the stop command will turn of the server
stop
#Install tmux
sudo apt-get install tmux
Now, tmux can create a minecraft server that will run even if you log out.
#Start a tmux session (named minecraft) that will run in the background:
tmux new -s minecraft
#Once the background terminal starts up, run the server
java -jar -Xmx512m -server spigot-x.jar
Press "Ctrl+b", then "d" to leave the tmux session. Now, even if the terminal window is closed, or ssh session is ended, the server will continue running. In order to return to the background terminal, run tmux a -t minecraft.
tmux a -t minecraft
#Now you can issue minecraft commands
difficulty 2
op notch
say hi
#Press `Ctrl+b d` to leave without stopping the server
#To stop the server and exit screen entirely:
stop #Stops the minecraft server
exit #Closes tmux
Okay, I think I solved my own problem. I grouped all of the tiles by texture, and rendered each texture's tiles in one sweep without rebinding. It seems like the hash map and array lists would be to much overhead to be worth it, but the frame rate is up so I'm keeping it until I find something better.
Yeah, you're right. I guess I'll keep looking. maybe if I delete the test.prop...
@HingedPrism, thanks, that worked
@rckymtnrfc, make sure that there are no hidden back-up files in that folder. I had a hidden test.prop~ file that kept trying to load the missing files.
I was going to use this mod for 1.8.9 modded thing I'm doing, however it's outdated with the last changes made on github being from last year. So, I've updated it. It should work for forge 1.8.9 versions.
1
I was hoping to get the whole guide up before someone else got a word in, but it seems markdown toggle has failed me.
The three most important parts to making a server run on a raspberry pi 2 are:
I don't know how the --server option works, but it does wonders for terrain generation. When we tried a server without this option, it only seemed to use one or two cores at a time, and the RPI2 has four cores. If you need more speed, you can use the world border plugin to pre-generate a bunch of terrain around spawn.
Obviously there's a limit to what the server can do (a hundred or so cows colliding in a pen caused us some trouble), but I think it's fun for a group of around 4 friends. I think we've gotten up to 6 without issue.
1
Any feedback is appreciated. I've considered adding bits on scheduling automatic backups and bukkit plugins, but I thought that might be jumping the gun. My favorite thing I did on the server is install the Minecraft Overviewer, which last I checked, does not have an Arm release. I had to build it myself, but it makes pretty pictures.
1
Share with Friends
This is the hardest, most important part
The ip from the previous tutorial only works for the netowrk the raspberry pi isconnected to, it does not work for the internet as a whole. In most houses, theonly thing that has an internet ip address is the router. In order to allowthe raspberry pi to use the internet ip address, the router must be configuredfor it. This is called "port forwarding".
The steps for port forwarding vary from router to router, but some things aresimilar. As in the previous tutorial, run 'ifconfig'. Again, this should listsomething like the following:
The ip for the server was "192.168.0.141". Usually, the ip of the router is thesame, but with a 1 at the end. In this case: "192.168.0.1". Go to this in a webbrowser, the same as any other webpage ("192.168.0.1" instead of"http://www.example.com"). It should be a webpage requesting a username andpassword. If these have not been configured, you can probably look up thedefault username and password for that router (google/bing/etc.).
Once logged in (which, honestly, might take a while to figure out), look aroundthe various menus for an option called "port forwarding". Once you find it, adda port with the following settings:
At this point, the raspberry pi server should be accessabe from anywhere onlineusing the router's external ip. The easiest way to find the external ip is toconnect to the router and search for "what is my ip" (on google/bing/etc.).Most search engines will reply with your ip address listed above the searchresults. Now is a good time to test the minecraft server, this time connectingwith the new ip address that can be used from anywhere.
URL
An external ip address works, but sometimes, it can change. It would be better to have a url from something like noip.com or freedns.afraid.org. This willredirect a url (eg. 'example.chickenkiller.com') to the ip address, and can be updated if the server moves or the ISP decides to change ip addresses.Here are the steps to setup a url by getting a subdomain from freedns.afraid.org.
Once the subdomain has been set up, the url '.' can be used to connect to the minecraft server instead of the ip address(eg. 'example.chickenkiller.com') the raspberry pi can be configured to automatically update the subdomain to point to the correct ip every so often.That way, if the raspberry pi moves, or the router's ip address changes,the url will be updated to point to the correct ip address.
Dynamic DNS
Dynamic DNS is the service that lets a url update when the ip changes
Go to the "Dynamic DNS" option on freedns.afriad.org page. Next to the newlycreated url, there should be a link to "quick cron example". Most of this filecontains comments, but the last line is an entry for the cron table, which isa linux tool for making tasks run automatically. To use it, run 'crontab -e' inthe terminal, wait for the crontab file to appear, then add the last line ofthe cron example to the end of the file. Copy and paste in the terminal, areoften 'Ctrol+shift+c' and 'Ctrol+shift+v' (for putty people, its hilight andright-click). Save and exit (eg. Ctrl+X and then Y at the prompt to save), andthe raspberry pi should now automatically keep the url up to date.
In summary:
It may take a bit of time for the url to start working.
Static IP
As a final note, sometimes, the raspberry pi's ip address within rhe router(eg. 192.168.0.141) might change. To prevent this, the raspberry pi can requesta particular ip. A tutorial on this can be found at[https://www.modmypi.com/blog/tutorial-how-to-give-your-raspberry-pi-a-static-ip-address](https://www.modmypi.com/blog/tutorial-how-to-give-your-raspberry-pi-a-static-ip-address). It involves editing the file /etc/network/interfaces (using'sudo nano /etc/network/interfaces') to read like the following
The 'iface eth0 inet static' section is the important part, and it's largelyfilled out with data from 'ifconfig'. If you didn't get the pi's ip address fromthe eth0 section, swap out eth0 for whatever had it (eg.'iface wlan0 inet static'). The 'broadcast' and 'netmask' are listed in the samesection (as 'Bcast' and 'Mask'). 'network' and 'gateway' can be found by running'netstat -nr'. They will be listed as "Destination" and "Gateway", eg.
Address can the first three number from network, followed by any number below255 that is not in use. It's a good idea to pick something between 100 and 200,since these are probably available. Bear in mind that if the ip of theraspberry pi is changed to something new, the ip for the router's portforwarding must be changed as well.
1
Make a Spigot Minecraft server
Spigot is an alternative to the official minecraft server. Here's a quickfeature comparison:
Because the Raspberry Pi is slow, the extra speed of Spigot is vital.
Setup
Prerequisites
The spigot server requires two other programs: java and git. On Raspbian,these should already be installed. If they aren't, installation can be done with a program called apt-get, which can be used from the terminal with these commands:
Note: We use Oracle's JVM because OpenJDK is slow on the Pi's ARM processor.
Spigot
Installing Spigot itself isn't quite this easy. It's a good idea to put the server files in their own folder, named minecraft.
Next, download the Spigot installer (BuildTools.jar):
Then run BuildTools.jar:
Once it finishes, there should be a file called spigot-x.jar, except instead of x, it will contain the Minecraft server version (eg. spigot-1.11.2.jar). This is the jar that runs the Minecraft server. Now is a good time to test it.
Test
Before starting the server, its a good idea to find out the raspberry pi's ip.Run `ifconfig` in the terminal, and look for a line with "inet addr". Something like the following will appear.
"inet addr" is the ip of the raspberry pi. Ignore the section labeled "lo" with "inet addr: 127.0.0.1". In the example above,the ip is "192.168.0.141". Write this down; it will be used to connect to the server later.
Note: Ips have four numbers, and most local ips start with 192.168.
To run the server:
The arguments are there for the following reasons:
The first time it is run, it will crash, saying that you need to agree to the EULA:
To do this, simply open eula.txt (`nano eula.txt`), and change eula=false to "eula=true". Save, exit, and run the server again.
This time, it will take a while to start up, but eventually it will finish preparing spawn.Now another computer on the same network can log in to the server using the ipfrom the `ifconfig` command (eg. 192.168.0.141). To close the server, simply enter `stop` into the minecraft console.
Tmux
The minecraft server is now running, but there's a problem. If you close the terminal (or ssh session) that the server is running in, the server will be killed. However, a program called `tmux` can run things in the background, even when you're not logged in.
First, close the server, and install tmux.
Now, tmux can create a minecraft server that will run even if you log out.
Press "Ctrl+b", then "d" to leave the tmux session. Now, even if the terminal window is closed, or ssh session is ended, the server will continue running. In order to return to the background terminal, run tmux a -t minecraft.
1
How to make a Raspberry Pi Minecraft Server
Many people have long wanted to make the ultimate minecraft server on a raspberry pi... AND NOW YOU CAN!
Here's what you need:
If you haven't set up the raspberry pi yet:
Here's the plan:
Common bash commands:
1
Okay, I think I solved my own problem. I grouped all of the tiles by texture, and rendered each texture's tiles in one sweep without rebinding. It seems like the hash map and array lists would be to much overhead to be worth it, but the frame rate is up so I'm keeping it until I find something better.
1
@HingedPrism, thanks, that worked
@rckymtnrfc, make sure that there are no hidden back-up files in that folder. I had a hidden test.prop~ file that kept trying to load the missing files.