Showing posts with label Minecraft. Show all posts
Showing posts with label Minecraft. Show all posts

Friday, 6 June 2014

Adding a Second Minecraft Server in Linux

Introduction

We've been using the linux startup script from the minecraft wiki for some time now and generally it works a treat, but recently I've wanted to set up a second service for my two younger sons to play on, away from the highly modified worlds that my oldest son had set up. The script can't cope with two services running at the same time, but with a few tweaks you can run as many as you like. The following instructions create a new game server called Pinga using a service called kidcraft.

Creating the New Minecraft Installation

I wanted it use vanilla Minecraft version 1.5.2, which was the very first version that we tried, but it should work for any version including craftbukkit, or any other modded versions.

1. Make a copy of your existing Minecraft installation.

cp -Rv /opt/minecraft /opt/kidcraft

2. Remove the old world directories (in my case the world was called 'Plop')

rm -R Plop

3. Edit your server.properties file and change the following settings:-
   - server-port : 25566 (the default is 25565 so pick a number that isn't being used)
   -server-name : Pinga (enter your new server name)
   - level-name : Pinga (will be used to name your new world)
   - gamemode : 1 (Creative - my kids don't want to play survival, you can leave this as 0)

Also make sure the other settings are set back if altered from standard.

4. Empty the Ops, Banned-ip, Banned-players and White-list files or delete them (they'll get recreated when you start the server).

5. Start the server up and allow it to create a new world.

6. Check you can connect to it in the game using the Multiplayer option.

7. Close down the server.

Create a New Backup Folder

If you use the backup option then you want to specify a new location for the files so they don't get mixed in with your existing backups. Mine were going into the /DailyBackup/Minecraft folder.

8. Go to your backup folder and create a new sub-directory

cd /DailyBackup
mkdir kidcraft

Modifying the Startup Script

The startup script uses the 'screen' utility as the control mechanism, and this also allows you to access the console if required. You will need to make some changes to the new script so that the commands connect to the correct service.

 9. Copy the startup script

cp /etc/init.d/minecraft /etc/init.d/kidcraft

10. Ensure it can be executed

chmod 755 /etc/init.d/kidcraft

11. Edit the new startup script and modify the following:-
   - WORLD : 'Pinga'
   - MCPATH : '/opt/kidcraft'
   - BACKUPPATH : '/DailyBackup/kidcraft'

12. Then alter the startup line in the mc_start() function

as_user "cd $MCPATH && screen -h $HISTORY -dmS kidcraft $INVOCATION"

13. Repeat stage 12 for the following functions:-
   - mc_saveoff()
   - mc_saveon()
   - mc_stop()
   - mc_command()

14. Save and exit the file.

You should be able to start and stop the new service using this new script in the normal way.

eg. /etc/init.d/kidcraft start

You can also access the console using the following command.

screen -r -S kidcraft

(Nb. use Ctrl + A D to exit)

One more thing..

Nearly forgot,.. if you want to make this server available over the web, don't forget to set up another port forwarding service on your router.

Update

An improved method can be found here http://theperfectbeast.blogspot.co.uk/p/linux-minecraft-server-script.html

Tuesday, 3 June 2014

Minecraft 1.5.2 on Snow Leopard


The Trials of Old Kit

I've pretty much given up trying to get Minecraft running on my old PowerPC Mac Mini (and I don't think I'm alone in that), so I dug out my black Macbook from around 2009. My original problem had been that Apple and Oracle had given up on the PPC processor so OSX was stuck at Leopard and Java with Apples version of 1.5, so I assumed the Macbook with it's intel Core Duo CPU would be easy.

Seems I was wrong again!

Its all about the Java

After installing the Minecraft launcher I initially found it crashed after trying to start the game (just like before). I managed to find a Java update that had been recompiled to NOT stop when it found an old version of the OSX.

With this I was able to get Minecraft working, but only on version 1.6.1 or higher. But my server is 1.5.2 and upgrading wasn't an option. I have a friend who's kids play on an old PC that doesn't like any version later than this because of video driver issues.

Once again, after lots of googling I was unable to find a solution to the problem, it seems that the launcher was broken some time after v1.5.2 and thus later versions just won't work on Snow Leopard.

Shoot the Snow Leopard

I'd always held off upgrading to Lion because it meant losing Rosetta and I'd actually quite liked Snow Leopard. I saw it as a better, more 'sorted' version of Leopard, but as this laptop just wasn't being used anymore I didnt have anything to lose. The upgrade went smoothly and was followed by a 2Gb system update.

After this I started up Minecraft and it just worked (wow) albeit running slightly warm. I then spent a little time tinkering with the video settings in the game to get it running smoothly (turning on advanced OpenGL, setting the Graphics to 'Fancy' and turning off clouds). Everything was running great until I turned off full screen mode to see if it would run cooler. Then it crashed in disgust, refusing to restart.

It took a little trial and error to work out how to fix it, but here's all you need to do:-
  • Set your launcher to use the latest version of the game.
  • Launch the game and then go into the video settings.
  • Switch back to fullscreen mode
  • End the game
  • Switch back to 1.5.2 and relaunch.
Simple enough to fix. I suspect there's some sort of backwards incompatibility with the video drivers and earlier versions of Minecraft. In my experience the world of Java is full of version issues and gotchas. But this is the price you pay for cross platform compatibility.

For a simple looking blocky game it sure does make my laptop run hot.

Wednesday, 11 December 2013

Minecraft Backup for MultiWorld servers

Basic Server Backup

One of the main reasons we built our new Linux server was to be able to run a simple Minecraft server, but as time's gone by we've moved to a more sophisticated configuration. We started out by switching from vanilla Minecraft to (plug-in friendly) CraftBukkit and from there we've experimented with various plug-ins that improved security or added enhancements to the game.

We've always used the linux startup script from the minecraft wiki and this gives us the added benefit of easy world backups without having to shut the service down. Backups are triggered from an entry in the crontab as below.

10 23 * * * /etc/init.d/minecraft backup

Here the backup option is triggered at 23:10 every day and generates the following entries in the minecraft server log.

2013-12-01 23:10:01 [INFO] [Server ] SERVER BACKUP STARTING. Server going readonly...
2013-12-01 23:10:01 [INFO] CONSOLE: Disabled level saving..
2013-12-01 23:10:01 [INFO] CONSOLE: Forcing save..
2013-12-01 23:10:03 [INFO] CONSOLE: Save complete.
2013-12-01 23:10:19 [INFO] CONSOLE: Enabled level saving..
2013-12-01 23:10:19 [INFO] [Server ] SERVER BACKUP ENDED. Server going read-write...  

MultiSite Backup

It wasn't long before we had the Multi-World plug-in installed and a dozen new Worlds linked in. My son built a linking portal with teleports to all of the new worlds and it was great, but it became apparent that these weren't being backed up by the startup script.

Mojang's script covers just the main world which is defined in the #Settings section at the top of the file. (see example below)

#Settings
SERVICE='craftbukkit.jar'
OPTIONS='nogui'
USERNAME='root'
WORLD='Plop'

OTHERWORLDS='creative hungergames spawn griefcity'
MCPATH='/opt/minecraft'
BACKUPPATH='/TimeMachine/DailyBackup/minecraft'
MAXHEAP=2048
MINHEAP=1024
HISTORY=1024
CPU_COUNT=1

I added a new variable called 'OTHERWORLDS' and I populated it with a list of the worlds currently being missed. (Note: these are separated by a space character so make sure the worlds don't include spaces in their names)

Next I altered the backup section of the script to loop through the OTHERWORLDS list and add each world directory to the backup tar file. (see script below)

mc_backup() {
mc_saveoff
NOW=`date "+%Y-%m-%d_%Hh%M"`
BACKUP_FILE="$BACKUPPATH/${WORLD}_${NOW}.tar"
echo "Backing up minecraft world…"
#as_user "cd $MCPATH && cp -r $WORLD $BACKUPPATH/${WORLD}_`date "+%Y.%m.%d_%H.%M"`" as_user "tar -C \"$MCPATH\" -cf \"$BACKUP_FILE\" $WORLD"

  for i in $OTHERWORLDS
  do
    as_user "tar -C \"$MCPATH\" -rf \"$BACKUP_FILE\" $i"
  done

echo "Backing up $SERVICE"
as_user "tar -C \"$MCPATH\" -rf \"$BACKUP_FILE\" $SERVICE"
#as_user "cp \"$MCPATH/$SERVICE\" \"$BACKUPPATH/minecraft_server_${NOW}.jar\""

mc_saveon

echo "Compressing backup..."
as_user "gzip -f \"$BACKUP_FILE\""
echo "Done."
}

Now when the backup runs the main world is backed up to a daily tar file and then the other worlds are added to it. (It will create a TAR file named after your main world and a timestamp)

Possible Updates

The only real problem with this script is that is doesn't cater for world names containing spaces. This was initially an issue that I struggled to fix, and in the end I took the easy option and altered the world name to remove the offending character.

But as is often the case the script is good enough, so I have no plans to fix it.

Update

An improved method can be found here http://theperfectbeast.blogspot.co.uk/p/linux-minecraft-server-script.html

Monday, 14 October 2013

Minecraft Server Log Web Interface

Introduction

If you run a Minecraft server in Linux then you'll probably like to keep track of what's going on in the server log. I found that it was a real pain having to remote shell into the server all the time and if it was available via a web browser I could keep track of it more conveniently, or by using my phone or tablet.

I decided that I would use PHP (even though PERL is generally my scripting weapon of choice) and once I'd found the correct commands and syntax it came together quite quickly. If you fancy giving it a try you just need a web server (such as Apache) and of course PHP running on your server.

How it works

It started out being a simple process of opening the server.log file and outputting each line as pre-formatted html.

Something like this..

<html>
<head><title>Minecraft Log</title></head>
<body><pre>
<?php
$filepath = "/opt/minecraft/server.log";
$file = file($filepath);
foreach($file as $line) {
    echo $line."<br/>\n";
}
?>
</pre></body>
</html>

This was great at first, but after we'd been running for a few weeks the server.log file gets too big and the web page gets slower and slower to load. What we needed was a way of only showing the current days log entries, and maybe a date selector so you can reference older stuff.

So I created version two with the following enhancements:-
  • Default to showing today's log entries.
  • A date selector is added to the top of the web page which sends the new value if altered.
  • If page requested with a date parameter then use this instead of today's date.
  • If no date has been passed then run a javascript function to scroll the log section to the bottom.
There's a nice feature in the log where text is coloured. This would typically be for chat or system warnings, but as it stood they left messy control codes littered about the log. Rather than remove these I decided to replace them and style the text to match these colours.

This enhancement required the following:-
  • Create a series of regular expression replaces to match the control codes.
  • Each colour code instance is replaced by a span tag which corresponds to a set of pre-defined styles (the css for these is defined in the head section).
  • Put log into a scrollable div.
Here's the completed code..

<!DOCTYPE html>
<html>
<head>
<title>Minecraft Log</title>
<style>
    #log{
        height:400px;
        overflow-y: scroll;
        margin: 5px 0 0 1px;
        border: 1px solid;
    }
    .green{color: green;}
    .red{color: red;}
    .purple{color: purple;}
    .black{color: black;}
    .blue{color: darkblue;}
    .gold{color: gold;}
    .cyan{color: darkcyan;}
    .aqua{color: cadetblue;}
    .gray{color: #888;}
    .bold{ font-weight:bold;}
</style>
<script>
    function scroll(){
    //scroll div to bottom
    var objDiv = document.getElementById("log");
    objDiv.scrollTop = objDiv.scrollHeight;
    }
</script>
</head>
<?php
$pass = htmlspecialchars($_POST["date"]);
if (!$pass){
    echo "<body onLoad='scroll()'>";
}
else {
    echo "<body>";
}

$filepath = "/opt/minecraft/server.log";
$file = file($filepath);
$dates = array();
$last = "";


/* Get List Of Dates */
foreach($file as $line) {
    $date = substr($line, 0, 10);
    if ($date != $last){
        if(preg_match('/\d{4}\-\d{2}\-\d{2}/',$date)) {
            array_push($dates, substr($line, 0, 10));
            $last = $date;
        }
    }
}

/* If Date Provided Use This */
if(preg_match('/\d{4}\-\d{2}\-\d{2}/',$pass)) {
    $last = $pass;
}

/* Add Form Element and Date Selector */
echo "<form method='post'>Select date: <select name='date' onchange='this.form.submit()'>\n";
foreach($dates as $value){
    $select = "";
    if ($value == $last){ $select = " selected='selected'"; }
    echo "<option value='".$value."'".$select.">".$value."</option>\n";
}
echo "</select></form>\n";

/* Output Log For Required Date */
echo "<div id='log'>";
foreach($file as $line) {
    /* Remap Problem Characters */
    $line = preg_replace("/</","&lt;",$line);
    $line = preg_replace("/>/","</span>&gt;",$line);
    $date = substr($line, 0, 10);
    if ($date == $last) {
        /* Remove Unrequired Formatting Codes */
        $line = str_replace("[m","",$line);
        $line = str_replace("[21m","",$line);
        $line = str_replace("[3m","",$line);
        /* Split Log Line Into Sections to Using First Formatting Code Style */
        $segarray = preg_split( '/(\[0|\[m)/', $line );
        for ($i = 1; $i < count($segarray); ++$i){
            /* Do Replace to Add Styled Spans */
            if (preg_match('/;\d{2};\d+m/', $segarray[$i])) {
                $segarray[$i] = preg_replace("/;30/","<span class='black",$segarray[$i]);
                $segarray[$i] = preg_replace("/;31/","<span class='red",$segarray[$i]);
                $segarray[$i] = preg_replace("/;32/","<span class='green",$segarray[$i]);
                $segarray[$i] = preg_replace("/;33/","<span class='gold",$segarray[$i]);
                $segarray[$i] = preg_replace("/;34/","<span class='blue",$segarray[$i]);
            $segarray[$i] = preg_replace("/;35/","<span class='purple",$segarray[$i]);
                $segarray[$i] = preg_replace("/;36/","<span class='aqua",$segarray[$i]);
                $segarray[$i] = preg_replace("/;37/","<span class='gray",$segarray[$i]);
                $segarray[$i] = preg_replace("/;22m/","'>",$segarray[$i]);
                $segarray[$i] = preg_replace("/;1m/"," bold'>",$segarray[$i]);
                $segarray[$i] = $segarray[$i]."</span>";
            }
        }
        /* Rejoin Then Split Log Line Using Second Formatting Code Style */
        $line = join("",$segarray);
        $segarray = preg_split( '/§/', $line );
        for ($i = 1; $i < count($segarray); ++$i){
            /* Do Replace to Add Styled Spans */
            $segarray[$i] = preg_replace("/^0/","<span class='black'>",$segarray[$i]);
            $segarray[$i] = preg_replace("/^1/","<span class='blue'>",$segarray[$i]);
            $segarray[$i] = preg_replace("/^2/","<span class='green'>",$segarray[$i]);
            $segarray[$i] = preg_replace("/^3/","<span class='aqua'>",$segarray[$i]);
            $segarray[$i] = preg_replace("/^4/","<span class='red'>",$segarray[$i]);
            $segarray[$i] = preg_replace("/^5/","<span class='purple'>",$segarray[$i]);
            $segarray[$i] = preg_replace("/^6/","<span class='gold'>",$segarray[$i]);
            $segarray[$i] = preg_replace("/^7/","<span class='gray'>",$segarray[$i]);
            $segarray[$i] = preg_replace("/^8/","<span class='gray'>",$segarray[$i]);
            $segarray[$i] = preg_replace("/^9/","<span class='blue'>",$segarray[$i]);
            $segarray[$i] = preg_replace("/^a/","<span class='green'>",$segarray[$i]);
            $segarray[$i] = preg_replace("/^b/","<span class='aqua'>",$segarray[$i]);
            $segarray[$i] = preg_replace("/^c/","<span class='red'>",$segarray[$i]);
            $segarray[$i] = preg_replace("/^d/","<span class='purple'>",$segarray[$i]);
            $segarray[$i] = preg_replace("/^e/","<span class='gold'>",$segarray[$i]);
            $segarray[$i] = preg_replace("/^f/","<span class='black'>",$segarray[$i]);
            $segarray[$i] = preg_replace("/^r/","<span class='black'>",$segarray[$i]);
            $segarray[$i] = $segarray[$i]."</span>";
        }
        /* Rejoin and Output to Webpage */
        $line = join("",$segarray);
        echo $line."<br/>\n";
    }
}

echo "</div>";
?>
</body>
</html>

nb. Notice the log must now be read twice!

Installation Instructions

Copy the code into a file called index.php and drop it into a directory accessible to your web server and ensure you grant the file execution rights.

Alter the $filepath = "/opt/minecraft/server.log"; line so that it points to your server log and ensure the web server has read rights to this file.

How to Use

Just open the PHP code in your browser and the a page should open showing today's log entries, scrolled to the bottom of the log.

If you then select an earlier date the page will refresh and show this dates entries without the auto-scrolling.

Monday, 19 August 2013

PermissionsEx: Anti-griefing methods for Minecraft

More Grief

If you've already installed and configured Grey Lists using PermissionsEx (as described in my earlier post) then you are well aware of the protection this provides against those pesky griefers. Yeah I know you can white-list your server but this helps you want to showcase your work without risk.

My son can be a little too trusting, and far too keen to attract new builders, and it always seems to be when we have friends of friends connected that trouble starts brewing. A few days ago the inevitable happened, a school pal and his friend paired up for an orgy of TNT abuse, dropping as many buildings as they could in full view of the regular builders. The server was downed soon as he figured out what was happening and the permissions.yml file altered to remove the offenders building rights, but ultimately damage had been done. One of the longest standing buildings was hit so hard that it was reduced to a crater, all in about a minutes chaos!

PermissionsEx Revisited

All the griefing we've experienced so far has been the result of fire or TNT, with the latter obliterating buildings well beyond repair. It made sense after this attack to limit their use, removing them from the standard 'builder' groups rights, but after well over an hour of altering permissions and testing we had only managed to remove the rights to place TNT. It's really a case of trying different modifyworld  restriction in the permissions.yml file until you get a result.

The first thing to be aware of is the order of the permission lines is important. The file is scanned top to bottom and as soon as a match is found it stops. This means restrictions must go before grants using wildcards or they'll never be reached.

Builder:
      prefix: '&0(&8Builder&0)&7 '
      permissions:
      - -modifyworld.blocks.place.46
      - -modifyworld.bucket.empty.10
      - -modifyworld.bucket.fill.10
      - -modifyworld.items.pickup.259
      - -modifyworld.items.craft.259
      - -modifyworld.items.use.259.on.block.*
      - -modifyworld.items.use.259
      - modifyworld.*
      options:
          rank: '900'

nb. Our restrictions go before modifyworld.* and use the '-' minus symbol to differentiate them from grants. The objects are listed by item/block id (46 = tnt, 10 = lava, 259 = flint and steel)

Now when TNT (46) is placed by a builder the block gets picked straight back up again, similarly the restrictions on flint and steel (259) don't allow you to pick it up or use it. The lava bucket (327) lines need to restrict filling and emptying of a liquid, in this case lava.

You will also need to enable some options in the modifyworld.yml before this works.

item-restrictions: true
use-material-names: false
drop-restricted-item: true
item-use-check: true

I set use-material-names to false so that I could use item and block numbers, but you can leave this set to 'true' and use proper names. Then your restriction would read as per the example below:-

   - -modifyworld.blocks.place.TNT

Don't mix the two up or your permissions won't work. Also be aware that the plugins are very sensitive to formatting errors, so check your server log after changing and if necessary run your config through a YAML file validator.

In the mean time I'll work on the fire problem & if anyone has any suggestions then please comment.

Sunday, 4 August 2013

Minecraft Grey Lists

Anti-Griefing

A few weeks ago my son's Minecraft world became trashed (buildings completely obliterated) by friends of a friend who visited our server. Thankfully we had a backup to restore from and then to ensure it didn't happen again we turned on white lists in the server.properties file.

But the story doesn't end here... a few days ago number one son asked me if I knew anything about grey lists, informing me roughly what they're supposed to do. Apparently if you set up a grey list then it enables anyone to join the server but they're restricted from building. This was new to me and seems ideal, meaning he'd be able to pass about the server connection details freely without worrying about being griefed again.

Grey Lists

The vanilla server only supports black lists (to ban people) or white lists (to only allow access to those listed). There's no setting in the properties file to enable grey lists, so I googled until I found that a plugin called PermissionsEx. This enables you to define access groups with appropriate rights, and assign users to them.

But you can't add plugins to the vanilla version of Minecraft server,.. there's no plugin directory, instead you have to use the CraftBukkit server instead. (Click here for download page)

While I'm at it, here's the link for the PermissionsEx plugin. (Click here for download page)

Installing Bukkit & PermissionsEx

Here's the steps we went through:
  1. Edit your server.properties file and disable white-lists if you where using them.
  2. Download the craftbukkit jar file and copy it into your minecraft server directory.
  3. Run the craftbukkit server program to create the extra files and folders (it also converts your world files).
  4. Download the PermissionEx jar files and copy these into the newly created plugin directory.
  5. Restart the server again and a PermissionEx sub-directory will be created.
  6. Change to this directory but leave config.yml alone.
  7. Edit the permissions.yml file and replace the contents with the following lines, then add your users into the end section (in line with the examples).
groups:
    default:
        default: true
        options:
            rank: '1000'
        permissions:
        - modifyworld.chat
    Builder:
        prefix: '&0(&8Builder&0)&7 '
        permissions:
        - modifyworld.*
        options:
            rank: '900'
    Moderator:
        prefix: '&0(&1Moderator&0)&7 '
        permissions:
        - -modifyworld.mobtarget.*
        - modifyworld.*
        options:
            rank: '100'
    Admin:
        prefix: '&0(&4Admins&0)&7 '
        permissions:
        - -modifyworld.mobtarget.*
        - modifyworld.*
        - permissions.*
        options:
            rank: '1'
users:
    SomePlayerName:
        group:
        - Builder
    YourPlayerName:
        group:
        - Admin

NB. Ensure you don't add any spaces before 'groups' or 'users' or the file will be ignored.

We found that if your name is in the ops.txt file then you automatically get admin level.

Follow this link for further details on configuration and how to type /pex commands when in the game.

Finally I updated the /etc/init.d/minecraft startup script to use the CraftBukkit jar file.

Tuesday, 9 July 2013

Power Corrupts

Pleased to Meter

My plug-in electricity usage meter arrived from Maplin (N67FU). It cost just just a tenner and gives me the ability to see if my careful purchasing has actually delivered me an efficient server. You plug it into a mains outlet, and then the device to be measured connects to the three pin 13 amp socket in the front. It has a maximum power rating of just over 3Kw so it should be enough for an Intel i3 (laffs), and the flat-ish design means wall-warts shouldn't be a problem.



It works really well, and it's cheap as chips, but the niggle I've had with it is reading the LCD screen. Parts of the display are really tiny and my eyes aren't what they used to be. Plus mains power sockets tend to be in low, poorly lit places, making reading harder still. The only real issue has been the mode indicator, which is the smallest bit and block inverse. (Who dreamed that up?.. I can understand from a design point of view how you'd want to differentiate that a little, but they might as have well used Egyptian Hieroglyphs!)

Meter mode indicator shown top right.
Thankfully the screen layout changes enough so that you can work out which mode you're in, and it's mostly about that big number in the top left so I can get by without needing a flashlight and my reading glasses.

Measuring Up

The existing Pingu had to be shut down to install a replacement /home and /data drive. I use 2.5" laptop drives these days to keep check on the noise and heat, and this disk was the first one I'd bought after switching to the policy four years ago. Last week it started to fail big time, throwing numerous errors, making loose rattling noises and finally showing files with zero bytes size. I won't bore you with the gory details because I have regular backups, but it gave me the chance to plug in the power meter and see how much juice my trusty old server has been using all these years.

The Via system board is rated at 11 watts, there's an SSD, two laptop drives and a 2Tb desktop drive for my auto-backups, which is normally asleep. So after allowing for a power supply efficiency of 80%, I'd estimated about 25 watts in total, but found it actually used just under 27w. I'm pretty sure it's the disks that are dragging it up so high, but until I unplug them it's just an educated guess. But having the electricity meter means I can be a little more pragmatic about future disk purchases. Maybe one day SSD's will be big enough and cheap enough to fulfil my data storage requirements.

Next to be benchmarked was the new Intel i3 based machine. The bulk of the software, two database servers (Postgresql and mySQL), as well as Apache2 had already been installed but not configured. And as I blogged last time, Minecraft Server was ready to go. Turning on the machine it peaked for a few seconds at 20 watts and then dropped to a very reasonable 14.5 watts. It pretty much stayed at that value until I started the Minecraft service and then it went up by about ½ a watt. I measured CPU temperature by installing LM-Sensors and CPU utilisation was monitored using the Top utility.

With one player joining the game the power rose to about 15.5 watts and (by pressing 1 while running top) I was able to see that all four of the CPU cores had started to register light utilisation. (So I stand corrected, Minecraft Server does use multiple cores - thanks to Dr Vesuvius for that heads-up).

top - 18:47:19 up 1 day, 22:48,  1 user,  load average: 0.18, 0.12, 0.08
Tasks: 106 total,   2 running, 104 sleeping,   0 stopped,   0 zombie
%Cpu0  :  5.6 us,  0.7 sy,  0.0 ni, 93.4 id,  0.3 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  : 18.6 us,  1.0 sy,  0.0 ni, 80.4 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu2  :  3.3 us,  0.0 sy,  0.0 ni, 96.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu3  :  6.4 us,  0.3 sy,  0.0 ni, 93.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   8127440 total,  1199480 used,  6927960 free,    19984 buffers
KiB Swap:  3090420 total,        0 used,  3090420 free,   862192 cached

Some of this could be the other services running but without the Minecraft Server there's very little utilisation on the other cores.

With the case lid removed the CPU temperature drifted up to around 45 degrees centigrade and the fan still turned at it's original lazy rate. I gotta admit, that's better than I expected.

Tuesday, 18 June 2013

What to do about Pingu?

The Painful Truth

It comes with some degree of sadness that I resign to the fact that my current home based server is reaching the end of it's natural life. It's not about to crash any moment, nor is it problematic or unstable in it's operation,.. no, something's come along that's revolutionising it's use. And it's not the first hardware refresh either, but the VIA C7 based machine has been pretty consistent for about six years now, having only software upgrades and additional disks thrown at it.

Pingu (my debian based server) originally started out as a way of adding network shares to my computers back in 2001. It was a simple affair, thrown together from cheap parts and a case so thin that I routinely cut my fingers when ever I 'lifted the bonnet'. A few years later I replaced the whole lot with a Mini-ITX machine and it has evolved along those lines ever since. Additionally Pingu has been a test bed and learning environment for me, and ultimately became the platform for iShare, my photo sharing portal (written in perl). These days Pingu does loads of useful things (web server, torrent downloader, media streamer, caldav server, network shares, timemachine store, dns alias updating, dns masquerading, web proxy and adzapping), but then my kids got old enough to start making demands of it.

Ultimately they're the revolution, and the technical impact that they bring is called Minecraft.

The Minecraft Hammer

It was easy to do, you just install the Java 7 runtime engine, download the server jar file from minecraft.net and run it. It then goes about creating all of the additional files it needs along with a barrage of messages and errors. Knowing the humble C7 to be under-powered for this use and the system low on memory I splashed out a tenner and installed a 1Gb SODIMM (maxing out the motherboards capability). I added a bigger swap file and after a little config tweaking we had a running Minecraft server. The console was throwing up loads of "Can't keep up! Did the system time change" errors, but it wasn't affecting the gameplay so my son was happy. (well,.. as happy as a teenager can be!)

Using the 'top' utility I monitored the impact on the server with just one player in the game. It hovered between 65% and 75% cpu usage while memory use was modest. It was about now that my wife started to mention that the web access and our photo hosting was much slower.

A few days later we had two players on the server, so once again I ran the 'top' utility noticing that the memory usage was still pretty low, but the cpu was consistently in the mid to high 90s. During this time none of the other services were responding enough to be usable, web was painfully slow and in the end we gave up our web browsing and facebooking and watched TV.

After a few days of this I decided we needed a new Pingu.