VoltDB Recap

Aug 05, 2010

Objective: VoltDB Recap, complete with multiple nodes, snapshots and k-safety.

The below is as copy-paste and fast-forward as possible.

You will have to change some literal values, most prominently the IP number 10.2.0.37.

The config I used were three virtual servers, the lead being 10.2.0.37. I had six terminal windows open, two for each server obviously, the respective second to start the test clients.

The below also addresses a few minor glitches in the VoltDB doc of right now. In doubt, the below worked. At least for me. It is mostly copy-pasted right out of the terminal to avoid typos. But at some places, where following the manuals was not entirely straight forward, I might have made errors. Let me know.

Check Java Versions Installed


All servers should have at least build 1.6.0_18

java -version

VoltDB 1.1 Dowload

https://community.voltdb.com/downloads

Docs & Packages

VoltDB 1.x DE-Install

rm -rf /opt/voltdb/

VoltDB 1.1 Installation


On all servers:

wget https://community.voltdb.com/sites/default/files/LINUX-voltdb-1.1.01.tar.gz
tar -zxvf LINUX-voltdb-1.1.01.tar.gz -C /opt
cd /opt
mv voltdb-1.1.01 voltdb
cd

Catalog Server Test


On all servers:

cd
rm -rf helloworld
mkdir helloworld
cd helloworld
cp /opt/voltdb/examples/helloworld/* .
CLASSPATH=$HOME/helloworld:/opt/voltdb/voltdb/*
export CLASSPATH
javac Client.java; javac Insert.java; javac Select.java
java org.voltdb.compiler.VoltCompiler project.xml helloworld.jar
java -Djava.library.path=/opt/voltdb/voltdb org.voltdb.VoltDB catalog helloworld.jar deployment deployment.xml


On all servers, in a respective second terminal window:

cd
cd helloworld
CLASSPATH=$HOME/helloworld:/opt/voltdb/voltdb/*
export CLASSPATH
java Client

Multi Partition Test


Correct Example Error

nano Insert.java

-> change

partitionInfo = "HELLOWORLD.DIALECT: 0",

-> to

partitionInfo = "HELLOWORLD.DIALECT: 2",
javac Insert.java
java org.voltdb.compiler.VoltCompiler project.xml helloworld.jar


Copy the new helloworld.jar from one server to all others. Has to be done this way.

cd ; cd helloworld
sftp 10.2.0.38
> cd helloworld
> put helloworld.jar
> exit
sftp 10.2.0.39
> cd helloworld
> put helloworld.jar
> exit


On all servers start the cluster

java -Djava.library.path=/opt/voltdb/voltdb org.voltdb.VoltDB catalog helloworld.jar deployment deployment.xml


On any server call the client as compiled before

java Client


On any server *not* part of the server cluster,

change the connection host parameter of the client app

nano Client.java

-> change

myApp.createConnection("localhost", "program", "password");

-> to

myApp.createConnection("10.2.0.37", "program", "password");
javac Client.java
java Client

Auto Snapshots


On all servers create dir

mkdir /srv/voltdb
mkdir /srv/voltdb/autobackup


On one server add to project.xml

        <snapshot prefix="helloworld"
                  path="/srv/voltdb/autobackup/"
                  frequency="1m"
                  retain="100"/>


Recompile Catalogue

java org.voltdb.compiler.VoltCompiler project.xml helloworld.jar


Copy the new helloworld.jar from the one server to all others. Has to be done this way.

cd ; cd helloworld
sftp 10.2.0.38
> cd helloworld
> put helloworld.jar
> exit
sftp 10.2.0.39
> cd helloworld
> put helloworld.jar
> exit


On all servers start the cluster

java -Djava.library.path=/opt/voltdb/voltdb org.voltdb.VoltDB catalog helloworld.jar deployment deployment.xml


Snapshot messages are coming every minute even for empty database

244144 [Snapshot terminator] INFO HOST - Snapshot helloworld_2010.08.05.06.27.46 finished
at 1280989666704 and took 0.049 seconds


On any server call the client as compiled before

java Client


Wait for next snapshot then compare size with previous ones

ls -alt  /srv/voltdb/autobackup/
-rw-r--r-- 1 root root  262 Aug  5 02:29 helloworld_2010.08.05.06.29.46-HELLOWORLD-host_0.vpt
-rw-r--r-- 1 root root   29 Aug  5 02:29 helloworld_2010.08.05.06.29.46.digest
-rw-r--r-- 1 root root  145 Aug  5 02:28 helloworld_2010.08.05.06.28.46-HELLOWORLD-host_0.vpt
-rw-r--r-- 1 root root   29 Aug  5 02:28 helloworld_2010.08.05.06.28.46.digest

Manual Restore


On one server create file Restore.java

import org.voltdb.*;
import org.voltdb.client.*;

public class Restore {

static final String SAVEDIR = "/srv/voltdb/autobackup";
static final String SAVEID = "helloworld_[COMPLETE THIS FILE NAME]";
static final int EXPORTFLAG = 0;

    public static void main(String[] args) throws Exception {

VoltTable[] results = null;

        /*
         * Instantiate a client and connect to the database.
         */
        org.voltdb.client.Client myApp;
        myApp = ClientFactory.createClient();
        myApp.createConnection("10.2.0.37", "program", "password");

