2. Setting up multiple database servers

If you want your installation to use multiple MySQL DB servers, you need to create databases for these. This is in addition to the main “livejournal” database you created earlier.

$ mysql -uroot -p
mysql> CREATE DATABASE lj_c1;
mysql> CREATE DATABASE lj_c2;

mysql> GRANT ALL PRIVILEGES ON lj_c1.* TO 
     > lj@'localhost' IDENTIFIED BY 'ljpass';
mysql> GRANT ALL PRIVILEGES ON lj_c2.* TO 
     > lj@'localhost' IDENTIFIED BY 'ljpass';
     > \q

Now, adjust the %LJ::DBINFO hash in ljconfig.pl to fit your needs.

Here is an example of multiple MySQL DB servers running on localhost:

%DBINFO = (
    # master must be named 'master'
        'master' => {
            'host' => 'localhost',
            'user' => 'lj',
            'pass' => 'ljpass',
        },
        'c1' => {
            'host' => 'localhost',
            'user' => 'lj',
            'pass' => 'ljpass',
            'dbname' => 'lj_c1',
            'role' => {
                'cluster1' => 1,
            },
        },
        'c2' => {
            'host' => 'localhost',
            'user' => 'lj',
            'pass' => 'ljpass',
            'dbname' => 'lj_c2',
            'role' => {
                'cluster2' => 1,
            },
        },
);

You also need to set @LJ::CLUSTERS and $LJ::DEFAULT_CLUSTER, to something like:

@CLUSTERS = (1, 2);
$DEFAULT_CLUSTER = [ 1, 2 ];

You can tweak the host key configuration within the %LJ::DBINFO hash to get them configured on multiple machines.