Category Archives: Uncategorized

Moving to a larger cluster

I’ve been building a larger version of my Banana Pi cluster. It was originally built with just four nodes, but I’ve extended it to 8. There are
now four database servers running MySQL which are synchronized using master/slave replication. There are four web servers with Nginx and uWSGI
running Pyplate.

I plan on adding another four Banana Pis as web servers. Pages are cached on the web servers, so most pages are served without needing to access
the database. There isn’t much load on the database servers, so it shouldn’t be a problem to have more web servers than database servers.

The web servers are synchronized using rsync. I’ve set up ssh keys so that I can use rsync over ssh without having to enter passwords. The web
root directory and the Pyplate directory are synchronized from a master web server to the workers in the web server cluster.

I’ve moved pyplate.com to the new cluster, and I’m working on new sites that will also be hosted on the cluster.

I’m using Ganglia to monitor both clusters. It’s almost set up the way I want, except the master web server doesn’t appear in the Ganglia UI.
I’ll check the settings in gmond.conf on the node I’m having problems with.

Advertisements

Running several sites on a Banana Pi server

I’ve been doing some work on Pyplate CMS.  I’ve upgraded it so that I can run several sites on a single server, and I’ve also added support for MySQL to Pyplate.  I’m calling the new version Pyplate Multi-Site.

Now I can create a very simple mass blogging system on my Banana Pi cluster by installing Pyplate Multi-Site on each server in the cluster and make sure that they are synchronized.  This is an improvement on the Raspberry Pi cluster which can only serve one site.

I haven’t released the updated code yet.  I need to do more testing and update the Pyplate installation scripts.

So far I have only tested Pyplate Multi-site with Nginx.  If I want to use it with Apache, I will need to use mod vhosts in order to set a different web root folder for each site.  I haven’t tested it yet, but I will over the next few weeks.

In the short term I need to keep working on the Banana Pi cluster and get the upgraded version of it online so that I can start building some new sites.

Using Ganglia to monitor three Banana Pi clusters

I’ve done some testing of the Ganglia monitoring tool on three small Banana Pi clusters.

three Banana Pi clusters monitored by Ganglia

Ganglia grid overview

I used a cluster of four database servers, another cluster of four nodes running GlusterFS, and a cluster of two master nodes.

The Ganglia meta demon has to be installed on the master node (the node where Ganglia stores data and the web front-end).  Some configuration changes need to be made in /etc/ganglia/gmetad.conf:

  • set the ‘gridname’ directive
  • add data_source lines for each cluster
  • add a list of IP addresses to the trustedhosts directive

The data_source directive specifies the name and host/port details of a cluster.  There is one data_source line for each cluster.

The Ganglia monitor needs to be installed on each node.  It’s configuration file (/etc/ganglia/gmond.conf) also needs to be edited:

  • edit the cluster name
  • change the port number that the monitor uses to communicate with the master node.

Ganglia uses different ports to distinguish between different clusters, so the ports in gmond.conf should be the same for every node in a cluster, and each cluster needs to use a different port.

You can read about the details here: http://banoffeepiserver.com/server-monitoring/ganglia/set-up-ganglia-on-multiple-clusters.html.

Server Monitoring

I’ve tested a few different monitoring tools for my Banana Pi servers.  The ones I’ve looked at so far are pretty simple, but they would be OK if I was just monitoring one Pi.

I need to be able to monitor clusters of servers, so I’m going to take a look at Ganglia.

Python utility for managing a cluster of database servers

I’m still working on some code to manage replication on a cluster of Banana Pi MySQL servers. It’s coming on quite well. I’ve got to a point where I can

  • demote a master,
  • promote another master,
  • add servers to the cluster,
  • copy the database to another server.

I’ve published the code on Github at https://github.com/Pyplate/db-cluster-utils.  There’s information on how to use DB Cluster Utils on my Banana Pi site at http://banoffeepiserver.com/mysql/python-database-cluster-management-utility/.

I was contacted earlier today by the owner of tinyonestore.com, asking if I would mind if they linked to my site from their site. I guess they wanted to check that they weren’t going to swamp my site with traffic, but that hasn’t been a problem so far. Looks like they have some interesting products like the Radxa Rock Pro.

GlusterFS and MySQL clusters running on Banana Pi servers

I’ve set up a four node MySQL cluster using Banana Pi servers.  There’s one master and three slaves replicating a MySQL database.

4 Banana Pi servers

