BaerConsulting LLC Blog

Server Configuration

Network Media Player/Server How To

by BaerConsultLLC on Jan.13, 2010, under How To's, Server Configuration

Ok, so let’s start with the requirements.

First, you’ll need a physical machine or anything running Windows, Mac, or Ubuntu. It can even be a virtual machine! For all intensive purposes, we’ll go with Ubuntu since it’s free and downloadable. Second, you’ll need a Network Interface Card (NIC) for that machine. I recommend going with Intel Gigabit Pro GT/1000 cards. They’re a bit more expensive, but it’s all we use here at BaerConsulting and we’ve yet to have one fail on us. Even if you don’t run a gigabit network, I still recommend Intel Gigabit cards. Third, you’ll need something to play these media files on. At home, I have a D-Link DSM-520, a Buffalo Media Player, an XBox 360, and a Playstation 3. Out of these media players, a Playstation 3 seems to produce the best quality and is most compatible with codec types. Codecs are something that transcodes, recodes, or encodes a media file using it’s respective format, be it MP3, MP4, WMV, AVI, etc. Lastly, you’ll need some sort of network set up with the network media player and the server on that network. This will not work over the internet.

If you haven’t already started downloading Ubuntu, head on over to Ubuntu’s Home Page to download a copy. There are a variety of types and variety of ways to download Ubuntu. If you have a machine that’s a Core 2 Duo, Quad Core, Pentium Dual Core, or anything else that’s been made in the last 3-4 years, it’s probably a 64-bit processor, thus you’ll probably want to go with 64-bit Ubuntu Desktop. There are a lot of debates going on about the true advantage of 64-bit over 32-bit, but that’s a blog for a different day. If you have an older machine, such as a Pentium 4 or an Athlon XP, you’ll want to get the 32-bit version. Why Desktop you ask? Well it’s simple. First, I assume that you’re probably not proficient in Linux, and while some might argue that the best way to learn it is to jump in to server (no GUI, just command prompt), I figure I’ll be kind and give you something familiar. Next you get to search for ways to download this file. HTTP is the norm, but if you’re in to Torrenting and have a client, I suggest using that. It’s less strenuous on the Ubuntu servers and mirrors, plus, you’ll probably get the file faster.

Now you need a program to burn the ISO file. My personal favourite is MagicISO, but Roxio or Nero work just the same. Burn that file to a CD. If you got desktop, you’ll notice it’s a Live CD. This means that you can literally run the operating system off of the disc without it ever erasing files or touching the hard drive at all. It is the strong recommendation of BaerConsulting that you use a spare hard drive or one that contains no data that is valuable. If you don’t know what you’re doing, it’s probably best you don’t do it. Now, with that out of the way, and you being sure that you have a hard drive that you don’t mind wiping, let’s install Ubuntu.

Pop in the CD to your computer and boot it up. Select ‘Try Ubuntu without ant change to your computer’. Once it is booted up, you should be greeted with some peculiar sounds and a Desktop. Double click on ‘Install Ubuntu 9.10′. Select the appropriate language and click Forward. Select your appropriate Time Zone and click Forward. Select the appropriate keyboard layout and click Forward. On this screen you’ll see something similar to that of setting up Windows. This is where you partition your drive. For most users, using the default layout and simply clicking Forward will work best. WARNING: ONCE YOU CLICK FORWARD, ALL DATA ON YOUR DRIVE WILL BE LOST.. Pick you username, username again, type in your password, confirm it, and choose the name of this computer (otherwise known as hostname). Anything that autofills is probably safe. Once you’re sure about your settings, click Forward, then click Install. This can take up to 60 minutes depending on your system, so be patient. When it’s completely installed, go ahead and Restart Now. Take the disc out and close the tray, hit Enter as instructed by the splash screen.

