<?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 Hugh Kaznowski on Medium]]></title>
        <description><![CDATA[Stories by Hugh Kaznowski on Medium]]></description>
        <link>https://medium.com/@hugh_surrealdb?source=rss-7d6039b9f35b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*7Wxn2_Yv9tmi9aa8b5epAg.jpeg</url>
            <title>Stories by Hugh Kaznowski on Medium</title>
            <link>https://medium.com/@hugh_surrealdb?source=rss-7d6039b9f35b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 08:50:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hugh_surrealdb/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[Clustered SurrealDB for 1.0.0-beta9]]></title>
            <link>https://medium.com/surrealdb/clustered-surrealdb-for-1-0-0-beta9-4d5d0da0348f?source=rss-7d6039b9f35b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d5d0da0348f</guid>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[surrealdb]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[clustering]]></category>
            <dc:creator><![CDATA[Hugh Kaznowski]]></dc:creator>
            <pubDate>Wed, 26 Apr 2023 12:38:47 GMT</pubDate>
            <atom:updated>2023-04-26T13:01:18.078Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NfM0q2YhxxgEGvsZTSRfyA.jpeg" /></figure><p>In this post, I will show you how to set up a distributed SurrealDB cluster that shares a distributed TiKV cluster.<br>This architecture allows you to scale your operations to improve writes and reads and seamlessly continue operations during failures.</p><h3>Introduction and architecture overview</h3><p>Users of SurrealDB can pick which Key-Value storage engines they want to use.<br>That means that for single deployment, you can use RocksDB or in-memory storage; for distributed storage, you can use TiKV and FoundationDB.</p><p>We will deploy a cluster of TiKV that includes 3 TiKV instances (the KV engine) and 3 PD instances (placement driver, a resource tracking service).<br>In addition to the above configuration, we will deploy three nodes of SurrealDB that will point to their respective KV engines.<br>Typically you would want the SurrealDB instances not tied to individual TiKV instances, but that would require a load balancer — something beyond the scope of this article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*tuqLodb6UEjz96RV.jpg" /></figure><h3>Setting up the environment</h3><p>Because we need access to 6 machines, we will simplify this setup using LXC — a lightweight Linux container system that makes nodes seem like fully-fledged computers.</p><p><strong>An important note</strong>: LXC does not play nice with docker.<br>There are ways around that, but I removed docker from my host machine for this example.<br>It’s a VM; usually, you wouldn’t host this environment this way anyway.</p><p>Let’s start by running and configuring our first LXC container for usage.</p><pre>hugh@hugh-VirtualBox:~$ lxc launch ubuntu: lxc-node-tikv-1</pre><pre>Creating lxc-node-tikv-1<br>Starting lxc-node-tikv-1</pre><pre>hugh@hugh-VirtualBox:~$ lxc exec lxc-node-tikv-1 bash<br>root@lxc-node-tikv-1:~# apt install openssh-server<br>...<br>root@lxc-node-tikv-1:~# curl --proto &#39;=https&#39; --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh</pre><pre>% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current<br>                                 Dload  Upload   Total   Spent    Left  Speed<br>100 7088k  100 7088k    0     0  2571k      0  0:00:02  0:00:02 --:--:-- 2570k<br>WARN: adding root certificate via internet: https://tiup-mirrors.pingcap.com/root.json<br>You can revoke this by remove /root/.tiup/bin/7b8e153f2e2d0928.root.json<br>Successfully set mirror to https://tiup-mirrors.pingcap.com<br>Detected shell:<br>Shell profile:  /root/.profile<br>/root/.profile has been modified to add tiup to PATH<br>open a new terminal or source /root/.profile to use it<br>Installed path: /root/.tiup/bin/tiup<br>===============================================<br>Have a try:     tiup playground<br>===============================================</pre><pre>root@lxc-node-tikv-1:~# sudo useradd -m hugh<br>root@lxc-node-tikv-1:~# sudo adduser hugh sudo</pre><pre>Adding user `hugh&#39; to group `sudo&#39; ...<br>Adding user hugh to group sudo<br>Done.</pre><pre>root@lxc-node-tikv-1:~# sudo passwd hugh</pre><pre>New password:<br>Retype new password:<br>passwd: password updated successfully</pre><pre>root@lxc-node-tikv-1:~# sudo visudo # Over here I replaced the sudo entry line with &quot;%sudo ALL=(ALL) NOPASSWD:ALL&quot;, so added NOPASSWD<br>root@lxc-node-tikv-1:~# vim /etc/ssh/sshd_config<br># Change the following lines<br># PasswordAuthentication yes<br>root@lxc-node-tikv-1:~# source .profile<br>root@lxc-node-tikv-1:~# tiup cluster</pre><pre>tiup is checking updates for component cluster ...timeout(2s)!<br>The component `cluster` version  is not installed; downloading from repository.<br>download https://tiup-mirrors.pingcap.com/cluster-v1.11.3-linux-amd64.tar.gz 8.44 MiB / 8.44 MiB 100.00% 396.61 MiB/s<br>Starting component `cluster`: /root/.tiup/components/cluster/v1.11.3/tiup-cluster<br>Deploy a TiDB cluster for production<br>...</pre><pre>root@lxc-node-tikv-1:~# tiup update --self &amp;&amp; tiup update cluster<br>download https://tiup-mirrors.pingcap.com/tiup-v1.11.3-linux-amd64.tar.gz 6.92 MiB / 6.92 MiB 100.00% 171.31 MiB/s<br>Updated successfully!<br>component cluster version v1.11.3 is already installed<br>Updated successfully!</pre><pre>root@lxc-node-tikv-1:~# tiup cluster template &gt; topology.yaml</pre><pre>tiup is checking updates for component cluster ...<br>Starting component `cluster`: /root/.tiup/components/cluster/v1.11.3/tiup-cluster template</pre><p>Great!<br>We now have our initial node ready.<br>We need to modify our topology file to reflect the actual topology we will have.<br>Here is the sample I have from editing the topology.yaml we just exported.</p><pre># # Global variables are applied to all deployments and used as the default value of<br># # the deployments if a specific deployment value is missing.<br>global:<br>  # # The user who runs the tidb cluster.<br>  user: &quot;hugh&quot;<br>  # # group is used to specify the group name the user belong to if it&#39;s not the same as user.<br>  # group: &quot;tidb&quot;<br>  # # SSH port of servers in the managed cluster.<br>  ssh_port: 22<br>  # # Storage directory for cluster deployment files, startup scripts, and configuration files.<br>  deploy_dir: &quot;/tidb-deploy&quot;<br>  # # TiDB Cluster data storage directory<br>  data_dir: &quot;/tidb-data&quot;<br>  arch: &quot;amd64&quot;</pre><pre># # Monitored variables are applied to all the machines.<br>monitored:<br>  # # The communication port for reporting system information of each node in the TiDB cluster.<br>  node_exporter_port: 9100<br>  # # Blackbox_exporter communication port, used for TiDB cluster port monitoring.<br>  blackbox_exporter_port: 9115</pre><pre># # Server configs are used to specify the configuration of PD Servers.<br>pd_servers:<br>  # # The ip address of the PD Server.<br>  - host: lxc-node-pd-1<br>  - host: lxc-node-pd-2<br>  - host: lxc-node-pd-3</pre><pre># # Server configs are used to specify the configuration of TiKV Servers.<br>tikv_servers:<br>  # # The ip address of the TiKV Server.<br>  - host: lxc-node-tikv-1<br>  - host: lxc-node-tikv-2<br>  - host: lxc-node-tikv-3</pre><p>That is actually my entire topology.yaml file.<br>I removed TiDB and all the monitoring — we aren’t using that for this example.</p><p>We will create a snapshot from the image to simplify our setup and start the installation.<br>We will then create instances that automatically have SSH, the hugh account with a known password, and a sudo group permission without password authentication.<br>Don’t do this in production — this is a highly insecure setup for many reasons.</p><pre>root@lxc-node-tikv-1:~# shutdown -r 0<br>hugh@hugh-VirtualBox:~$ lxc snapshot lxc-node-tikv-1 base-installation-tikv<br>hugh@hugh-VirtualBox:~$ lxc publish lxc-node-tikv-1/base-installation-tikv --alias base-installation-tikv</pre><pre>Instance published with fingerprint: b8841a679a59f98f3c23ba6c8795c84942f19170b4a8c41eb102130467c4cca6</pre><pre>hugh@hugh-VirtualBox:~$ printf &quot;lxc-node-tikv-2\n lxc-node-tikv-3\n lxc-node-pd-1\n lxc-node-pd-2\n lxc-node-pd-3&quot; | xargs -I % lxc launch base-installation-tikv %</pre><pre>Creating lxc-node-tikv-2<br>Starting lxc-node-tikv-2<br>Creating lxc-node-tikv-3<br>Starting lxc-node-tikv-3<br>Creating lxc-node-pd-1<br>Starting lxc-node-pd-1<br>Creating lxc-node-pd-2<br>Starting lxc-node-pd-2<br>Creating lxc-node-pd-3<br>Starting lxc-node-pd-3</pre><p>We can now start our cluster from the first node we configured.<br>TiUp will connect to all the other nodes via SSH and password authentication and install the services that way.</p><pre>hugh@hugh-VirtualBox:~$ lxc exec lxc-node-tikv-1 bash<br>root@lxc-node-tikv-1:~# source .profile<br>root@lxc-node-tikv-1:~# tiup cluster deploy tikv-test v6.6.0 ./topology.yaml --user hugh -p</pre><pre>tiup is checking updates for component cluster ...<br>Starting component `cluster`: /root/.tiup/components/cluster/v1.11.3/tiup-cluster deploy tikv-test v6.6.0 ./topology.yaml --user hugh -p<br>Input SSH password:</pre><pre>+ Detect CPU Arch Name<br>+ Detect CPU Arch Name<br>  - Detecting node lxc-node-pd-1 Arch info ... Done<br>  - Detecting node lxc-node-pd-2 Arch info ... Done<br>  - Detecting node lxc-node-pd-3 Arch info ... Done<br>  - Detecting node lxc-node-tikv-1 Arch info ... Done<br>  - Detecting node lxc-node-tikv-2 Arch info ... Done<br>  - Detecting node lxc-node-tikv-3 Arch info ... Done</pre><pre>+ Detect CPU OS Name<br>+ Detect CPU OS Name<br>  - Detecting node lxc-node-pd-1 OS info ... Done<br>  - Detecting node lxc-node-pd-2 OS info ... Done<br>  - Detecting node lxc-node-pd-3 OS info ... Done<br>  - Detecting node lxc-node-tikv-1 OS info ... Done<br>  - Detecting node lxc-node-tikv-2 OS info ... Done<br>  - Detecting node lxc-node-tikv-3 OS info ... Done<br>Please confirm your topology:<br>Cluster type:    tidb<br>Cluster name:    tikv-test<br>Cluster version: v6.6.0<br>Role  Host             Ports        OS/Arch       Directories<br>----  ----             -----        -------       -----------<br>pd    lxc-node-pd-1    2379/2380    linux/x86_64  /tidb-deploy/pd-2379,/tidb-data/pd-2379<br>pd    lxc-node-pd-2    2379/2380    linux/x86_64  /tidb-deploy/pd-2379,/tidb-data/pd-2379<br>pd    lxc-node-pd-3    2379/2380    linux/x86_64  /tidb-deploy/pd-2379,/tidb-data/pd-2379<br>tikv  lxc-node-tikv-1  20160/20180  linux/x86_64  /tidb-deploy/tikv-20160,/tidb-data/tikv-20160<br>tikv  lxc-node-tikv-2  20160/20180  linux/x86_64  /tidb-deploy/tikv-20160,/tidb-data/tikv-20160<br>tikv  lxc-node-tikv-3  20160/20180  linux/x86_64  /tidb-deploy/tikv-20160,/tidb-data/tikv-20160<br>Attention:<br>    1. If the topology is not what you expected, check your yaml file.<br>    2. Please confirm there is no port/directory conflicts in same host.<br>Do you want to continue? [y/N]: (default=N) y<br>...<br>Cluster `tikv-test` deployed successfully, you can start it with command: `tiup cluster start tikv-test --init`</pre><pre>root@lxc-node-tikv-1:~# tiup cluster start tikv-test --init</pre><pre>tiup is checking updates for component cluster ...<br>Starting component `cluster`: /root/.tiup/components/cluster/v1.11.3/tiup-cluster start tikv-test --init<br>Starting cluster tikv-test...<br>+ [ Serial ] - SSHKeySet: privateKey=/root/.tiup/storage/cluster/clusters/tikv-test/ssh/id_rsa, publicKey=/root/.tiup/storage/cluster/clusters/tikv-test/ssh/id_rsa.pub<br>+ [Parallel] - UserSSH: user=hugh, host=lxc-node-tikv-2<br>+ [Parallel] - UserSSH: user=hugh, host=lxc-node-pd-3<br>+ [Parallel] - UserSSH: user=hugh, host=lxc-node-pd-2<br>+ [Parallel] - UserSSH: user=hugh, host=lxc-node-tikv-3<br>+ [Parallel] - UserSSH: user=hugh, host=lxc-node-tikv-1<br>+ [Parallel] - UserSSH: user=hugh, host=lxc-node-pd-1<br>+ [ Serial ] - StartCluster<br>...<br>Started cluster `tikv-test` successfully<br>The root password of TiDB database has been changed.<br>The new password is: &#39;JuEzYp59+8@$20T_3K&#39;.<br>Copy and record it to somewhere safe, it is only displayed once, and will not be stored.<br>The generated password can NOT be get and shown again.</pre><p>At this point, you should have a running TiKV cluster.<br>All that remains is to put SurrealDB instances on the PD nodes.<br>I will demonstrate this only for a single PD node, as the rest are identical.</p><pre>root@lxc-node-pd-1:~# curl --proto &#39;=https&#39; --tlsv1.2 -sSf https://install.surrealdb.com | sh -s -- --nightly</pre><pre>.d8888b.                                             888 8888888b.  888888b.<br>d88P  Y88b                                            888 888  &#39;Y88b 888  &#39;88b<br>Y88b.                                                 888 888    888 888  .88P<br> &#39;Y888b.   888  888 888d888 888d888  .d88b.   8888b.  888 888    888 8888888K.<br>    &#39;Y88b. 888  888 888P&#39;   888P&#39;   d8P  Y8b     &#39;88b 888 888    888 888  &#39;Y88b<br>      &#39;888 888  888 888     888     88888888 .d888888 888 888    888 888    888<br>Y88b  d88P Y88b 888 888     888     Y8b.     888  888 888 888  .d88P 888   d88P<br> &#39;Y8888P&#39;   &#39;Y88888 888     888      &#39;Y8888  &#39;Y888888 888 8888888P&#39;  8888888P&#39;</pre><pre>Fetching the latest database version...<br>Fetching the host system architecture...<br>Installing surreal-nightly for linux-amd64...<br></pre><pre>SurrealDB successfully installed in:<br>  /root/.surrealdb/surreal</pre><pre>To ensure that surreal is in your $PATH run:<br>  PATH=/root/.surrealdb:$PATH<br>Or to move the binary to --nightly run:<br>  sudo mv /root/.surrealdb/surreal --nightly</pre><pre>To see the command-line options run:<br>  surreal help<br>To start an in-memory database server run:<br>  surreal start --log debug --user root --pass root memory<br>For help with getting started visit:<br>  <a href="https://surrealdb.com/docs">https://surrealdb.com/docs</a></pre><pre>root@lxc-node-pd-1:~# PATH=/root/.surrealdb:$PATH<br>root@lxc-node-pd-1:~# surreal sql --ns testns --db testdb -u root -p root --conn tikv://lxc-node-pd-1:2379</pre><pre>testns/testdb&gt; create person:hugh content {name:&#39;test&#39;}<br>[{&quot;id&quot;:&quot;person:hugh&quot;,&quot;name&quot;:&quot;test&quot;}]<br>testns/testdb&gt; select * from person<br>[{&quot;id&quot;:&quot;person:hugh&quot;,&quot;name&quot;:&quot;test&quot;}]</pre><p>Under a real scenario, you would have the SurrealDB nodes separate from the PD nodes, and the connections would be load balanced across the entire PD node pool.</p><h3>Takeaways</h3><p>As you can see, it is possible to set up SurrealDB in a cluster so that writes and reads can scale.<br>Failure of a single node would have minimal disruption to the rest of the work while keeping your data intact.<br>Backups can be performed against the TiKV cluster to ensure you can recover in the event of serious failures.</p><p>Hopefully, you found this guide helpful, and I look forward to hearing what you get up to with it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d5d0da0348f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/surrealdb/clustered-surrealdb-for-1-0-0-beta9-4d5d0da0348f">Clustered SurrealDB for 1.0.0-beta9</a> was originally published in <a href="https://medium.com/surrealdb">SurrealDB</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Started a Medium account]]></title>
            <link>https://medium.com/@hugh_surrealdb/started-a-medium-account-286f8d39a594?source=rss-7d6039b9f35b------2</link>
            <guid isPermaLink="false">https://medium.com/p/286f8d39a594</guid>
            <category><![CDATA[blogging]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[surrealdb]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Hugh Kaznowski]]></dc:creator>
            <pubDate>Wed, 08 Feb 2023 14:55:55 GMT</pubDate>
            <atom:updated>2023-02-08T15:06:42.475Z</atom:updated>
            <content:encoded><![CDATA[<p>I have started a medium account so that I can get the benefits of using Medium, but at the same time, I mainly publish at <a href="https://phughk.github.io/">https://phughk.github.io</a> and <a href="https://blog.hughkaznowski.com/">https://blog.hughkaznowski.com</a> .</p><p>A lot of my writing will be the same on all the platforms (sometimes I may selectively publish on a few platforms). But overall, it is the same — I just want the benefits of people being able to subscribe where they prefer.</p><p>I write about SurrealDB, Databases, Distributed Systems (algorithms, concepts, papers, products), Rust Language, and whatever would take my fancy.</p><p>Hobbies include nerd stuff — MTG, 40k, running, photography, classical piano, psychology.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=286f8d39a594" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>