4 node Banana Pi cluster

The first time I tried this I set up a small two node cluster and set up replication by typing commands at the MySQL shell prompt.  I didn’t want to do that again when I set up a 4 node cluster, so I wrote some Python scripts to do the work for me.  You can check them out at https://github.com/Pyplate/db-cluster-utils.

For detailed information on how I set this up, check out this page:http://banoffeepiserver.com/mysql/automate-mysql-replication-on-four-nodes.html.

I’ve also built a cluster of Banana Pi servers for use with the GlusterFS file distributed system.  First I built a stack of hard disks:

4 SATA hard disks

4 SATA hard disks

I connected a 4 node Banana Pi cluster to the stack, and installed GlusterFS on each Banana Pi.  Data is replicated on two of the disks, so if one disk breaks, no data will be lost.  You can read about how I set this up at http://banoffeepiserver.com/glusterfs/setting-up-glusterfs-on-four-banana-pi-servers.html

4 Banana Pis and 4 hard disks

4 node Gluster volume with SATA disks running on Banana Pi servers

Once I’ve finished testing these clusters, I can integrate them with my cluster of Banana Pi web servers.

Setting up a home page on a Pyplate site

I was recently asked how to set up a home page on a Pyplate web site. You need to do two things to make this work:
1. Create a new layout in the Site Settings field in the Admin area,
2. Edit the database record for page /main.html to use the new layout when this page is served.

To add a new layout, go to the Admin Area’s Site Settings page, and look for the post layout formatting code. It should look something like this, depending on which version of Pyplate you’re using:

 if layout == "post_layout":
 return post_layout.format(
 banner=pyplate.getFile(pyplate.getCMSRoot() + "/template/banner.html"),
 navbar=pyplate.getFile(pyplate.getCMSRoot() + "/template/navbar.html"),
# navbar=pyplate.get_navbar(dbase),
 banner_ad=pyplate.getFile(pyplate.getCMSRoot() + "/template/bananapi_responsive.html"),
 sidebar=sidebar_str,
# sharing=pyplate.get_sharing_template(),
 sharing=pyplate.get_sharing_buttons(path, page.title,page.description),
 breadcrumbs=pyplate.get_breadcrumbs(dbase, page.posts[0]),
 posts=post_str,
 section_menu=pyplate.get_category_menu(dbase, page.category, True, "More from this category:"),
 comments=pyplate.get_comment_template(),
 footer=pyplate.getFile(pyplate.getCMSRoot() + "/template/footer.html"))

Copy that code and paste it directly below the post_layout code. On the first line of th enew block, change post_layout to homepage_layout

#
# Copy the post_layout and change the layout string to homepage_layout
#
 if layout == "homepage_layout":
 return post_layout.format(
 banner=pyplate.getFile(pyplate.getCMSRoot() + "/template/banner.html"),
 navbar=pyplate.getFile(pyplate.getCMSRoot() + "/template/navbar.html"),
# navbar=pyplate.get_navbar(dbase),
 banner_ad=pyplate.getFile(pyplate.getCMSRoot() + "/template/bananapi_responsive.html"),
 sidebar=sidebar_str,
# sharing=pyplate.get_sharing_template(),
 sharing=pyplate.get_sharing_buttons(path, page.title,page.description),
 breadcrumbs=pyplate.get_breadcrumbs(dbase, page.posts[0]),
#
# Instead of using the post_str variable to fill the posts field, 
# use this line 
#
 posts=pyplate.getPost(pyplate.getCMSRoot() + "/content/main.html", "/content/main.html", ),

 section_menu=pyplate.get_category_menu(dbase, page.category, True, "More from this category:"),
 comments=pyplate.get_comment_template(),
 footer=pyplate.getFile(pyplate.getCMSRoot() + "/template/footer.html"))

Next, set the layout field to homepage_layout in the database.  You need to edit the layout field for /main.html. If you’re using a newer version of Pyplate with imort/export control in the Admin Area, then you can just export the database. Open /usr/share/pyplate/database/postindex.xml, and look for the record that contains main.html. Change the layout field to look like this:

<layout>homepage_layout</layout>

Click the import button to import the changes into the database. Then restart your server.

If you’re using an earlier version of Pyplate with no import/export buttons, you need to copy the database from /usr/share/pyplate/database/pyplate.db to a PC. Then you can install Sqlite Studio to edit the database: http://sqlitestudio.pl/. Copy the updated file back to your server and restart it.