When it boots back up, go ahead and log in based on the credentials you entered during the installation. Click on Applications>Accessories>Terminal. Type “sudo apt-get update”, hit enter, enter your password, hit enter. From here on, please assume that “hit enter” comes after every command. Once that’s completed, type “sudo apt-get upgrade”. When it prompts you, select yes. While it’s downloading updates, go back to Applications>Accessories and right click on Terminal. Click Add To Panel… This will put a shortcut icon on the top bar of your screen. This will give you quicker access to the terminal. It is the definitive administration tool under Linux. While the command is downloading and installing updates, go to System>Preferences>Remote Desktop. Click the “Allow other users to view your desktop” checkbox. Select the checkbox that says “Require the user to enter this password:” and enter a password. This will allow VNC remote access to this machine. This is where the hostname comes in handy, which you should see in the form of “username”@”hostname” in the terminal window at the beginning of the command prompt. Download Real, Tight, or Ultra VNC Viewer. That is quite simple, open it, enter the hostname, and click connect. If you’ve done everything right, you should be prompted for a password. Enter the password and you should now be seeing the Desktop of the Ubuntu machine. You can now put this machine in a remote location, provided the VNC connection worked, and remove the monitor, keyboard, mouse, etc. Just a network cable, a power cable, and of course, the machine itself.

After the update of Ubuntu, you should reboot and run those two commands again, just in case. We’re not dealing with Windows, so you’ll usually get all updates in one shot. Open up the terminal again. Enter “sudo apt-get install ssh”. This will install and SSH server so you can use an application like PUTTY for Windows to use the command line. If you’re proficient in command line, this will be very familiar to you.

Let’s open up terminal again, if it’s not already open. Type “sudo apt-get install mencoder ffmpeg mplayer vlc sun-java6-jre”. Note the spaces in between each application or package, as they’re referred to in Linux. Accept the license terms.

Go to PS3MediaServer.blogspot.com and download the newest Playstation Media Server. Choose to save to the Desktop. Right click and choose to extract here. There should be a new folder on the Desktop. Open up the terminal again and type “cd /home/[username]/Desktop/pm[tab]“. The tab key should autocomplete the folder as necessary. You should now be in the same folder as the files you just downloaded. Type “chmod +x PM[tab]“. Unlike Windows command line, Linux’s command line is case sensitive, so PM is not interpreted the same as pm. Then type “chmod +x linux/ts[tab]“. This makes the necessary files executable, just like a shortcut icon on the desktop of Windows.

With your mouse, go in to the folder that you just extracted to your Desktop. Double click on the PMS.sh file. If prompted, choose run in terminal. This should open up a new window. This is the main configuration console of the Playstation Media Server. This is where you can select the folders to be shared across the network. To add files to this server, you’ll need to set up Samba, which is a blog for another day. By default, the server shares all files and folders, which can be risky, but if you’re network is secure, it should be fine. Now that you have SSH set up, you could use Samba, or you could use WinSCP. For now, Google and download WinSCP. You’ll log in with the same username, password, and hostname that you entered during your initial setup of Ubuntu. Once logged in, you can see the layout of your local machine and the remote machine. Seeing as how Linux/Ubuntu is very secure operating system based mostly on permissions, you’ll want to put the files under /home/[username] on the Ubuntu machine. That will make them available to your media player. Also a note about permission; you’ll notice I used “sudo” quite a bit in the commands above. This stands for “superuserdo”. The superuser is the ultimate in permissions. It allows you to modify the system wherever you need to. Do NOT provide your password or any credentials to that machine to anyone you do not trust.

Why Playstation Media Server you ask? Because it plays mostly anything you like. As you can already guess, it is mostly compatible with the Playstation 3, but I have yet to meet anything that it will play on the Playstation 3 that you cannot play on the XBox 360 for example.

You now have a fully functional media server that can be detected by media players. You can also use this media server as anything else Ubuntu based that you like, such as a network grapher, network monitor, or a NAS. Again, you’ll probably want some extra storage on this machine. We’ll eventually post some instructions on setting up a NAS at a later time, but this should get you streaming your media files in the meantime.

Leave a Comment :, , , , , , , , , , more...

Nagios

by BaerConsultLLC on Aug.25, 2009, under News, Server Configuration

