Getting Started


In this tutorial we will walk you through the process of starting a cluster and inserting into and reading from it.

Download The Software

Unpack Package

  • Linux/Mac: Type "tar -xzf sonicbase-<version>.tgz" in the parent directory where you want the software to go. A directory named "sonicbase" will be created.
  • Windows: Unzip the file sonicbase-<version>.zip in the parent directory where you want the software to go. A directory named "sonicbase" will be created.
  • Set Paths In The Config


    Note on Windows you will need to escape the backslashes so the value can be stored in the json file.
    On Windows the directory may look like "c:\\\\sonicbase". On linux it may look like "/mnt/sonicbase". On linux and mac you also have the option of prefixing your path with "$HOME" to specify the home directory. This option is not available on Windows.

    Start Client

    Change to the sonicbase/bin directory and type "./cli" for MacOS and Linux and "./cli.bat" for cygwin and "cli.bat" for Windows. This will start the SonicBase client.

    Use Cluster

    In the client, type:
      use cluster 1-local

    Passwordless SSH

    If your servers aren't local, for Linux and Mac you need to setup passwordless ssh between all your servers and the local machine before taking the next steps.

    Deploy Cluster

    In the client, type:
      deploy cluster

    If all your servers are local, you do not need to deploy the cluster. Note that this command is not available in Windows. In Windows you need to manually copy the local install directory to each server in the location specified by "installDirectory" in the config file.

    Start Cluster

    In the client, type:
      start cluster

    This will start the cluster on the servers specified in the config file.

    Create Database

    In the client, type:
      create database db

    This will create the database named "db".

    Create Table

    In the client, type:
      create table persons (name VARCHAR, age INTEGER, ssn VARCHAR, PRIMARY KEY (ssn))

    Insert Record

    In the client, type:
      insert into persons (name, age, ssn) VALUES ('bob', 22, '555-66-7777')

    Read Record

    In the client, type:
      select * from persons

    You should see the inserted record displayed in the client.

    Access From JDBC Client

    Create and run the following class:

    
        package foo;
    class Test { public static void main(String[] args) { Class.forName("Driver"); Connection conn = DriverManager.getConnection("jdbc:sonicbase:localhost;:9010/db"); PreparedStatement stmt = conn.prepareStatement("select * from persons"); ResultSet rs = stmt.executeQuery(); rs.next(); System.out.println(rs.getString("name") + " " + rs.getInt("age") + " " + rs.getString("ssn")); } }

    Stop Cluster

    In the client, type:
      stop cluster