Jump to content

  • Curse Sites
Become a Premium Member! Help
Latest News Article

Tutorial on running minecraft on a dedicated server!


  • This topic is locked This topic is locked
146 replies to this topic

#1

citricsquid
  • Location: Stafford, England
  • Minecraft: citricsquid
  • Xbox:citricsquid

Posted 28 June 2009 - 08:00 PM

I've been doing this for a while and quite a few others have also, I've had people asking about it and for a tutorial so I decided to go ahead and make one. I need to make clear, upfront, that I am no sort of expert with linux and therefore I may make mistakes with what I tell you.

Overview...
Minecraft servers use little resources so it can run off pretty much any system, I personally use a dedicated server, however a VPS would be perfectly acceptable. Running minecraft servers from a dedicated/vps means that they can online 24/7 and are not affected by your internet connection, so you'll suffer no lag connection wise - if you're with a good provider.

If you already have a provider, you can skip this section, if you don't read on. I would personally recommend you check out either linode or slicehost for a VPS, or singlehop and burst for a dedicated. I will be using centos so it's prefered if you go with that operating system but it's up to you, I only support this as it is my choice of OS though...

Information...
The minecraft server currently refuses connections from more than 4 servers from the same IP, so each server is limited to running 4 minecraft servers, however you can create vms within a server, but I won't go into that here.

Let's get started...
Firstly you'll need an ssh client, I prefer putty but you can use any client you like. Enter your IP, username (normally root) and password, if all is correct you'll end up in your command line seeing "root@server ~", firstly change up a directory:
cd ../
Now that you're in the main directory, do:
wget ftp://mine:[email protected]/java.bin
This will download the java installer, it shouldn't take more than a few seconds to do, once it's downloaded do:
sh java.bin
This will start the install, hold down enter to confirm you agree to everything, then type "yes" and hit enter when you're done with that. If everything goes well you'll now have Java installed. (If any errors show up you can post them here and I'll try and help).

Now we're going to create a folder for your minecraft servers to run from:
mkdir minecraft
Now that we've created the folder, move into that folder:
cd minecraft
You're now in the minecraft folder! Now we're going to create a folder for the first server:
mkdir one
then change into that folder:
cd one
You're now in the folder "one" inside of "minecraft", you can now download the minecraft server client:
wget http://minecraft.net/minecraft-server.zip
Wait for it to download (should take <1 second), once done you'll need to unzip it:
unzip minecraft-server.zip
If all goes well then you'll have the contents of that folder in "one". run the following command:
ls
This should list a variety of files, "admins.txt, banned.txt, banned-ips.txt" etc.

Everything is ready now, you've installed Java and accquired all the files for your server to run, however you'll need to configure it first:
nano admins.txt
Enter your minecraft username in this folder, then press ctrl + x, press Y and hit enter. The file admins.txt should be saved with your username. Now enter server.properties:
nano server.properties
This will open up the server properties file, you'll need to add your server name, message of the day, max players and whether or not you want it private.

#Minecraft server properties
#Fri Jun 19 14:46:39 CEST 2009
verify-names=true
port=25565
max-players=16
server-name=Minecraft Server
public=true
motd=Welcome to my Minecraft Server\!
max-connections=3
You don't need to change your port unless you're going to run multiple servers, if you're running multiple just increase the port number by 1 in every server.properties. Once you've edited server.properties to your liking, hit ctrl + x, then y and then hit enter, this will save the file!

Now we've got everything configured, assuming there haven't been any errors! Now all you need to do is run the server. There are quite a few different ways to do this, you can simply run the command which will end when you close putty (or your chosen ssh client), you can run using nohup which will run forever, even when the client is closed, you can also use screen which achieves the same thing as nohup. I personally use nohup which is what I'll use for this:

nohup java -cp minecraft-server.jar com.mojang.minecraft.server.MinecraftServer
The server has now been started, if you ran the server publicly you can go to the servers list, scroll to the bottom and you should see your server listed! If it's private it won't show up, so you'll need to check out the externalurl.txt file.

If you're using nohup you'll need to disconnect from putty (or your chosen client) and then reconnect to continue administrating your server, once you're logged back in do (assuming you're using my directory structure outlined above, if not you can use your own directory structure)
cd ../minecraft/one
Now do:
nano externalurl.txt
This will show you the externalurl for connecting with to private servers.