Oooo such a dirty word. In all actuality, Nagios is only intimidating. Once you find the right walkthrough and decide for or against compiling from source, you’re already through most of the battle. We decided that a free Windows based monitoring system that had device and probe limitations just wasn’t going to cut it anymore. Since we have a very beautiful 5TB total available storage NAS with a dual-core processor and 2GB of RAM sitting there just storing data, we figure we might as well use it for some monitoring. We went through Zabbix and determined that it was going to take longer to get it set up than most of the server would even be in production. Not to mention SNMP based monitoring of system resources can be a security risk as well as difficult to troubleshoot. Nagios has a very comprehensive support base out there. It has been customized and modified to do just about anything that is desired, so we opted for Nagios.

As previously stated, the NAS is a Ubuntu 9.04 desktop with the hardware specs above. Luckily, Nagios and most plugin packages are in the repositories, meaning that can be downloaded and install using your favorite package manager, on Ubuntu, by default, it’s apt. From there, it’s quite simple to figure out how to monitor things. We did print outs of all the commands that were available in the /etc/nagios-plugins directory with (while in /etc/nagios-plugins) ‘cat *.cfg > all.txt’. Marked each one that we’d like to use and started making our host .cfg files. Whenever you make a change to the Nagios configuration files (any of them), you have to restart Nagios for the change to take effect. This is where Nagios can get somewhat tedious. We highly recommend doing one host at a time. Do a few hosts one at a time, restarting after each one. When Nagios catches an error, it won’t restart successfully and it will usually tell you why. Go back in to the config file and make the necessary changes. Once you’ve mastered hosts, you should start adding services to the host files. You can do your file structure however you like. We used one .cfg file for the mail server, one for the web server, so on and so forth. This way, if you take that server out of production, you can just remove the file or move it to another file with another extension. Also, if something goes wrong, you’ll know exactly where to start looking.

Also, there is a Nagios ‘agent’ called NRPE that is used to monitor system resources on the local machine and sends them back to Nagios. The nice thing is that NRPE uses one single port and utilizes SSL so it’s pretty secure. Those commands are defined in the nrpe.cfg file. We have ours running under xinetd which means we can modify commands as much as we want without having to restart NRPE, although you will have to restart Nagios when you add your check_nrpe command. It’s basically a beefier version of SNMP. We’ve only had one hiccup where NRPE failed SSL handshakes for about an hour, but we believe it was due to an NTP misconfiguration. Time is very important when dealing with secure connections. Right now, we’re experimenting with adding some extensive Zimbra monitoring utilizing NRPE. We just altered some perl paths to get Nagios monitoring the postfix mail queue on the Zimbra server, letting us know whenever it reaches a certain point. This tells us that it is possible to do some very interesting things with Nagios. We’ll post the most interesting parts.

We have not and will not post anything pertaining to the actual set up of Nagios such as a walkthrough. Honestly, it took about 15-25 hours to get it successfully monitoring 52 different services, but that includes setting up NSClient++ (basically NRPE for Windows), NRPE on the Mail Server (CentOS) and the Web Server (Ubuntu), importing all publicly available and privately available services such as POP, SMTP, IMAP, HTTP, etc., public IP addresses, private IP addresses, and domains. We went through and used at least a dozen walkthroughs. At some point, we may set up an additional box just to do the walkthrough, but don’t hold your breath. Nagios documentation is pretty thorough. Google NRPE documentation in order to find the best document for the job. It’s posted by Nagios but couldn’t be readily found on the site. Nagios mailing lists are great resources when all else fails. Also, don’t forget your notification profiles. IT IS HIGHLY ADVISED THAT YOU USE THE ‘NEVER’ NOTIFICATION PROFILE OR CREATE ONE IF YOUR SPECIFIC INSTALL DOESN’T HAVE ONE ON EACH AND EVERY HOST/SERVICE UNTIL IT IS UP, RUNNING, AND STABLE. I’D SAY ONCE EVERYTHING IS GREEN, LET IT RUN FOR A WEEK, THEN YOU’LL KNOW YOU CAN TURN ON NOTIFICATIONS. OTHERWISE, YOUR INBOX WILL FILL QUICKLY WHILE YOU WORK OUT THE BUGS.

