GUIDE: Setting up and Monitoring a Linux MineCraft Server

Discussion in 'Bukkit Help' started by lDucks, Jan 10, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    lDucks

    Hello, I'm lDucks and this is my guide on how to run a Linux MineCraft server. I ran a server for about 8 months, I've been creating plugins for about 13 months, and I administrated a server for over a year. This guide may have some errors in it since even after rereading it and having other people reread it countless times, I still have to change little errors I find. I hope this helps people out there who don't know how to run servers.

    All the information in this guide are things I have picked up in my experiences and learned through my love for CS. Enjoy.

    This guide is to teach you how to set up and run a physical server. This guide does not contain anything with regards to running a community or running a website. This is just how to setup and monitor your server and make sure the backend is running smoothly. Obviously if you want to run a server for you and your friends you can run one off your computer or a cheap Minecraft host. However, if you want to run one on a larger scale, you will need to do a lot more work that I will explain in this guide.

    Prerequisites:
    • Linux Server (This is a guide for a Linux server, all the commands on this server are for CentOS but they don’t differ much from other Linux distributions)
    • Knowledge of Filezilla or another FTP client
    • Knowledge of basic command line navigation (Windows or Linux, as long as you know what a "terminal" is and how to use its basic commands)
    What you need to download:
    • Latest craftbukkit build
    This guide is set up in the order in which you will set the server up. It starts at step one, and ends with extra information that you will need after setup in order to make sure your server is running properly.

    Picking a Server
    First of all, if you are opening up a Minecraft server you should expect to put some money into it. Running a server off your own personal computer, even a computer on your network, is not a good idea. To run a server you need to have the correct internet service provider and a proper server setup. I highly recommend that if you want to run a Minecraft server you start it up with a Minecraft host.

    What is a Minecraft host?
    Well, Minecraft has become big enough where there are hundreds of hosting companies out there dedicated to Minecraft hosting. I'm not going to get too into how to run a server from them because you don't have much functionality and most of them use MCMyAdmin. If you are running a server that does not require constant maintenance (paintball, hunger games, etc.) then you really don't need to read much past this. You can get a host for ~$30 a month that will do everything you need and more. However, if you want to make a server that requires you to create CRON jobs, edit core files, install software, has more processing speed, etc. you will eventually need to get a dedicated server host. Usually once you get past ~10GB of RAM from an MC host, the prices are more expensive than just renting a dedicated server. Once you get past ~30 players on your server and you're able to pull in $100+ per month in donations, you need to expand.

    For those of you looking for good Minecraft hosts, I have had some good experiences with https://allgamer.net/ - I have supplied a list of Minecraft hosts at the end of this guide.

    This is where you start looking for dedicated servers. A dedicated server is not made specifically for Minecraft. It is an entire physical server that you can rent from a datacenter and use to your heart’s desire. In this guide I will only be going over how to run a Linux operated server. I highly recommend to anyone looking to run a Minecraft server to get a Linux dedicated host. This is personal preference and there is no negative to a Windows server and no specific reason to pick Linux. This guide, however, will be written only for people with a Linux box. If you don't have a Linux box, you can stop reading now.

    Now, when picking a server many people are always concerned about their RAM. I've read in many places that you need about 1GB of RAM for every 10-20 slots on your server. This is a pretty good estimate to go by, but you have to remember that RAM is not the only thing that you need to worry about. You need to make sure your HDD is big enough, you need to make sure your processor is good enough, your internet speeds are fast enough, and more.

    When I was running a server I had a very nice box: i7 3770 4 Core @ 3.4 Ghz, 32 GB RAM, 64 GB SSD, 32GB HDD.

    That is more than enough to run a server with 200+ people on. Take that into consideration when renting a box. A good host you may want to look into would be Choopa. I would recommend that you research other hosts before you decide on one to use. I have supplied a list of hosts at the end of this guide.

    I recommend getting a box with 16GB of RAM, 16 - 32GB HDD, and 16GB SSD. There are so many processors that any you get offered will most likely get the job done. These numbers are highballing it and you don't exactly need that much. If you're on a budget, you can go less. I would only recommend these numbers so you have some working space.

    Setting Up Your Server
    Now that you have your box you may be wondering how to start it. You don't have the ability to open up your Windows Explorer and run the run.bat file you got off Bukkit's wiki. Sadly, it is a bit more complicated than that. First upload your craftbukkit file to your server. I normally used the directory /home/SERVERNAME.

    Then, create a file called start.sh.

    You should put this code on that page:
    DO NOT COPY THIS CODE EXACTLY
    Code:
    java  -server -Xms10G -Xmx16G -jar craftbukkit.jar


    Every box is different, so you're going to need to change the amount of allocated RAM that you will provide to your server. Above, we are giving the server 10GB of extended memory and 16GB for the maximum heap size. DO NOT ALLOCATE ALL OF YOUR RAM. If you have an 8GB box, you should give it -Xms4G and -Xmx6G, if you have a 16GB box you should give it -Xms8G and -Xmx12G. Play around with the numbers, make sure you have at least 2GB not allocated, and keep Xmx bigger than Xms. Other things are going to be running on your box besides the Minecraft server, so leave some extra space. There are a bunch of other options that you can add depending on how you want your processor to handle the server and what not. That isn't important but you can do some research if you need things changed.

    Upload this start.sh into the /home/SERVERNAME. You can do this with Filezilla, I'm assuming that if you're setting up a server you know how to use Filezilla (or any other FTP client) so I am not going to get into detail about that.

    Now, how do I run that script? Well, let me explain. I'm going to teach you how to use PuTTy. The reason I am using this method is because it is much easier than teaching you how to connect through a terminal. PuTTY is perfect for anything you'll want to do on your server box.

    Download PuTTy here: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

    Open PuTTy and enter the hostname, lets use 108.61.45.74 as an example IP. You will want to use the IP of your Minecraft server. If you don't know what it is you could get it by logging into your account on the server host's website or by contacting your serverhost. If you use a URL to access your Minecraft server you can enter that URL instead.

    Next, you need to enter in the port. If you haven't changed the port it should be port 22. Then you want to click the option "SSH" .. Note, this is NOT the port of your Minecraft server. It is the SSH port.
    [​IMG]

    After that, you want to open the connection. Click "Open"

    When you do that, you will be prompted to login. Your login name should be root if you weren't told otherwise. You can contact your host if you don't know what it is. After typing root press enter. Then enter the password which you should also have gotten from your host. Then click enter. Your password will not show up as you type it.
    [​IMG]

    Now you want to make sure you have certain things installed on your box. You will need a bunch of things like: Java, MySQL, htop, and iptraf. I will explain how to do this in this guide.

    Installing Programs
    Here is command line for installing every program you will need. You need to remember that not all Linux boxes use the same format. These commands are for a CentOS box. I realize that most people use Ubuntu (and now I do) but at the time I wrote this I was running CentOS. The commands for installing is not much different. If you are using CentOS you can use the command line I have below. If you are using Ubuntu then you can use the “apt-get” command. I would suggest researching your distribution for the proper commands.

    First enter the following command to make sure you can use the rpm extension:
    Code:
    yum install rpm

    If you're running 32bit you'll need to find the RPMs on your own. The iptraf and htop links I have provided are for 64bit boxes.

    iptraf:
    Code:
    yum install http://scriptmantra.info/sources/iptraf-3.0.0-5.el5.x86_64.rpm

    htop:
    Code:
    yum install http://205.196.123.160/j785fw1gc80g/al1aaacqodltr1i/Htopbuild0056.yashua.rf.x86_64.rpm

    For installing MySQL and Java you can get those guides with a quick Google search, so I'm not going to waste time rewriting them.

    JAVA: http://www.wikihow.com/Install-Java-on-Linux
    MYSQL: http://www.thegeekstuff.com/2008/07/howto-install-mysql-on-linux/

    Starting MySQL
    To start MySQL you want to enter the following command line:
    Code:
    /etc/init.d/mysqld start


    Turning the Server on
    Well now I assume you're ready to turn this baby on and start installing plugins. In order to do this you need to open a "screen" (instance). However, screen does not come preinstalled and you will need to install it. Type:
    Code:
    yum install screen

    If the above command doesn't work, follow the next step. If you got it installed, move on to opening a screen.

    Go to this link and find the version for your distribution. Then, enter the following two lines into your terminal:

    Code:
    yum -y install ncurses-devel texinfo pam-devel libtool
    yum install URL_TO_RPM
    Screen is now installed installed.

    To open a screen you will need to type the following into the command line
    Code:
    screen -S SERVERNAME

    Obviously, replace servername with the name of your server. When you run your screen you will want it to be the same name. This is just so you can easily remember which server is running on each instance. Once you do this a page should open up like this. I'm going to call my screen "WARCHICKEN" for now.
    [​IMG]

    Now, you are on the screen. You want to now run your start script. You first have to open the file that it is in.

    You type:
    Code:
    cd /home/SERVERNAME

    Since that is the path we decided to use earlier in this guide.
    [​IMG]
    Now you want to type:
    Code:
    ./start.sh

    This will start your server. If you get the following message:
    [​IMG]

    It means you did not chmod your start.sh file to 770. Please do so using the following command:


    Code:
    chmod 770 /home/SERVERNAME/start.sh
    After the server is on, you can use this screen to enter commands as the server. When you want to detach you hold CTRL+A+D and it will detach you.

    If you want to reconnect you can type
    Code:
    screen -r WARCHICKEN
    screen -rd WARCHICKEN
    -r is to connect
    -rd is to connect and kick anyone else who is attached off. Only one person can view a screen at a time

    You can also do
    Code:
    screen -list

    to list all the open screens. If you need to kill a screen you type:
    Code:
    kill -9 <PID>

    The PID is the number to the left of the screen name.
    [​IMG]

    This number will be different every time you reopen a screen. If your server crashes, you need to kill the screen and then reopen it. If you kill a screen you will want to remove it from the list of screens by doing
    Code:
    screen -wipe

    [​IMG]
     
    Jozeth, jacklin213, Wizehh and 5 others like this.
  2. Offline

    Iaccidentally

    Looks like a fairly well written and comprehensive guide, good work! :)
     
  3. Offline

    lDucks

    Thank you! Spent a lot of time on it.
     
    MasterNiitro and Wizehh like this.
  4. Offline

    Pendar2

    This guide is awesome and very helpful. This would have saved me a lot of time if I used it to set up my server. It is ironic that I did all of that about a month ago. Good work.
     
  5. Offline

    LaxWasHere

    Nice, this is indeed very helpful. Though think you should provide a list of "VPS" and "dedi" host.
     
  6. Offline

    lDucks

    I just added it above the FAQs
     
    Wizehh likes this.
  7. Offline

    alkarin

    Just want to say excellent work on this! This is the most detailed guide I've seen about setting up a server. Since you already go into detail about starting though you might want to add a small section about the plugins folder.

    Also there is a folder called "update" that can be created inside of the plugins directory for jars that have updated that you can't move inside while the server is running.
     
  8. Offline

    lDucks

    I wasn't really planning on getting too detailed with plugins, however I do plan to add how to properly update plugins and craftbukkit.. and a few other things that would be nice to add. Its long enough as is, though ;P
     
    Wizehh likes this.
  9. Offline

    alkarin

    Just thought of another small section.

    Dealing with Lag (aka Profiling).
    Inside of the bukkit.yml you can toggle this.

    settings.plugin-profiling: true
     
  10. Offline

    LaxWasHere

    Shouldn't WinSCP be the prefered (s)FTP client?
     
  11. Offline

    LiLChris

    Nice guide, something you should probably add would be a way to monitor I/O.
     
  12. Offline

    lDucks

    I already have that ... iptraf

    Also, I added plugin profiling to the guide.
     
  13. Offline

    Sheepii

    This should be stickied.
     
  14. Offline

    lDucks

    I prefer Filezilla.
     
    Wizehh and kahlilnc like this.
  15. Offline

    Sheepii

    Just a heads up, Screen isn't integrated unless you install it. You might want to add that to your tutorial.
    The module:
    Code:
    yum install screen
    
    The dependencies:
    Code:
    yum -y install ncurses-devel texinfo pam-devel libtool
    
     
  16. Offline

    lDucks

    Added it, thanks for reminding me:

     
  17. Offline

    Sheepii

    Not exactly sure, but I'm pretty sure you need to install rpm aswell. I just used yum install rpm and then the extensions worked but, I'm not too sure about this. Atleast on my CentOS most console commands that are needed didn't work. You should put a recommended module list, atleast for basic navigation.

    http://www.wikihow.com/Install-Java-on-Linux this is for Ubuntu Distro. Also, I've heard it's more proficient to run Java Sun for Minecraft instead of JDK but not entirely sure how accurate that claim is.
     
  18. Offline

    lDucks

    Every box I've ever used had rpm installed...
     
  19. Offline

    kahlilnc

  20. Offline

    Sheepii

    Probably pre-setup boxes. If you're buying a server box that's not specifically for Minecraft or anything in particular, (self-maintained), it shouldn't have anything on it. I had a completely clean box with no rpm and just CentOS 6.4 x86_64.
     
  21. Offline

    lDucks

    You don't need to install it.. o.0

    However, I just found out that "yum install" works for RPMs and it finds the dependencies for you. http://linux.byexamples.com/archives/521/install-rpm-with-yum/
     
  22. Offline

    Sheepii

    It's just my distro didn't have rpm. Well, anyways. Great tutorial.

    yum install just updates the distro right?
     
  23. Offline

    lDucks

    Added website hosts to the list.
     
  24. Offline

    zack6849

    You may also want to add OVH and Kimsufi
     
  25. Offline

    lDucks

    I've added it
     
  26. Offline

    Jatoc

    lDucks

    You made a mistake in the screen parameter. Your screenshot is correct, but in the code you don't have -s capitalized.
     
  27. Offline

    lDucks

    Thank you, it's been fixed, good sir.
     
  28. Offline

    jtdemille

    lDucks

    This is the perfect guide for when I switch over to hosting a MC Server net. I am looking for a CUSTOM dedicated server so that I can achieve either 960GB RAM or 1TB RAM.
     
  29. Offline

    Gahhruuba

    This is a very nice guide lDucks , You should include a way to install it on a RAMdisk!

    Also, honestly, I think deserves a sticky somewhere on this site!
     
  30. Offline

    lDucks

    You do not, for any reason, need anything close to 960GB of RAM, or 1TB for that matter. You're not running a server for every human on this planet to play Minecraft, and you will not find a hosting company selling RAM in those quantities.
    Ahh yes, RAMdisk.. I'll add that in when I'm less busy.
     
Thread Status:
Not open for further replies.

Share This Page