<docbook><section><title>VirtGraphReplicationBiDirectional</title><title> Replication Example: 2-node Bi-directional Topology</title> Replication Example: 2-node Bi-directional Topology
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Introduction</bridgehead>
<para>The following Guide demonstrates the Virtuoso RDF Bi-directional Graph Replication, e.g., <figure><graphic fileref="VirtGraphReplicationBiDirectional/topo-bidirectional.png" /></figure></para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2">Prerequisites</bridgehead>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">Database INI Parameters</bridgehead>
<para>Suppose there are 2 Virtuoso instances respectively with the following ini parameters values:</para>
<orderedlist spacing="compact"><listitem>virtuoso1.ini: <programlisting>...
[Database]
DatabaseFile    = virtuoso1.db
TransactionFile = virtuoso1.trx
ErrorLogFile     = virtuoso1.log
...
[Parameters]
ServerPort               = 1111
SchedulerInterval        = 1
...
[HTTPServer]
ServerPort                  = 8891
...
[URIQA]
DefaultHost = localhost:8891
...
[Replication]
ServerName   = db1
...
</programlisting></listitem>
<listitem>virtuoso2.ini: <programlisting>...
[Database]
DatabaseFile    = virtuoso2.db
TransactionFile = virtuoso2.trx
ErrorLogFile     = virtuoso2.log
...
[Parameters]
ServerPort               = 1112
SchedulerInterval        = 1
...
[HTTPServer]
ServerPort                  = 8892
...
[URIQA]
DefaultHost = localhost:8892
...
[Replication]
ServerName   = db2
...
</programlisting></listitem>
</orderedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3">Database DSNs</bridgehead>
<para>Use the ODBC Administrator on your Virtuoso host (e.g., on Windows, <emphasis>Start</emphasis> menu -&gt; <emphasis>Control Panel</emphasis> -&gt; <emphasis>Administrative Tools</emphasis> -&gt; <emphasis>Data Sources (ODBC)</emphasis>; on Mac OS X, /Applications/Utilities/OpenLink ODBC Administrator.app) to create a System DSN for db1 and db2 with names db1 and db2 respectively.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3">Install Conductor package</bridgehead>
<para>On each of the 2 Virtuoso instances install the <ulink url="https://virtuoso.openlinksw.com/download/">conductor_dav.vad</ulink> package.</para>
<para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2">Create Publication on db2</bridgehead>
<orderedlist spacing="compact"><listitem>Go to <ulink url="http://localhost:8892/conductor">http://localhost:8892/conductor</ulink> and log in as dba </listitem>
<listitem>Go to Conductor -&gt; Replication -&gt; Transactional -&gt; Publications <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd1.png" /></figure> </listitem>
<listitem>Click <emphasis>Enable RDF Publishing</emphasis> </listitem>
<listitem>As result publication with the name <emphasis>RDF Publication</emphasis> should be created <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd2.png" /></figure> </listitem>
<listitem>Click the link which is the publication name.
</listitem>
<listitem>You will be shown the publication items page <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd3.png" /></figure> </listitem>
<listitem>Enter for Graph IRI: <programlisting>http://example.org
</programlisting><figure><graphic fileref="VirtGraphReplicationBiDirectional/bd4.png" /></figure> </listitem>
<listitem>Click Add New </listitem>
<listitem>The item will be created and shown in the list of items for the currently viewed publication.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd5.png" /></figure></listitem>
</orderedlist><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2">Create subscription from db1 to db2&#39;s Publication</bridgehead>
<orderedlist spacing="compact"><listitem>Log in at <ulink url="http://localhost:8891/conductor">http://localhost:8891/conductor</ulink> </listitem>
<listitem>Go to Replication -&gt; Transactional -&gt; Subscriptions <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd6.png" /></figure> </listitem>
<listitem>Click <emphasis>New Subscription</emphasis> <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd7.png" /></figure> </listitem>
<listitem>From the list of &quot;Specify new data source&quot; select Data Source db2 <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd8.png" /></figure> </listitem>
<listitem>Enter for db2 dba user credentials <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd9.png" /></figure> </listitem>
<listitem>Click &quot;Add Data Source&quot; </listitem>
<listitem>As result <emphasis>db2</emphasis> will be shown in the &quot;Connected Data Sources&quot; list.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd10.png" /></figure> </listitem>
<listitem>Select <emphasis>db2</emphasis> the &quot;Connected Data Sources&quot; list and click &quot;Publications list&quot; <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd11.png" /></figure> </listitem>
<listitem>As result will be shown the list of available publications for the selected data source.
 Select the one with name &quot;RDF Publication&quot; and click &quot;List Items&quot;.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd12.png" /></figure> </listitem>
<listitem>As result will be shown the &quot;Confirm subscription&quot; page.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd13.png" /></figure> </listitem>
<listitem>The sync interval by default is 10 minutes.
 For the testing purposes, we will change it to 1 minute.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd14.png" /></figure> </listitem>