Leave a Comment :, , , , , , , , , , , , more...

The resurrected NAS is in production…finally

by BaerConsultLLC on Aug.03, 2009, under News, Server Configuration

Well, it was a long hard road over the past month or so. Quite a few unexpected twists and turns but what can you expect when trying to build this type of machine. There’s about 80 total pounds to this beast. 15 of those pounds in hard drives. A brand new 3ware 9650SE and 8TB of data. We opted to go with RAID1 (1TB + 1TB) for the operating system array/server backup array. Then we utilized RAID5 (2TB + 2TB + 2TB) for the remainder of the storage area. Sad to say, we lost some performance with RAID5, but since we opted for gigabit through, we’re pushing anywhere from 400mbps down to 200mbps (mainly the loss of performance on the RAID5). That’s writing, though. We’re hitting ~500mbps for reading! If anyone is considering building a NAS and is reading this; save yourself the headache and get a hardware RAID card. See the attached picture to see why 3ware is convenient.

3ware has a utility called 3DM2, which comes in handy when rebuilding or troubleshooting RAID arrays

3ware has a utility called 3DM2, which comes in handy when rebuilding or troubleshooting RAID arrays

Leave a Comment :, , , , , , , , more...

Ubuntu NAS

by BaerConsultLLC on Jul.20, 2009, under Server Configuration

Building a NAS seems like an easy task, just buy the drives, build a computer, install the operating system and away you go. In actuality, it’s not always as easy as it seems. The first thing you’ll want to do is make sure that each drive is the same size. RAID (Redundant Array of Inexpensive Drives) does not support variable sizes so each drive will be truncated to the size of the smallest drive.

For example 660GB split between two drives would most likely look like this:
1 500GB drive
1 160GB drive

But RAID will only see it as:
1 160GB drive
1 160GB drive

There is another “RAID” type but we don’t consider it to be a true RAID array as it’s not constrained by proportions and that’s JBOD (Just a Bunch Of Drives). With JBOD, you can combine drive sizes to make one massive, logical volume. In the example above, using JBOD, you could end up with a 660GB volume. However, you will rarely find someone that will suggest JBOD or RAID0 as there is no redundancy there. One advantage that JBOD offers over RAID0 is that it is uses concatenation, meaning that as data is added to the volume it is placed on individual drives in the order it was added. If the drive is full, it will begin adding to the next drive in the array. RAID0 uses striping, meaning that when you add data, it writes the data in “blocks”, typically 128KB, to the volume, but not in an efficient fashion.

When adding a 300KB file to a 2 drive RAID0 array:
The file will be written 128KB (by default) at a time.
0-128KB will go to the first drive
129KB-256KB will go to the second drive
257KB-300KB will go back on the first drive
This cycle will repeat the larger the file/folder is.

With RAID0, you have little to no chance of getting your data back if a drive were to fail.

RAID1 is used for mirroring, meaning that data is near simultaneously written to each drive in the array. The most common implementation of this is Hot-Swapping of drives. You can literally unplug all but one drive in a RAID1 array and the system will continue to function without the other drives in the array. You can do everything you normally would without those drives and the computer will still function. You can also plug them back in and the RAID will write altered files to the drives over time and get them back up to speed. In any server implementation, it would be handy to have this in the event of a hard drive failure. The drive can fail and you would see no difference what-so-ever in the function of the machine.

We opted to go with RAID5 for the time being. The reason is simple, only Ubuntu server supports a streamlined method of implementing software RAID. It does not support JBOD, however. In our implementation, the logical method would be to use JBOD to create two 4TB volumes, and then mirror them with RAID1. This way, simply replacing a failed drive, would fill the data back up without error.

RAID5 is similar to RAID0 in which is uses striping, but RAID5 also uses parity, which is used to rebuild a failed drive. However, it does have some restrictions in that you are supposed to only use equal numbered drives but Ubuntu did not throw an error when configuring the array with 5 drives. We will most likely research a way to do JBOD under Ubuntu Desktop and continue there…

