Notes on MonetDB

MonetDB download

(Below I used Ubuntu 13.04 and MonetDB v11.15.7 (Feb2013-SP2)

Installation

  1. Create file /etc/apt/sources.list.d/monetdb.list with the following content
    deb http://dev.monetdb.org/downloads/deb/ quantal monetdb
    deb-src http://dev.monetdb.org/downloads/deb/ quantal monetdb
    
  2. Get the GPG public key by
    $ wget --output-document=- http://dev.monetdb.org/downloads/MonetDB-GPG-KEY | sudo apt-key add -
    
  3. Install the MonetDB
    $ sudo apt-get install monetdb5-sql monetdb-client
    
    A pseudo user monetdb will be created.

    The following .deb files are downloaded and installed

    libmonetdb-stream3
    libmonetdb-client6
    libmonetdb9
    monetdb-client
    monetdb5-server
    monetdb5-sql
    
  4. Make sure the pseudo user monetdb can write to the directory /var/lib/monetdb by
    $ sudo chown monetdb:monetdb /var/lib/monetdb
    

MonetDB executable binaries

/usr/bin/mclient
/usr/bin/monetdb
/usr/bin/monetdbd
/usr/bin/mserver5
/usr/bin/msqldump

MonetDB concepts

MonetDB operates on "dbfarms". A dbfarm is actually just a directory where the actual database will be stored.

A dbfarm is managed by the MonetDB daemon process monetdbd, and each individual database in a dbfarm is managed by MonetDB server process mserver5.

Create/Configure/Start/Shutdown a MonetDB dbfarm

Let's say a dbfarm will be located at /data/monetdb
  • Create: monetdbd create /data/monetdb
  • Start: monetdbd start /data/monetdb

    The MonetDB daemon process monetdbd by default will listen at port 50000

  • Show parameters: monetdbd get all /data/monetdb
  • Set port number to 54321: monetdbd set port=54321 /data/monetdb

  • Stop: monetdbd stop /data/monetdb
The dbfarm parameters are stored in /data/monetdb/.merovingian_properties

The dbfarm log file is /data/monetdb/merovingian.log

Create a MonetDB database

Suppose the MonetDB daemon process is already running and listening at port 50000. If not, see above steps to create a dbfarm and start the daemon process.

Suppose a database mydb is to be created and used. The steps are

  1. Create: monetdb create mydb

    A database named mydb will be created and be put in maintenance (locked) mode. A database in such a mode will not be started automatically by MonetDB daemon process monetdbd when a client requests connection.

    The database is located under /data/monetdb/mydb/

  2. Start: monetdb start mydb

  3. Unlock: monetdb release mydb

Process tree

monetdbd start /data/monetdb
 \_ /usr/bin/mserver5 --dbpath=/data/monetdb/mydb --set merovingian_uri mapi:monetdb://myhost:50000/mydb --set mapi_open false --set mapi_port 0 --set mapi_usock /data/monetdb/mydb/.mapi.sock --set monet_vault_key /data/monetdb/mydb/.vaultkey --set gdk_nr_threads 2 --set max_clients 64 --set sql_optimizer default_pipe --set monet_daemon yes

Other useful MonetDB commands

  • List all available databases: monetdb discover

  • Show status of all available databases: monetdb status

    The usual statuses of a database are Stopped, Running, or Locked.

  • Show status of mydb: monetdb status mydb

  • Show parameters of mydb: monetdb get all mydb

  • Stop mydb: monetdb stop mydb.

    Alternatively, one can use monetdb kill mydb, which is equivalent to sending a SIGKILL signal to the MonetDB server process mserver5.

Create schema and user in a MonetDB database

  1. Launch the MonetDB client: Use the default user monetdb and default password monetdb to log in
    $ mclient -u monetdb -d mydb
    
  2. Create a user foobar
    sql> CREATE USER "foobar" WITH PASSWORD 'foobar' NAME 'Foo Bar' SCHEMA "sys";
    
  3. Create a schema foobardb for user foobar
    sql> CREATE SCHEMA "foobardb" AUTHORIZATION "foobar";
    sql> ALTER USER "foobar" SET SCHEMA "foobardb";
    

Useful commands for MonetDB client

  • Describe table (or view) tbl: \d tbl

  • Describe schema sch: \dn sch

  • List all tables: \d

  • List all schemas: \dn

  • List all system objects: \dS

  • List all authorizations: SELECT * FROM AUTHS;

  • List database parameters: SELECT * FROM env() env;

Use DBVisualizer as a MonetDB client

  1. Download JDBC driver here and put it under DBVisualizer's JDBC directory, say C:\Program Files (x86)\DbVisualizer\jdbc\monetdb
  2. Launch DBVisualizer. It will find this new driver but it does not recognize it.
  3. Select Tool -> Driver Manager menu, add a new driver called MonetDB.

    In URL format, enter jdbc:monetdb://hostname/database

    In Driver File Paths, point to the JAR file under C:\Program Files (x86)\DbVisualizer\jdbc\monetdb

    Now the Driver Class pull-down menu should have nl.cwi.monetdb.jdbc.MonetDriver as an option. Select it.

    Close Driver Manager dialog box.

  4. Restart DBVisualizer. Create a new connection to MonetDB mydb

    In JDBC Driver, select MonetDB.

    In Database URL, enter jdbc:monetdb://localhost/mydb.

Migrate data from MySQL to MonetDB

  1. Dump the table, say t1 of database mydb, into a "|" separate file:
    mysql> USE mydb;
    mysql> SELECT * FROM t1 INTO OUTFILE '/tmp/t1.tbl' FIELDS TERMINATED BY '|';
    
  2. Create the table in MonetDB. One can show table schema in MySQL by
    mysql> SHOW CREATE TABLE t1;
    
    Note that MonetDB does not have indices, so remove all KEY clauses in the table scheme.

    DATETIME in MySQL is TIMESTAMP in MonetDB, FLOAT in MySQL is REAL in MonetDB.

    MonetDB uses single quotes for strings and double quotes for table or schema names.

  3. Once the table is in MonetDB, use COPY INTO syntax:
    $ mclient -u foobar -d foobardb -s "COPY INTO t1 FROM STDIN" - < /tmp/t1.tbl
    
    Note the minus sign - in the command line.
Tips about MonetDB bulk load here. An even faster bulk load is binary mode.

Notes on manual installation of Intel 64-bit Linux C/C++ compiler version 2013.4.183

To install Intel 64-bit Linux C/C++ compiler version 2013.4.183 manually, one needs to unpack the following:
  • intel-compilerpro-common-183-13.1-4.noarch.rpm
  • intel-compilerpro-devel-183-13.1-4.x86_64.rpm
  • intel-compilerproc-183-13.1-4.x86_64.rpm
  • intel-compilerproc-common-183-13.1-4.noarch.rpm
  • intel-compilerproc-devel-183-13.1-4.x86_64.rpm
  • intel-openmp-183-13.1-4.x86_64.rpm
  • intel-openmp-devel-183-13.1-4.x86_64.rpm