Skip to content
Snippets Groups Projects
README.md 9.78 KiB

Noblogs documentation

A distributed, scalable version of WordPress, with some pre-bundled (and audited) plugins, and some privacy-related tweaks.

This software is intended to be used as a basis for a large (potentially, very large), geographically distributed, WordPress multisite installation.

Although some of our patches can be of general use for a WordPress user that cares about his privacy, this WordPress version is meant to be deployed on multiple servers.

Architecture

Scaling WordPress is usually achieved through some form of database partitioning using HyperDB. This will not work very well in a high-latency scenario, such as a geographically distributed cluster (i.e. commodity hardware on different ISPs), due to the very high number of (sequential) database requests needed to render a single WordPress page.

We are solving the distribution problem in a high-latency cluster as follows:

  • Each blog is completely local to one server (images, files, database) and is served locally from that server

  • Global data (the main site, buddypress, users, blog index, etc) is stored on a separate database, relatively small, that is replicated to all nodes with a master-slave setup. Using HyperDB, we're able to read from the local replica and to write to the remote master, just for this tiny global layer.

  • HTTP requests for a specific blog are forwarded to the right backend by the reverse HTTP proxy layer which stands in front of the PHP workers, so that partitioning is completely transparent to the users.

Installation

In this installation example, we assume you have at least 3 servers; all of them with a fully-functional LAMP stack already installed.

Get the software

Create a working directory for your noblogs-wp installation on all your servers, and then clone the noblogs-wp repository:


    $ mkdir -p /opt/noblogs/www
    $ git clone https://git.autistici.org/ai/noblogs-wp.git

The noblogs-wp repository is split in an "upstream" branch, where we keep all the upstream code, the "noblogs" branch, where we collect our patches on top of the upstream branch, and a few "release" branches, used in production.

So, if you want to use a stable release branch, check it out, i.e.


    $ git checkout noblogs-1.2.7

Setting up MySQL databases

This is probably the trickiest part of the installation, so please if you have doubts take a good look at the MySQL manuals.

Each MySQL instance will have two datasets:

  • A global, shared dataset
  • A local dataset containing data of the blogs assigned to this server

Let's create the two datasets on each server (here we're showing server 1):


    $ mysqladmin create global
    $ mysqladmin create local_1
    $ mysql -e "GRANT ALL PRIVILEGES ON global.* TO 'myuser'@'localhost' \
          IDENTIFIED BY 'somepassword'"
    $ mysql -e "GRANT ALL PRIVILEGES ON local_1.* TO 'myuser'@'localhost' \
          IDENTIFIED BY 'someotherpassword'"

The name of the local database name should change on the other servers, to be i.e. local_2, local_3 and so on. The global dataset should be replicated, and have a master instance. So, pick one server to be your master, and configure it to allow replication (in the following, we assume your master will be server 1):


    $ mysql -e "CREATE USER 'noblogs_replica' IDENTIFIED BY \
          'a_password'"
    $ mysql -e "GRANT REPLICATION SLAVE ON *.* TO 'noblogs_replica'"

On all servers, you should add to your mysql configuration file:


    binlog-do-db = global

Now set up the replica on the slaves (in our example, servers 2 and 3):


    $  mysql -e "CHANGE MASTER TO \
          MASTER_HOST='server_1', \
          MASTER_PORT=3306, \
          MASTER_USER='noblogs_replica', \
          MASTER_PASSWORD='a_password';"

Since the databases are empty at this point, we can safely start replication:


    $ mysql -e 'SLAVE START;'