<listitem>Click &quot;Subscribe&quot; </listitem>
<listitem>The subscription will be created.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd15.png" /></figure></listitem>
</orderedlist><bridgehead class="http://www.w3.org/1999/xhtml:h2">Create Publication on db1</bridgehead>
<orderedlist spacing="compact"><listitem>Go to <ulink url="http://localhost:8891/conductor">http://localhost:8891/conductor</ulink> and log in as dba </listitem>
<listitem>Go to Conductor -&gt; Replication -&gt; Transactional -&gt; Publications <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd16.png" /></figure> </listitem>
<listitem>Click <emphasis>Enable RDF Publishing</emphasis> </listitem>
<listitem>As result publication with the name <emphasis>RDF Publication</emphasis> should be created <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd17.png" /></figure> </listitem>
<listitem>Click the link which is the publication name.
</listitem>
<listitem>You will be shown the publication items page <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd18.png" /></figure> </listitem>
<listitem>Enter for Graph IRI: <programlisting>http://example.org
</programlisting><figure><graphic fileref="VirtGraphReplicationBiDirectional/bd19.png" /></figure> </listitem>
<listitem>Click Add New </listitem>
<listitem>The item will be created and shown in the list of items for the currently viewed publication.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd20.png" /></figure></listitem>
</orderedlist><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2">Create subscription from db2 to db1&#39;s Publication</bridgehead>
<orderedlist spacing="compact"><listitem>Log in at <ulink url="http://localhost:8892/conductor">http://localhost:8892/conductor</ulink> </listitem>
<listitem>Go to Replication -&gt; Transactional -&gt; Subscriptions <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd21.png" /></figure> </listitem>
<listitem>Click <emphasis>New Subscription</emphasis> <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd22.png" /></figure> </listitem>
<listitem>From the list of &quot;Specify new data source&quot; select Data Source db1 <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd23.png" /></figure> </listitem>
<listitem>Enter for db1 dba user credentials <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd24.png" /></figure> </listitem>
<listitem>Click &quot;Add Data Source&quot; <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd25.png" /></figure> </listitem>
<listitem>As result <emphasis>db1</emphasis> will be shown in the &quot;Connected Data Sources&quot; list.
 Select it and click &quot;Publications list&quot; <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd26.png" /></figure> </listitem>
<listitem>As result will be shown the list of available publications for the selected data source.
 Select the one with name &quot;RDF Publication&quot; and click &quot;List Items&quot;.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd27.png" /></figure> </listitem>
<listitem>As result will be shown the &quot;Confirm subscription&quot; page.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd28.png" /></figure> </listitem>
<listitem>The sync interval by default is 10 minutes.
 For the testing purposes, we will change it to 1 minute.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd29.png" /></figure> </listitem>
<listitem>Click &quot;Subscribe&quot; </listitem>
<listitem>The subscription will be created.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd30.png" /></figure></listitem>
</orderedlist><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2">Insert Data into a Named Graph on the db2 Virtuoso Instance</bridgehead>
<orderedlist spacing="compact"><listitem>Log in at <ulink url="http://localhost:8892/conductor">http://localhost:8892/conductor</ulink> </listitem>
<listitem>Go to Linked Data -&gt; Quad Store Upload <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd31.png" /></figure> </listitem>
<listitem>In the shown form: <orderedlist spacing="compact"><listitem>Tick the box for <emphasis>Resource URL</emphasis> and enter your resource URL, e.g.: <programlisting>http://www.openlinksw.com/dataspace/person/kidehen@openlinksw.com#this
</programlisting></listitem>
<listitem>Enter for Named Graph IRI: <programlisting>http://example.org
</programlisting><figure><graphic fileref="VirtGraphReplicationBiDirectional/bd32.png" /></figure> </listitem>
</orderedlist></listitem>
<listitem>Click Upload </listitem>
<listitem>A successful upload will result in a shown message.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd33.png" /></figure> </listitem>
<listitem>Check the count of the inserted triples by executing a query like the following against the SPARQL endpoint, <ulink url="http://localhost:8892/sparql:">http://localhost:8892/sparql:</ulink> <programlisting>SELECT COUNT(*) 
   FROM &lt;http://example.org&gt;
WHERE { ?s ?p ?o }
</programlisting><figure><graphic fileref="VirtGraphReplicationBiDirectional/bd34.png" /></figure> </listitem>
<listitem>Should return <emphasis>57</emphasis> as total.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd35.png" /></figure></listitem>
</orderedlist><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2">Check data on the Destination instance db1</bridgehead>
<orderedlist spacing="compact"><listitem>To check the starting count, execute from db1&#39;s SPARQL Endpoint: <programlisting>SELECT COUNT(*) 
   FROM &lt;http://example.org&gt;
WHERE { ?s ?p ?o }
</programlisting></listitem>
<listitem>Should return <emphasis>57</emphasis> as total.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd35.png" /></figure></listitem>
</orderedlist><bridgehead class="http://www.w3.org/1999/xhtml:h2">Add new data on db2</bridgehead>
<orderedlist spacing="compact"><listitem>Disconnect db1.
</listitem>
<listitem>On the Host Virtuoso Instance db2 go to Conductor -&gt; Database -&gt; Interactive SQL enter the following statement: <programlisting>SPARQL INSERT INTO GRAPH &lt;http://example.org&gt; 
  { 
     &lt;http://www.openlinksw.com/dataspace/person/kidehen@openlinksw.com#this&gt;
     &lt;http://xmlns.com/foaf/0.1/interest&gt;
     &lt;http://dbpedia.org/resource/Web_Services&gt; 
  } ;
