Archive for the 'Servers' Category

Smokeping on FreeBSD 7

Thursday, April 24th, 2008

This write-up assumes a working copy of FreeBSD 7.0.  It was built using 7.0-RELEASE.  It should work on FreeBSD 6.x-STABLE and future versions of FreeBSD 7.  The package versions listed were current as of this writing but may have been updated by the time someone uses this howto.

This is a basic setup of Smokeping.  There are many extra features that I do not touch on here such as multi-target graphs, alerting, slaves, agents and additional probe types.  Check the online documentation for further info.

Please let me know if you run into typos or other technical issues when implementing this.

1.) First let’s update the ports collection.

Setup the update:


# cd /usr/ports/ports-mgmt/portupgrade
# make install clean
# cd /usr/ports/net/cvsup
# make install clean
# cp /usr/share/examples/cvsup/ports-supfile /root/ports-supfile
# pico /root/ports-supfile

Make it look something like this:


#######################################################
*default host=cvsup1.us.FreeBSD.org
*default base=/var/db
*default prefix=/usr
*default release=cvs  tag=.
*default delete use-rel-suffix
#comment the below line if you don't want to update the /src directory
#src-all
#update /usr/ports
ports-all tag=.
#######################################################

Run the update:


# cvsup -L 2 /root/ports-supfile
# portsdb -Uu

Update installed ports:


# portversion -l "<"
# portupgrade -arR
# pkgdb -F

2.) Install the necessary packages.