try {
      results = myApp.callProcedure("@SnapshotRestore",
                       SAVEDIR,SAVEID,EXPORTFLAG).getResults();
    }
catch (Exception ex)
    {
       ex.printStackTrace();
       System.out.printf("Restore operation failed: " + ex.getMessage());
     }
for (VoltTable t: results) { System.out.println(t.toString()); }
    }
}


put actual file name to SAVEID

ls -alt /srv/voltdb/autobackup/


enter latest file name, e.g.

static final String SAVEID = "helloworld_2010.08.05.06.33.46";


compile

javac Restore.java  


restart all servers

java -Djava.library.path=/opt/voltdb/voltdb org.voltdb.VoltDB catalog helloworld.jar deployment deployment.xml


Restore

java Restore


Check that Client crashes (as it should for unique index)

java Client

K Safety

On all servers add kfactor=”1″ to deployment.xml

<?xml version="1.0"?>
<deployment>
    <cluster hostcount="3" sitesperhost="1" leader="10.2.0.37" kfactor="1" />
</deployment>


fill data base

java Client

Useful Test Client

instead of letting "java Client" fail as test, you could use this:
import org.voltdb.*;
import org.voltdb.client.*;

public class Query {

    public static void main(String[] args) throws Exception {

        /*
         * Instantiate a client and connect to the database.
         */
        org.voltdb.client.Client myApp;
        myApp = ClientFactory.createClient();
        myApp.createConnection("localhost", "program", "password");

        /*
         * Retrieve the message.
         */
        final ClientResponse response = myApp.callProcedure("Select",
                                                            "Spanish");
        if (response.getStatus() != ClientResponse.SUCCESS){
            System.err.println(response.getStatusString());
            System.exit(-1);
        }

       final VoltTable results[] = response.getResults();
        System.out.printf("Result table length: %d\n", results.length);
      if (results.length != 1) {
            System.out.printf("I have a problem.");
            System.exit(-1);
        }

        VoltTable resultTable = results[0];
        System.out.printf("Result table rows: %d\n", resultTable.getRowCount());
      if ( resultTable.getRowCount() != 1) {
            System.out.printf("I can't say Hello in that language.");
            System.exit(-1);
        }

        VoltTableRow row = resultTable.fetchRow(0);
        System.out.printf("%s, %s!\n", row.getString("hello"),
                                       row.getString("world"));
    }
}

one comment

  1. [...] This post was mentioned on Twitter by VoltDB, tmcallaghan. tmcallaghan said: Interesting #VoltDB recap, from a users perspective. http://www.eonblast.com/blog/voltdb-recap/ [...]

You must be logged in to post a comment.