<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nguyen Viet Bach on Medium]]></title>
        <description><![CDATA[Stories by Nguyen Viet Bach on Medium]]></description>
        <link>https://medium.com/@nvbach91?source=rss-a5c51ed2396a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*azmoj5eoOeL3HSmu.</url>
            <title>Stories by Nguyen Viet Bach on Medium</title>
            <link>https://medium.com/@nvbach91?source=rss-a5c51ed2396a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 15:43:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nvbach91/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to reclaim disk space from Blazegraph]]></title>
            <link>https://medium.com/@nvbach91/how-to-reclaim-disk-space-in-blazegraph-95a47575f8a8?source=rss-a5c51ed2396a------2</link>
            <guid isPermaLink="false">https://medium.com/p/95a47575f8a8</guid>
            <category><![CDATA[rdf]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[triplestore]]></category>
            <category><![CDATA[sparql]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[Nguyen Viet Bach]]></dc:creator>
            <pubDate>Tue, 20 Sep 2022 22:24:48 GMT</pubDate>
            <atom:updated>2022-09-21T09:06:34.498Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hhSYtx6vFDDsXUlUgCB7ow.png" /><figcaption>Blazegraph workbench logo</figcaption></figure><p>Blazegraph is a triplestore database used to store graph data. It can be used to deploy a SPARQL endpoint for querying. One of the frequent questions regarding the performance of databases is how much disk space is required to store data on the server.</p><p>Blazegraph uses a <a href="https://github.com/blazegraph/database/wiki/PerformanceOptimization">journaling system</a>. Data is basically stored inside a journal file. By default, it is called bigdata.jnl located in the home directory, or wherever Blazegraph is run from, e.g. <a href="https://nvbach.blogspot.com/2019/04/installing-blazegraph-on-linux-debian.html">in a Tomcat container</a></p><p>The disadvantage of using a journaling system for database file storage is that the journal file is an append-only data structure. A write on the B+Tree never overwrites the old data. Instead, it writes a new revision of the node of leaf. This means that if we decide to remove a dataset or delete some data from the database, the journal file size will not become smaller, and the disk space will not be freed.</p><p>There are <a href="https://sourceforge.net/p/bigdata/discussion/676946/thread/852d40e0/">two possible ways</a> to reclaim disk space. It is either to 1) export/dump all data and reupload everything, or 2) shrink this journal file via an optimization process.</p><p>Dumping data (you can use maybe <a href="https://github.com/balhoff/blazegraph-runner">blazegraph-runner tool</a> to create a dump) can be troublesome, especially for large datasets and when there are multiple namespaces in the same Blazegraph instance.</p><p>So, let’s see how we can shrink the journal file without losing any data.</p><p>First, let’s check how big the journal file is:</p><pre>$&gt; ls -laSh /etc/blazegraph/<br>-rw-rw----   1 tomcat tomcat  <strong>28G</strong> Sep 20 17:22 bigdata.jnl<br>drwxr-xr-x 105 root   root    12K Sep 12 12:02 ..<br>drwxr-xr-x   2 tomcat root   4.0K Sep 21 00:05 .</pre><p>It’s quite big. Now, imagine we have just removed an unused large dataset from Blazegraph (either by SPARQL Update or by deleting a namespace in the workbench). But the journal file size has not changed one bit.</p><pre>SPARQL: DROP GRAPHS<br>---<br>$&gt; ls -laSh /etc/blazegraph/<br>-rw-rw----   1 tomcat tomcat  28G Sep 20 17:22 bigdata.jnl<br>drwxr-xr-x 105 root   root    12K Sep 12 12:02 ..<br>drwxr-xr-x   2 tomcat root   4.0K Sep 21 00:05 .</pre><p><strong>So how can we reclaim disk space from Blazegraph?</strong></p><p>In the Blazegraph implementation GitHub repository there is an old utility class CompactJournalUtility.javathat says:</p><blockquote>Compacts the source journal, writing a new journal containing <strong>only the most current committed view</strong> onto the specified output file.</blockquote><p><strong>Perfect</strong>. Now let’s run it:</p><p>Prerequisites:</p><ul><li>Java JDK 8 (I used OpenJDK 1.8.0_332)</li><li>Apache Maven (I used Maven 3.6.3)</li></ul><p>STEP 1: clone the project (you might wanna read the gotchas at the end of this post after this step)</p><pre>$&gt; git clone <a href="https://github.com/blazegraph/database.git">https://github.com/blazegraph/database.git</a></pre><p>STEP 2: modify the code of CompactJournalUtility.java</p><pre>$&gt; cd database<br>$&gt; nano bigdata-core/bigdata/src/java/com/bigdata/journal/CompactJournalUtility.java</pre><p>—</p><pre>static public void main(final String[] args) {</pre><pre>//change to</pre><pre>public static void main(final String[] args) {</pre><p>STEP 3: build the project</p><pre>$&gt; ./scripts/mavenInstall.sh<br>$&gt; cd bigdata-core<br>$&gt; mvn install</pre><p>STEP 4: create a script to run the CompactJournalUtility class</p><pre>$&gt; cd ..<br>$&gt; nano ./scripts/compactJournal.sh</pre><p>—</p><pre>#!/bin/bash</pre><pre>BASE_DIR=`dirname $0`</pre><pre>${BASE_DIR}/prog.sh com.bigdata.journal.CompactJournalUtility $*</pre><p>STEP 5: go to sudo mode and stop Blazegraph</p><pre>$&gt; sudo bash<br>$&gt; systemctl stop tomcat</pre><p>STEP 6: run the script with the journal file paths (you may need that sudo)</p><pre>$&gt; ./scripts/compactJournal.sh /etc/blazegraph/bigdata.jnl /etc/blazegraph/bigdata.jnl.compact</pre><p>— the magic happens</p><pre>BlazeGraph(TM) Graph Engine</pre><pre>Flexible<br>                   Reliable<br>                  Affordable<br>      Web-Scale Computing for the Enterprise</pre><pre>Copyright SYSTAP, LLC DBA Blazegraph 2006-2016.  All rights reserved.</pre><pre>...</pre><pre>...<br>Linux/5.10.0-17-amd64 amd64<br>Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz Family 6 Model 79 Stepping 1, GenuineIntel #CPU=4<br>Oracle Corporation 1.8.0_332<br>freeMemory=128974224<br>buildVersion=2.1.6-SNAPSHOT<br>gitCommit=3127706f0b6504838daae226b9158840d2df1744</pre><pre>Dependency         License<br>ICU                <a href="http://source.icu-project.org/repos/icu/icu/trunk/license.html">http://source.icu-project.org/repos/icu/icu/trunk/license.html</a><br>bigdata-ganglia    <a href="http://www.apache.org/licenses/LICENSE-2.0.html">http://www.apache.org/licenses/LICENSE-2.0.html</a><br>...<br>slf4j              <a href="http://www.slf4j.org/license.html">http://www.slf4j.org/license.html</a><br>zookeeper          <a href="http://www.apache.org/licenses/LICENSE-2.0.html">http://www.apache.org/licenses/LICENSE-2.0.html</a></pre><pre>source: nbytes=......., nindices=11<br>Running: Tue Sep 20 ........ CEST ....<br>Success: Tue Sep 20 ........ CEST ....<br>bytes used: before=......., after=....., <strong>reducedBy=72%</strong></pre><p>STEP 7: check the reduced file</p><pre>$&gt; ls -laSh /etc/blazegraph/<br>-rw-rw----   1 tomcat tomcat  <strong>28G </strong>Sep 20 17:22 bigdata.jnl<br>-rw-r--r--   1 root   root   <strong>6.7G</strong> Sep 20 23:15 bigdata.jnl.compact<br>drwxr-xr-x 105 root   root    12K Sep 12 12:02 ..<br>drwxr-xr-x   2 tomcat root   4.0K Sep 20 23:51 .</pre><p>As you can see, from 28GB we got it reduced to 6.7G, which is a 72% reduction and we have reclaimed 21GB of disk space! Was it worth it? I think so.</p><p>STEP 8: swap the journal files to start using the new reduced file</p><pre>$&gt; cd /etc/blazegraph<br>$&gt; mv bigdata.jnl bigdata.jnl.original<br>$&gt; mv bigdata.jnl.compact bigdata.jnl<br>$&gt; chown tomcat:tomcat bigdata.jnl<br>$&gt; chmod 660 bigdata.jnl<br>$&gt; ls -laSh<br>-rw-rw----   1 tomcat tomcat  <strong>28G </strong>Sep 20 17:22 bigdata.jnl.original<br>-rw-rw----   1 tomcat tomcat <strong>6.7G</strong> Sep 20 23:15 bigdata.jnl<br>drwxr-xr-x 105 root   root    12K Sep 12 12:02 ..<br>drwxr-xr-x   2 tomcat root   4.0K Sep 21 00:05 .<br>$&gt; systemctl start tomcat</pre><p>STEP 10: check your Blazegraph workbench</p><figure><img alt="Blazegraph Workbench UI still shows the original namespaces" src="https://cdn-images-1.medium.com/max/929/1*nWsCLl9MeBqsW8XegRmRwg.png" /></figure><p>Thank goodness we still have our data intact.</p><p>Now we can remove that old journal file.</p><pre>$&gt; rm bigdata.jnl.original</pre><p>Done. Happy hacking, my friends.</p><p>P.S.: Gotchas! After cloning the git repository of Blazegraph, revert to a previous version that matches your Blazegraph instance (using git reset &lt;commit-id&gt; ). Otherwise, STEP 6 may fail (you will understand the error log though).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95a47575f8a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create Let’s Encrypt’s free wildcard SSL certificates — for Windows Server IIS web servers]]></title>
            <link>https://medium.com/@nvbach91/how-to-create-lets-encrypt-s-free-wildcard-ssl-certificates-for-windows-server-iis-web-servers-aa01d939e0ad?source=rss-a5c51ed2396a------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa01d939e0ad</guid>
            <category><![CDATA[ssl-certificate]]></category>
            <category><![CDATA[windows-server]]></category>
            <category><![CDATA[lets-encrypt]]></category>
            <category><![CDATA[certbot]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Nguyen Viet Bach]]></dc:creator>
            <pubDate>Wed, 17 Jun 2020 15:04:12 GMT</pubDate>
            <atom:updated>2022-08-26T10:15:57.677Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to create Let’s Encrypt’s free wildcard SSL certificates — for Windows IIS web servers</h3><p>I’ve been using sslforfree.com for years now to generate wildcard certificates for my servers. But recently, they joined ZeroSSL and this feature is now accessible only in a paid plan. But I don’t wanna spend money on something that should be free for everyone.</p><p>I did some digging and found an alternative solution quite easily. It’s called <a href="https://certbot.eff.org/"><strong>certbot</strong></a><strong>.</strong> It helps us generate wildcard certificates issued by Let’s Encrypt for our Windows servers in a matter of minutes. The following instructions will guide you through the whole process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*DGfono2LOLNpEjdblp6m8g.png" /><figcaption>Certbot logo</figcaption></figure><p><strong>Step 1</strong>: Install <strong>certbot </strong>for Windows</p><ul><li>Download it from <a href="https://dl.eff.org/certbot-beta-installer-win32.exe">https://dl.eff.org/certbot-beta-installer-win32.exe</a> / <a href="https://certbot.eff.org/instructions?ws=other&amp;os=windows">https://certbot.eff.org/instructions?ws=other&amp;os=windows</a></li><li>The installation will make <strong>certbot</strong> accessible via the command line</li></ul><p><strong>Step 2</strong>: Install <strong>openssl </strong>(to convert the .pemcertificates to .pfx format)</p><ul><li>Download it from <a href="https://slproweb.com/products/Win32OpenSSL.html">https://slproweb.com/products/Win32OpenSSL.html</a> (use the “non-light” version)</li><li>Put it in your system Path so it’s accessible via the command line (<a href="https://stackoverflow.com/questions/4822400/register-an-exe-so-you-can-run-it-from-any-command-line-in-windows">https://stackoverflow.com/questions/4822400/register-an-exe-so-you-can-run-it-from-any-command-line-in-windows</a>)</li></ul><p><strong>Step 3</strong>: Generate the wildcard certificate using <strong>certbot</strong></p><ul><li>Open an elevated command line (with administrator privileges) and run:</li></ul><pre><strong>C:\...\cert&gt; certbot </strong>certonly --manual --preferred-challenges=dns   --email <strong><em>me@mail.com</em></strong> --server <a href="https://acme-v02.api.letsencrypt.org/directory">https://acme-v02.api.letsencrypt.org/directory</a> -d <strong><em>*.domain.org</em></strong> -d <strong><em>domain.org</em></strong></pre><ul><li>Provide your own email after the <strong>--email</strong>param and domain name after the two <strong>-d</strong> flags. For the sake of this tutorial, we will be using the domain “<strong>domain.org</strong>” and its subdomains “<strong>*.domain.org</strong>”. Please note that we want the certificate to be issued to cover all subdomains and also the domain itself, so we need to specify two values here (one with the asterisk and one without).</li><li>Agree to all terms and questions (Yes/Agree)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*71ZX-_pFDiBwbRPiW7iU7Q.png" /><figcaption>Screenshot 1: Certbot in action</figcaption></figure><ul><li>Certbot will show you <strong>two DNS TXT records</strong> (based on how many domains you gave it) which you must deploy under the<strong>_acme-challenge</strong> subdomain in order to verify the ownership of your domain. This is usually achieved using a management system of your domain hosting provider in the DNS configuration.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*MtHUhuxo_ybOgtcgEXwmYw.png" /><figcaption>Create and edit <strong>_acme-challenge TXT DNS records </strong>via the web UI of your hosting provider</figcaption></figure><ul><li>It might take some time (based on the TXT record time-to-tive — TTL) before the TXT records are fully propagated after saving. If you can, make sure you set the shortest possible TTL for these TXT records.</li><li>To check the availability of the TXT records and verify them, you can use the <strong>nslookup</strong>command in a separate command line window (or a web service like <a href="http://mxtoolbox.com/">mxtoolbox.com</a>) and make sure the two active TXT records are exactly the same as the ones displayed in the first command line by <strong>certbot</strong>. The order of these TXT records is not important.</li></ul><pre><strong>C:\Users\Admin&gt; nslookup </strong>-type=txt _acme-challenge.domain.org</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*zgeWV_y4MjO2IVOl51tv_w.png" /><figcaption>Screenshot 2: Manual verification of the DNS TXT records</figcaption></figure><ul><li>After that, press Enter in the first command line to continue. If the verification was successful. Your certificates will be generated a put in the installation directory of <strong>certbot</strong>. By default, it’s located in <strong>C:\Certbot\live\domain.org\</strong></li></ul><p><strong>Step 4</strong>: Convert the certificates from .pem to .pfx and import it</p><ul><li>In that folder, you will find a bunch of .pem files, which must be converted and combined into one .pfx file before importing to IIS. To do so, use the following commands:</li></ul><pre>C:\Certbot\live\domain.org&gt; <strong>type </strong>fullchain.pem privkey.pem &gt; bundle.pem<br>C:\Certbot\live\domain.org&gt; <strong>openssl </strong>pkcs12 -export -out &quot;certificate_combined.pfx&quot; -inkey &quot;privkey.pem&quot; -in &quot;cert.pem&quot; -certfile bundle.pem</pre><ul><li>Provide a password when prompted by <strong>openssl</strong>.</li><li>Use the .pfx file to import the certificate to your system and bind it to your website in IIS.</li></ul><p>And that’s all.</p><p><strong>BROTIP</strong>: The commands in the command line can be partly automated using the following batch script (just replace the domain value at the beginning with your domain):</p><pre>set dm=domain.org</pre><pre>certbot certonly --manual --preferred-challenges=dns --email <a href="/service/mailto:nvbach91@gmail.com">me@mail.com</a> --server <a href="https://acme-v02.api.letsencrypt.org/directory">https://acme-v02.api.letsencrypt.org/directory</a> -d *.%dm% -d %dm%</pre><pre>cd C:\Certbot\live\%dm%</pre><pre>type fullchain.pem privkey.pem &gt; bundle.pem</pre><pre>openssl pkcs12 -export -out &quot;certificate_combined.pfx&quot; -inkey &quot;privkey.pem&quot; -in &quot;cert.pem&quot; -certfile bundle.pem<br>certificate_combined.pfx</pre><p>Hope you found this article helpful.</p><p>Greetings from Prague</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa01d939e0ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>