Leave a Comment :, , , , , , , , , , , more...

Rebuilding the NAS

by BaerConsultLLC on Jul.20, 2009, under Server Configuration

Well, we’ve been putting this off for a long time and for a very good reason…setting up RAID arrays can be extremely difficult. Ubuntu only supports setting them up on the server edition but can not be set up in the fashion that is needed. We’re going from (2) 1TB drives to (3) 2TB drives and (2) 1TB drives for a total of 8TB of storage. However, we’re trying to implement fault tolerance and get them mirrored. It’s inevitable, this will end up included in the Tip of the Week. We’ve opted to abandon Ubuntu in this particular instance and go with a distro specifically geared for Samba, NFS, etc. setups, FreeNAS. We’ll post results when all is well…hopefully…

Leave a Comment :, , , , , , , , , , more...

Virtual Hosting Nightmare

by BaerConsultLLC on Jun.24, 2009, under Server Configuration

Seeing as how I have finally gotten through the Virtual Hosting fog, it only seems appropriate that my first blog be about setting up Virtual Hosting.  First off, this blog will only contain the bare minimum.  If you’re going to have Wordpress, Drupal, Databases, or anything other than strictly HTML, you’ll need to install the packages that support those such as MySQL-Server and PHP5.  I had to do a whole bunch of this to get Wordpress and Drupal going.  This is also for Apache2 on Ubuntu 8.04 server.

First, go in to /etc/apache2/sites-enabled and delete the symlink for 000-default.  Don’t worry about doing this as the actual file that contains all of that information is actually located in sites-available.  It’s just a shortcut or a link.

Next, go to /etc/apache2/sites-available and create a new text file.  I did “sudo nano vhost”.  The contents of this file are pretty straight forward.  Mine looks like this:


NameVirtualHost *

#
# domain1.com
#

ServerName domain1.com
ServerAlias www.domain1.com
DocumentRoot /var/www/domain1
CustomLog /var/www/logs/domain1.com-access.log combined
ErrorLog /var/www/logs/domain1.com-error.log

#
# domain2.com
#

ServerName blog.domain2.com
ServerAlias www.blog.domain2.com
DocumentRoot /var/www/blog
CustomLog /var/www/logs/Blog.domain2.com-access.log combined
ErrorLog /var/www/logs/Blog.domain2.com-error.log

ServerName = the site name that you’re configuring.
ServerAlias = anything that you want to direct to the same site. This can be “blog.example.com” or “www.example.com” or anything you want pretty much.
DocumentRoot = the path that houses all of your files or your single index.html file or index.php file.
CustomLog and ErrorLog = I highly suggest using these. This definitely helps with troubleshooting. Otherwise, you’ll probably end up adding this anyway, so just add it now.

So now you’ve got the actual virtual hosts configured. You can put dummy HTML files in those directories for testing purposes. Now do “sudo ln -s /etc/apache2/sites-available/YOUR FILE NAME HERE /etc/apache2/sites-enabled/YOUR FILE NAME HERE”. This will put your file linked to sites-enabled which will make it active.

Next, “sudo nano /etc/hosts” and add:

Your Internal IP address domain1.com domain2.com

And save it.

Next, “sudo nano /etc/apache2/apache2.conf” and add:

ServerName Your Internal IP address

Now, if you restart apache2:

sudo /etc/init.d/apache2 restart

You should be able to go to Your Internal IP address/folder_that_files_are_stored_in in a browser and pull up whatever your index.html file has in it.

If you want these externally accessible, create A records in your favorite NS server, I use everydns.net, for that server’s static public IP address.

Keep in mind that once you’re sure that the sites are externally accessible, you should edit your hosts file and remove their entries from it.

If you want it internally accessible only, do not put in DNS A records, just leave your host file the way it has been set up. That way when your browser makes the HTTP request, it puts through the domain name and IP address.

Editing the host file can also allow you the opportunity to take your site offline for edits, etc. You can shut down the port on your firewall and use the host file to access the domain (as long as you’re in the same network).

You should be all set.

1 Comment :, , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...