Uploading your own levels!
assuming you're in the folder "one":
rm -rf server_level.dat
then do
wget http://website.com/server_level.dat
Change "http://website.com/server_level.dat" to the URL of your level, you'll need to upload it somewhere to the internet. You could also use SFTP. After changing your server_level.dat you'll need to restart the server.

Turning the server off
There is currently a "deficiency" in the server client which means a port will still be in use after turning a server off: If you turn the server off you'll need to edit server.properties and change the port before starting it up again.
ps aux
This will now list all processes on your server, near the bottom you should see:
root	  [b]4341[/b]  2.3  4.5 216768 46100 ?		Sl   Jun26  76:56 java -cp minecraft-server.jar com.mojang.minecraft.server.MinecraftServer
Then do:
kill 4341
where 4341 is the bold number.


I've probably missed some things in this tutorial, so I'll amend as appropriate, however it should work. If you have any questions, post below. Just to mention again: I don't claim to be or masquerade as a linux expert or anything, but this all works perfectly for me :(

Register or log in to remove.

#2

Stiggs
    Stiggs

    Tree Puncher

  • Members
  • 11 posts

Posted 28 June 2009 - 09:13 PM

I followed the instructions, but when I try and connect, it hangs on 'Connecting'. :(

#3

citricsquid
  • Location: Stafford, England
  • Minecraft: citricsquid
  • Xbox:citricsquid

Posted 28 June 2009 - 09:16 PM

Quote

I followed the instructions, but when I try and connect, it hangs on 'Connecting'. :(
I get this when the port is blocked. I doubt this is the most secure method, in fact it's very insecure and brutish, but I just do:
system-config-securitylevel
then select "disable".

#4

Stiggs
    Stiggs

    Tree Puncher

  • Members
  • 11 posts

Posted 28 June 2009 - 09:20 PM

Probably a dumb question, but where am I typing that? I put it in putty, but it gave me a 'command not found' error.

#5

citricsquid
  • Location: Stafford, England
  • Minecraft: citricsquid
  • Xbox:citricsquid

Posted 28 June 2009 - 09:23 PM

Quote

Probably a dumb question, but where am I typing that? I put it in putty, but it gave me a 'command not found' error.
Strange.

Posted Image

Doing it like that, does the blue window not come up?

#6

Stiggs
    Stiggs

    Tree Puncher

  • Members
  • 11 posts

Posted 28 June 2009 - 09:24 PM

Nope, I just get -bash: system-config-securitylevel: command not found

#7

citricsquid
  • Location: Stafford, England
  • Minecraft: citricsquid
  • Xbox:citricsquid

Posted 28 June 2009 - 10:04 PM

We solved Stiggs problem: The ports were being blocked by centos, if you have this problem run the following command:

service iptables stop
then try connecting again :(

#8

fanta
    fanta

    Tree Puncher

  • Members
  • 22 posts

Posted 29 June 2009 - 12:06 PM

What ever you do, never ever run the game as root! Otherwise you risk being hacked. Create a new user instead.

Personally I prefer "screen" instead of "nohup", because I can reopen the window agian.

#9

citricsquid
  • Location: Stafford, England
  • Minecraft: citricsquid
  • Xbox:citricsquid

Posted 29 June 2009 - 12:43 PM

Quote

What ever you do, never ever run the game as root! Otherwise you risk being hacked. Create a new user instead.

Personally I prefer "screen" instead of "nohup", because I can reopen the window agian.
How would running as root get them hacked?

(I'm interested to learn more, not being sarcastic ;))

#10

dexter
    dexter

    Carpenter

  • Members
  • 69 posts

Posted 29 June 2009 - 12:46 PM

If there is some sort of security hole in the system, running as root means your entire system would be compromised as root can obviously do anything. Running as a user, only what the user has access to would be at risk, which ideally would only be local user files and nothing else.

I'm not sure that running as root makes your more susceptible to an attack, it just gives the attacker more power once "inside".
MineCraft Server Operator v0.3b
Votekick/voteban, remote access, automated backups, cross-platform and more.
Control your server.

#11

Stiggs
    Stiggs

    Tree Puncher

  • Members
  • 11 posts

Posted 29 June 2009 - 07:58 PM

How would I go about creating a new user then?

#12

Stiggs
    Stiggs

    Tree Puncher

  • Members
  • 11 posts

Posted 02 July 2009 - 08:39 PM

Is it possible to get the server_leve.dat file off of the VPS?

#13

Guest
    Guest

    Coal Miner

  • Members
  • 120 posts

Posted 02 July 2009 - 09:03 PM

Quote

Is it possible to get the server_leve.dat file off of the VPS?
Yes.  Start either an FTP server or a webserver.  Tutorials abound online, or you can ask me or others in IRC.

#14

Angelo
    Angelo

    Out of the Water

  • Members
  • 2 posts

Posted 05 July 2009 - 02:53 PM

I get errors when trying to start the server (both using nohup and screen) on Suse:

Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
		at java.lang.ClassLoader.defineClass1(Native Method)
		at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
		at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
		at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
		at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
		at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
		at java.security.AccessController.doPrivileged(Native Method)
		at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
		at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
		at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
		at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
		at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)


#15

nick_gc
    nick_gc

    Out of the Water

  • Members
  • 3 posts

Posted 20 July 2009 - 07:21 AM

I have server space with 1and1 (linux based) but do not have the ability to connect with SSH. Is there a way to get a minecraft server running on my server space?

#16

tastypotato

Posted 26 July 2009 - 06:09 PM

I get to:

sh java.bin

Then it gives me:

Do you agree to the above license terms? [yes or no]
yes
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP ([email protected]).
  inflating: jre-6u14-linux-i586.rpm
error: can't create transaction lock on /var/lock/rpm/transaction

:[

#17

Guest
    Guest

    Coal Miner

  • Members
  • 120 posts

Posted 26 July 2009 - 08:01 PM

Quote

I get to:

sh java.bin

Then it gives me:

Do you agree to the above license terms? [yes or no]
yes
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP ([email protected]).
  inflating: jre-6u14-linux-i586.rpm
error: can't create transaction lock on /var/lock/rpm/transaction

:[
You're not running as root.  Either sudo sh java.bin , or if you're not a sudoer, su -c 'sh java.bin' , for which you need a root account.  Alternatively, you can login as root and run it, but I wouldn't recommend running Minecraft servers as root.

#18

tastypotato

Posted 27 July 2009 - 12:03 AM

Quote

Quote

I get to:

sh java.bin

Then it gives me:

Do you agree to the above license terms? [yes or no]
yes
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP ([email protected]).
  inflating: jre-6u14-linux-i586.rpm
error: can't create transaction lock on /var/lock/rpm/transaction

:[
You're not running as root.  Either sudo sh java.bin , or if you're not a sudoer, su -c 'sh java.bin' , for which you need a root account.  Alternatively, you can login as root and run it, but I wouldn't recommend running Minecraft servers as root.
okay, so I managed to get linux on a running old laptop of mine. Brand new install of ubuntu 9.04.

I try and run the java.bin and it gives me

java.bin: 438: rpm: not found

#19

Colt6615
    Colt6615

    Newly Spawned

  • Members
  • 1 posts

Posted 01 September 2009 - 05:11 PM

Do you have another source for the java installer, I believe that

http://minecraftservers.com
is down.

#20

GolemdX
    GolemdX

    Out of the Water

  • Members
  • 9 posts

Posted 03 October 2009 - 07:25 PM

Little mistake. This isn't really a dedicated server, it's a remote server. Dedicated servers don't have to be remote, and remote servers don't have to be dedicated. Just a little thing that bugs me, otherwise good job :).