Descriptions of packages and uses here: http://oss.oetiker.ch/smokeping/doc/smokeping_install.en.html

  •          Perl 5.8:
  • Installed by default with FreeBSD install

  •          RRDTool 1.2.26:

  • # cd /usr/ports/databases/rrdtool
    # make install clean

     

  •          Fping 2.4b2_to-ipv6:

  • # cd /usr/ports/net/fping
    # make install clean

     

  •          EchoPing 6.0.0:

  • # cd /usr/ports/net/echoping
    # make install clean

  •          Dig:
  • Installed by default with FreeBSD install

  •         Perl modules:
  • Socket6

    # cpan
    # install Socket6

    Net:DNS

    # install Net::DNS
    # quit

  •          Apache 2.2.8:

  • # cd /usr/ports/www/apache22
    # make install clean

  •          SpeedyCGI 2.22_4:

  • # cd /usr/ports/www/p5-CGI-SpeedyCGI/
    # make install clean

  •          Smokeping 2.2.7_2:

  • # cd /usr/ports/net-mgmt/smokeping
    # make install clean

    3.) Configure the packages.

  •          Configure Apache:

  • # pico /usr/local/etc/apache22/httpd.conf

    Add:

    (within the <IfModule alias_module> section)


    <Directory "/usr/local/smokeping/htdocs">

    Add:

    (within the <IfModule dir_module> section)

    Add smokeping.cgi after index.html on the DirectoryIndex line to allow smokeping.cgi to load as a default document.

    It should look like:

    DirectoryIndex index.html smokeping.cgi

    Allow the startup of Apache:

    Add the following to /etc/rc.conf

    apache22_enable="YES"           # enable Apache 2.2

    Start Apache:

    # /usr/local/etc/rc.d/apache22 start

  •          Configure Smokeping:
  • Edit the variables in the following files appropriately

    # pico /usr/local/etc/smokeping/config

    Variable example settings in the first section:


    owner    = Systems Administrator
    contact  = sysadmin@domain.com
    mailhost = localhost
    sendmail = /usr/sbin/sendmail
    imgcache = /usr/local/smokeping/htdocs/img
    imgurl   = /smokeping/img
    datadir  = /usr/local/var/smokeping
    piddir  = /usr/local/var/smokeping
    cgiurl   = http://server.domain.com/smokeping/smokeping.cgi
    smokemail = /usr/local/etc/smokeping/smokemail
    tmail = /usr/local/etc/smokeping/tmail

    *** Alerts ***

    The “*** Targets ***” section is where you define your Smokeping targets and build the navigation menu.  It is a little too in depth to cover here.  Play around with it to figure out how it works.

    In depth configuration info is here: http://oss.oetiker.ch/smokeping/doc/smokeping_config.en.html

    There are some configuration samples here: http://oss.oetiker.ch/smokeping/doc/smokeping_examples.en.html

    Verify the path to Speedy:

    # pico /usr/local/smokeping/htdocs/smokeping.cgi

    -first line pointing to full path of speedy

    Customizations to the Smokeping web page templates can be made in the following config files:


    /usr/local/etc/smokeping/smokemail
    /usr/local/etc/smokeping/basepage.html
    /usr/local/etc/smokeping/tmail

    Set file system permissions to make the img folder and files writeable:

    # find /usr/local/smokeping/htdocs/img -type d -exec chmod 777 {} \;
    # find /usr/local/smokeping/htdocs/img -type f -exec chmod 666 {} \;

    Allow the startup of Smokeping:

    Add the following to /etc/rc.conf

  • smokeping_enable=”YES”          # enable smokeping
  • Start Smokeping:


    # /usr/local/etc/rc.d/smokeping start

    Operational Notes:

  •          You should now be able to browse to http://www.yourdomain.com/smokeping/ to view your Smokeping statistics.
  •          You may want to consider securing the Smokeping page with .htaccess users, a firewall or other form of authentication.
  •          I updated the index.html page in the root of the default Apache site:
  •  index.html at /usr/local/www/apache22/data/

    <meta http-equiv=”refresh” content=”0;url=http://www.someotherdomain.com”/>

    This redirects traffic sent to the root of your server to a different domain since this traffic obviously doesn’t need to be hitting the Smokeping server.

  •          When you add new targets or change targets in the /usr/local/etc/smokeping/config file you will need to restart Smokeping:
  • #/usr/local/etc/rc.d/smokeping restart

     

    Installing MySQL4 and MySQL5 on a single FreeBSD 6.2 Server.

    Tuesday, March 11th, 2008

    This write-up makes the following assumptions:

    • Working copy of FreeBSD 6.2.
    • Build: 6.2-RELEASE.

    Which should work on 6.2-STABLE and 7.0 as well.

    Please let me know if you run into typos or other technical issues when implementing this.

    1. Download the latest binaries from mysql.com.
    2. At write-up time this was:

      mysql-5.0.45-freebsd6.0-i386.tar.gz
      mysql-standard-4.1.22-unknown-freebsd6.0-i386.tar.gz
    3. Install MySQL 4.
    4. Uncompress the binary source.

      # cd /usr/local
      # gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
      # ln -s full-path-to-mysql-VERSION-OS mysql4

      Create the daemon user and group.

      # pw groupadd mysql4
      # pw useradd -n mysql4 -c "" -g mysql4 -d /nonexistent -s /usr/sbin/nologin

      Set the file permissions.

      # cd /usr/local/mysql4
      # chown -R root:mysql4 .

      Run the setup database setup script.

      # scripts/mysql_install_db --user=mysql4

      Copy the startup script to the proper location.

      # cp /usr/local/mysql4/support-files/mysql.server /usr/local/etc/rc.d/mysql4.server.sh

      Change two variables in the start script.

      # pico /usr/local/etc/rc.d/mysql4.server.sh

      Change “basedir=” to “basedir=/usr/local/mysql4″
      Change “datadir=/usr/local/mysql/data” to “datadir=/usr/local/mysql4/data”
      Change “pid_file=” to “pid_file=/var/run/mysql4/mysql4.pid”

      Create configuration files.

      Copy one of the sample configuration files based on your server usage replacing xxxx in the line below.

      # cp /usr/local/mysql4/support-files/my-xxxx.cnf /usr/local/mysql4/data/my.cnf

      Change variables in the configuration file.

      # pico /usr/local/mysql4/data/my.cnf

      Add a variable at the top of the [mysqld] section - “user = mysql5″
      Change the “port = 3306″ variables to “port = 3304″
      Change the “socket = /tmp/mysql.sock” variables to “socket = /tmp/mysql4.sock”

      Create a run directory for the MySQL 4 process and set permissions on it.

      # mkdir /var/run/mysql4
      # chown -R mysql4:mysql4 /var/run/mysql4
    5. Install MySQL 5.
    6. Uncompress the binary source.

      # cd /usr/local
      # gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
      # ln -s full-path-to-mysql-VERSION-OS mysql5

      Create the daemon user and group.

      # pw groupadd mysql5
      # pw useradd -n mysql5 -c "" -g mysql5 -d /nonexistent -s /usr/sbin/nologin

      Set the file permissions.

      # cd /usr/local/mysql5
      # chown -R root:mysql5 .

      Run the setup database setup script.

      # scripts/mysql_install_db --user=mysql5

      Copy the startup script to the proper location.

      # cp /usr/local/mysql5/support-files/mysql.server /usr/local/etc/rc.d/mysql5.server.sh

      Change a few variables in the start script.

      # pico /usr/local/etc/rc.d/mysql5.server.sh

      Change “basedir=” to “basedir=/usr/local/mysql5″
      Change “datadir=” to “datadir=/usr/local/mysql5/data”
      Change “pid_file=” to “pid_file=/var/run/mysql5/mysql5.pid”
      Change “server_pid_file=” to “server_pid_file=/var/run/mysql5/mysql5.pid”
      Change “user=mysql” to “user=mysql5″

      Create configuration files.

      Copy one of the sample configuration files based on your server usage replacing xxxx in the line below.

      # cp /usr/local/mysql5/support-files/my-xxxx.cnf /usr/local/mysql5/my.cnf

      Change variables in the configuration file.

      # pico /usr/local/mysql5/my.cnf

      Add a variable at the top of the [mysqld] section - “user = mysql5″
      Change the “port = 3306″ variables to “port = 3305″
      Change the “socket = /tmp/mysql.sock” variables to “socket = /tmp/mysql5.sock”

      Create a run directory for the MySQL 5 process and set permissions on it.

      # mkdir /var/run/mysql5
      # chown -R mysql5:mysql5 /var/run/mysql5
    7. Start the daemons.
    8. # /usr/local/etc/rc.d/mysql4.server.sh start
      # /usr/local/etc/rc.d/mysql5.server.sh start
    9. Post installation configuration.
    10. MySQL4:

      Connect to MySQL

      # /usr/local/mysql4/bin/mysql -u root -P3304 -S/tmp/mysql4.sock

      Remove the anonymous account.

      mysql> DELET FROM mysql.user WHERE Host='localhost' AND User='';

      Set the root password

      mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('difficultpassword1');
      mysql> SET PASSWORD FOR 'root'@'server.domain.com' = PASSWORD('difficultpassword1');

      Create a backupoperator account for backup script access to all databases.

      mysql> GRANT ALL PRIVILEGES ON *.* TO 'backupoperator'@'localhost' IDENTIFIED BY 'difficultpassword2';

      Apply changes.

      mysql> FLUSH PRIVILEGES;

      Quit.

      mysql> QUIT;

      MySQL5:

      Connect to MySQL

      # /usr/local/mysql5/bin/mysql -u root -P3305 -S/tmp/mysql5.sock

      Remove the anonymous account.

      mysql> DROP USER '';

      Set the root password.

      mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('difficultpassword1');
      mysql> SET PASSWORD FOR 'root'@'server.domain.com' = PASSWORD('difficultpassword1');
      mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('difficultpassword1');

      Create a backupoperator account for backup script access to all databases

      mysql> GRANT ALL PRIVILEGES ON *.* TO 'backupoperator'@'localhost' IDENTIFIED BY 'difficultpassword2';

      Quit

      mysql> QUIT;

    That’s it! Create your mysql users and databases and connect your applications.

    Notes:

    1. Command line connections to mysql now require additional connection info to specify port and socket:
      MySQL4 - # /usr/local/mysql4/bin/mysql -u username -ppassword -P3304 -S/tmp/mysql4.sock
      MySQL5 - # /usr/local/mysql5/bin/mysql -u username -ppassword -P3305 -S/tmp/mysql5.sock
    2. Remote connections to mysql will require specifying the correct port in the connection string instead of assuming port 3306.

    HostingCon 2007 - Distributed/Grid Computing vs. Virtualization

    Friday, September 28th, 2007

    opus interactive grid grill

    There was a lot of buzz about Grid Computing vs. Virtual Machines and the combination of them together. As many of you may know Amazon (Amazon EC2 and Amazon S3) like many others, such as Google (Google Page Creator) and Microsoft (Microsoft Office Live,) has released online hosting/storage services using this technology in one form or another. The technology has been out since 1990s as a metaphor for making computer power as easy to access as an electric power grid in Ian Foster and Carl Kesselmans seminal work, “The Grid: Blueprint For A New Computing Infrastructure.”

    My experience with Grid Computing goes back to the late 1990s with distributed.net in helping making encryption that much secure. With the technology originally designed to harness unused CPU cycles to solve complex problems, to now being used to hosting an infinite number of hosting environments. It is amazing the level of reliability and scalability options that are available with the system. The ability to grow in resources at an unlimited rate -on the fly- with little to no exposure to change, is outstanding. The other great aspect of this system of technology is the ability to contribute to a sustainable mindset. If done properly, you can reuse old servers and hardware that in a normal life cycle would be recycled, now can be reprovisioned back into a production environment with little concern of impact of hardware failure. This rejuvenation of hardware opens up a great opportunity to get that-much-more out of your initial investment as well as being able to pass those saving onto the customer. Do I see Grid and Virtual environments replacing all hosting environments? Not likely. In theory they have great potential to revolutionize the price, uptime, and growth opportunities of hosting. However I don’t see the replacement of dedicated environments with dedicated resources. Really, the way I look at it is: the continued growth in Grid and Virtual systems is really an improvement like public light rail has been for transportation. It has become cheaper, more reliable and continues to expand where it can go. However most of us still buy our own cars customized the way we like; from rims, stereos, number of seats, 4×4, biodiesel, the list goes on. Just like the vehicles you want to own, the same holds true in hosting. As a light rail can’t take you everywhere when you need to be, grids and virtual solutions can’t host every complex environment.

    We at opus:interactive specialize in virtual management services.

    The question always seems to come up with this technology, will the Corporate Giants with the large pocket books and nearly limitless resources wipe out the little local hosting companies? In my opinion – not likely. Although the large corporate empires can deliver good products and great hardware, one thing they will always struggle with is: relationships. There is something to be said with local support and the face-to-face relationship with your hosting partner that you don’t get with the Giants. Having the ability to pick up the phone and call your solutions executive-engineer-local-host 24/7 and have them know who you are by name and the solution you utilize says a lot about the type of local provider you have. Additionally, there is something to be said about the warm fuzzy feelings we all get when we can go down to the local Data Center and see the pretty lights flashing and say to yourself, “There is my site.” The fact is, what Amazon as well as other do for the industry is what helps get the exposure to the general public about technology and drive more business to local providers as well. I think it is great. It will be interesting to see how the community responds to the technology. One thing is for sure my eyes will be watching.

    Hosting Con 2007 also brought information about web 2.0 applications: MySpace, YouTube, Facebook, Friendster, and Xanga community. Others refer to this as a social networking movement. I find it interesting that half of Myspace users are over the age of 35.

    Older demographics are emerging in many of the social networks, case in point: Facebook.

    So what does that say? To me it says there is a opportunity harness some of the power of user driven content. There is over 180,000 active and unique visitors in these communities as of Aug 2006 and they continue to grow. One way I see harnessing the power of these users is to create a community of customers for your hosting business that can help each other. They are all in one form or another doing the same thing and can use each other’s resources/knowledge to grow together. This type of value add and communication tunnel that not only your customers can contribute and drive the conversations but also your engineers and technicians can contribute ideas or solutions to drive more business. In summary, hosting is a communication vehicle to drive your customers content.

    George Sums Up HostingCon 2007.

    Thursday, September 13th, 2007

    millennium park chicago hosting con 2007

    Jeremy Sherwood and myself at Millennium Park. Jeremy kept trying to get in.

    Carson Daly at Hosting Con?!

    Carson Daly at Hosting Con?!

    Tigers first pitch, home run off your head!

    Tigers first pitch, home run off your head!

    opus interactive hosting con 2007 chicago sunset

    Our final Chicago sunset as we depart Hosting Con 2007.

    COM Object Issues on Windows 2003 (URLFetch)

    Thursday, August 30th, 2007

    opus interactive edition windows 2003 upgrade

    With the passage of time, there is always technological challenges that crop up for existing clients, which is why as a managed service provider we step in to eagerly correct issues so our clients need not (after all, this is what they are paying us for.) These challenges manifest themselves either through user growth, hardware limitations or in worse case scenarios: hardware failures. Recently our monitors noticed that a five year old Windows 2000 Server was about to start digging a little virtual six-foot-deep grave and this is where we stepped into the challenge.

    I quickly stabilized their old server allowing it to keep running while we worked on a migration to a new solution. While this was happening, Jeremy (our beef-jerky-loving sales representative) sold the client one of our new dedicated managed HP c-Class BladeSystem servers. The web server will be migrated to Windows 2003 and the SQL server migrated to SQL 2005 on Windows 2003 as well. Additionally, I replaced their old Cisco PIX 501 firewall.

    After the migration of content, I began setting things up, including the VPN tunnels to the third party development company and the integration with the billing system. Once this was completed, I began full regression Quality Assurance.

    After testing, it was quickly discovered that the integration with the billing engine was not working. The reason was the rather old code (Active Server Pages, ASP, version 3.0) which had been written by a third-party development company back in 1999. The code they produced relied on a component called URLFetch, which didn’t work inside of the new operating system environment.

    Here is the particular code call:

    Set trs = server.CreateObject(”URLFetch.URLFetch”)

    This component is a COM Wrapper for a few lines of Java code that allow you to, basically, screen scrape sites and return them for use in the code. Since the billing system is on an internal network behind firewalls and a VPN, it can’t be served up direct to the end-user, so it has to be done from the code on the web server. Since this was an old component it was pretty much assumed that it wouldn’t work on Windows Server 2003 and IIS 6.

    The research began about this component and the specific error that was being thrown by the code, which was:

    Microsoft VBScript runtime error ‘800a01ad’
    ActiveX component can’t create object

    I quickly found this Microsoft Knowledge base (KB) article and grabbed filemon from sysinternals to check it out.

    Using depends.exe (from Dependency Walker) I looked into finding the missing .dll that I figured was trying to be loaded behind the scenes. This was confirmed and the missing dependent file was DWMAPI.dll.

    From there a little more research uncovered another team having difficulty with the same situation. From this information the .dll was found and downloaded.

    However, this new .dll didn’t produce results and I had to start again, from ground-zero.

    It was at this point that I began to deduct that this old component would not work on the Windows 2003 and IIS6. We then contacted the client and gave them the harrowing news that the possibility that they may need to re-write their code existed. Even in the face of this possibility, we wanted to assure that all avenues had been explored and I continued researching. Next was to review the component itself and how it was written - to define what dependencies it required. This additional digging uncovered the following information:

    The most likely cause to this problem is that you don’t have the latest Microsoft Virtual Machine installed on that computer. This is especially a problem with Windows Server 2003, as it does not ship with the Microsoft Virtual Machine. Please note that this is Microsoft’s Virtual Machine, and not Sun’s Java Virtual Machine. Microsoft’s Virtual Machine can be downloaded from these locations:

    opus interactive wants you to be a pepper tooThis was the final ‘a-ha!’ moment. I then quickly downloaded the Microsoft Virtual Machine and voilà, it worked! (The new SUN Java SDK was already tried before this and it didn’t work.)

    The end result: The client’s code now works great, on the new environment, with no need to update the code-base and I got to celebrate the moment with a Dr. Pepper.