</programlisting><figure><graphic fileref="VirtGraphReplicationBiDirectional/bd36.png" /></figure> </listitem>
<listitem>Click &quot;Execute&quot; </listitem>
<listitem>As result the triples will be inserted <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd37.png" /></figure> </listitem>
<listitem>Check the count of the destination instance graph&#39;s triples by executing the following query like against the SPARQL endpoint, <ulink url="http://localhost:8892/sparql:">http://localhost:8892/sparql:</ulink> <programlisting>SELECT COUNT(*) 
   FROM &lt;http://example.org&gt;
WHERE { ?s ?p ?o }
</programlisting></listitem>
<listitem>Should return <emphasis>58</emphasis> as total.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd38.png" /></figure></listitem>
</orderedlist><bridgehead class="http://www.w3.org/1999/xhtml:h2">Check data on the Destination instance db1</bridgehead>
<orderedlist spacing="compact"><listitem>Start instance db1 </listitem>
<listitem>To confirm that the triple count has increased by the number of inserted triples, execute the following statement on db1&#39;s SPARQL Endpoint: <programlisting>SELECT COUNT(*) 
   FROM &lt;http://example.org&gt;
WHERE { ?s ?p ?o }
</programlisting></listitem>
<listitem>Should return <emphasis>58</emphasis> as total.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd38.png" /></figure></listitem>
</orderedlist><bridgehead class="http://www.w3.org/1999/xhtml:h2">Add new data on db1</bridgehead>
<orderedlist spacing="compact"><listitem>Disconnect db2.
</listitem>
<listitem>On the Host Virtuoso Instance db1 go to Conductor -&gt; Database -&gt; Interactive SQL enter the following statement: <programlisting>SPARQL INSERT INTO GRAPH &lt;http://example.org&gt; 
  { 
    &lt;http://www.openlinksw.com/dataspace/person/kidehen@openlinksw.com#this&gt;  	
    &lt;http://xmlns.com/foaf/0.1/interest&gt;  	
    &lt;http://dbpedia.org/resource/Web_Clients&gt; 
  } ;
SPARQL INSERT INTO GRAPH &lt;http://example.org&gt; 
  { 
    &lt;http://www.openlinksw.com/dataspace/person/kidehen@openlinksw.com#this&gt;  	
    &lt;http://xmlns.com/foaf/0.1/interest&gt;  	
    &lt;http://dbpedia.org/resource/SPARQL&gt; 
  } ;
</programlisting><figure><graphic fileref="VirtGraphReplicationBiDirectional/bd39.png" /></figure> </listitem>
<listitem>Click &quot;Execute&quot; </listitem>
<listitem>As result the triples will be inserted <figure><graphic fileref="VirtGraphReplicationBiDirectional/bd40.png" /></figure> </listitem>
<listitem>Check the count of the destination instance graph&#39;s triples by executing the following query like against the SPARQL endpoint, <ulink url="http://localhost:8891/sparql:">http://localhost:8891/sparql:</ulink> <programlisting>SELECT COUNT(*) 
   FROM &lt;http://example.org&gt;
WHERE { ?s ?p ?o }
</programlisting></listitem>
<listitem>Should return <emphasis>60</emphasis> as total.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd41.png" /></figure></listitem>
</orderedlist><bridgehead class="http://www.w3.org/1999/xhtml:h2">Check data on the Destination instance db2</bridgehead>
<orderedlist spacing="compact"><listitem>Start instance db2 </listitem>
<listitem>To confirm that the triple count has increased by the number of inserted triples, execute the following statement on db2&#39;s SPARQL Endpoint: <programlisting>SELECT COUNT(*) 
   FROM &lt;http://example.org&gt;
WHERE { ?s ?p ?o }
</programlisting></listitem>
<listitem>Should return <emphasis>60</emphasis> as total.
<figure><graphic fileref="VirtGraphReplicationBiDirectional/bd41.png" /></figure></listitem>
</orderedlist><bridgehead class="http://www.w3.org/1999/xhtml:h2">Related</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="VirtGraphReplicationStar">Replication Example: Star Topology</ulink> </listitem>
<listitem><ulink url="VirtGraphReplicationChain">Replication Example: Chain Topology</ulink> </listitem>
<listitem><ulink url="VirtGraphReplicationPSQL">Set up RDF Replication via procedure calls</ulink> </listitem>
<listitem><ulink url="http://ods.openlinksw.com/wiki/ODS/VirtPubSubHub">Example of Linked Data Usage of PubSubHubbub Implementation</ulink> </listitem>
<listitem><ulink url="VirtRdfReplScenarios">Exploit Virtuoso&#39;s Replication Functionality Web based Solutions</ulink></listitem>
</itemizedlist></section></docbook>