Virtuoso Open Source on Mac OS

I’ve played around with different triple stores over the past years, but somehow never got to try Virtuoso. So I thought I’d give it a shot and while I’m at it, document the installation steps. The commercial edition of Virtuoso comes with a simple app that does all the dirty work for you, the open source edition does not – but this is not a huge issue unless a terminal window makes you want to hide under the table and cry.

Here we go.

Installation

  1. The Virtuoso Open Source GitHub page has a tutorial for building the application from scratch, but we are going to take the easy path. If you don’t have Homebrew installed, go ahead and do that. Open a terminal window and run
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. Homebrew is a package manager for Mac OS and provides builds for many popular (and not so popular) open source software packages. Homebrew makes installing Virtuoso as easy as
    brew install virtuoso

Starting Virtuoso

  1. After Homebrew has installed all dependencies and Virtuoso itself, we are ready to go. Virtuoso needs a virtuoso.ini file that contains all settings for the server. Our installation comes with a sample .ini file, located in /usr/local/Cellar/virtuoso/7.1.0/var/lib/virtuoso/db/ (this works for Virtuoso 7.1.0, but the location is most likely different for other versions. You can find that directory by running locate virtuoso.ini). Change into that directory and start virtuoso by running the following two commands:
    cd /usr/local/Cellar/virtuoso/7.1.0/var/lib/virtuoso/db/
    virtuoso-t -f
  2. Voilà. You should now be able to access the Virtuoso frontend at http://localhost:8890.
  3. You’ll find a link to the Conductor, the Virtuoso admin interface, at the top left of the page. The standard installation has a bunch of preset usernames and passwords, so that we can simply login with
    • User: dba
    • Password: dba

Loading data into Virtuoso

An empty triple store is not much fun, so let’s load some data into Virtuoso. There are several ways to do that, I’ll just describe one way here that works well for large files like the Geonames dump in N-Triples format I’m loading here.

  1. In order to load a local RDF file into Virtuoso, it needs access to the directory holding that file. The clean solution is to add that directory to the DirsAllowed in virtuoso.ini and restart Virtuoso. I’ll take the quick and dirty approach here and simply move the file from my Downloads folder to the folder holding our virtuoso.ini by running
    mv ~/Downloads/geonames.nt /usr/local/Cellar/virtuoso/7.1.0/var/lib/virtuoso/db/geonames.nt
  2. Next, we’ll start an SQL prompt by running
    isql

    You should see a new prompt now: SQL>

  3. On this SQL prompt, insert the following command to load the data into Virtuoso:
    DB.DBA.TTLP_MT (file_to_string_output ('./geonames.nt'), '', 'http://mytest.com');

    The second parameter is the URI of the graph we load the data into. It does not really matter what you put there, as long as it’s a valid URI.

If you’re trying to load a big file, the bulk loader functions are much faster. You should also change the settings for the NumberOfBuffers and MaxDirtyBuffers in virtuoso.ini to allow Virtuoso to use more RAM.

Querying Virtuoso

While we are waiting for Virtuoso to finish loading our dataset (which may take a while if you are loading a big dump like GeoNames), we can already run our first queries on the triples that have already been loaded. Go to http://localhost:8890/sparql and run a test query against the graph you are loading data into (http://mytest.com in my example above:

SELECT * WHERE {
 ?a ?b ?c
} LIMIT 10

This should give you ten random triples from the dataset you are loading.

Update 12/03/2014: You can also execute SPARQL commands on the isql prompt we have been using above to load data into Virtuoso. There are two ways to do that: If you are already on the isql prompt, you can just type SPARQL, followed by your query and a semicolon to finish the command (see below). This will list the results on the prompt. If you want to take the data out, e.g. to process them in other software, you can just put this command in a file, e.g. save

SPARQL SELECT * WHERE {
 ?a ?b ?c
} LIMIT 10;

in a file called query.sparql, and then on the command line (i.e., without logging into the isql prompt), run:

isql 127.0.0.1:1111 dba dba query.sparql > results.txt

Assuming you have not changed the Virtuoso standard port and username/password, this will save the results in a file called results.txt.

Shutting down Virtuoso

Shutting down Virtuoso correctly (rather than just killing the process) is important because otherwise you may have trouble starting it next time. For a clean shut down, open an SQL prompt (see above) and run

SHUTDOWN;

8 thoughts on “Virtuoso Open Source on Mac OS

  1. Hi, I did not manage to conclude successfully the procedure because when I try to start Virtuoso I get the error:
    17:23:08 GPF: page.c:2516 page_apply called with not enough stack
    GPF: page.c:2516 page_apply called with not enough stack
    17:23:08 Server received signal 11. Continuing with the default action for that signal.
    Segmentation fault: 11
    Found similar posts on forums I tried solving the issue by adding the parameters
    ServerThreadSize = 2 800 000
    MainThreadSize = 2 800 000
    into the file virtuoso.ini, but this did not help.
    Do you have an idea of what the issue might be and how I can solve it?

  2. Already had brew installed. Did a “brew update” and then ran “brew install virtuoso” — it reported a successful 7.2.4.2 install!! Went to /usr/local/Cellar/virtuoso/7.2.4.2/var/lib/virtuoso/db , ran virtuoso-t -f and everything ran first time. Thank you!!

Leave a Reply

Your email address will not be published. Required fields are marked *