Installing XTDB
XTDB can run in-process, or through traditional client-server connections.
Client/Server
You can start the XTDB server using Docker:
docker pull ghcr.io/xtdb/xtdb-ea
docker run -tip 3000:3000 ghcr.io/xtdb/xtdb-ea
Then, add the thin client to your deps.edn
:
;; deps.edn
{:mvn/repos {"ossrh-snapshots" {:url "https://s01.oss.sonatype.org/content/repositories/snapshots"}}
:deps {org.clojure/clojure {:mvn/version "1.11.1"}
com.xtdb.labs/xtdb-api {:mvn/version "2.0.0-SNAPSHOT"}
com.xtdb.labs/xtdb-http-client-clj {:mvn/version "2.0.0-SNAPSHOT"}}}
Once you have a REPL (e.g. by running clj
), you can connect to the XTDB node with:
(require '[xtdb.client :as xt.client]
'[xtdb.api :as xt])
(with-open [node (xt.client/start-client "http://localhost:3000")]
(xt/status node)
;; ...
)
In process
First, ensure you are running JDK 11+ and then add the XTDB dependencies to your deps.edn
:
deps.edn
{:mvn/repos {"ossrh-snapshots" {:url "https://s01.oss.sonatype.org/content/repositories/snapshots"}}
:deps {org.clojure/clojure {:mvn/version "1.11.1"}
com.xtdb.labs/xtdb-api {:mvn/version "2.0.0-SNAPSHOT"}
com.xtdb.labs/xtdb-core {:mvn/version "2.0.0-SNAPSHOT"}}
;; needed on JDK16+
:aliases {:xtdb {:jvm-opts ["--add-opens=java.base/java.nio=ALL-UNNAMED"
"-Dio.netty.tryReflectionSetAccessible=true"]}}}
Once you have a REPL (started with clj -A:xtdb
if you’re on JDK 16+), you can create an in-memory XTDB node with:
(require '[xtdb.node :as xt.node]
'[xtdb.api :as xt])
(with-open [node (xt.node/start-node {})]
(xt/status node)
;; ...
)
Next
Data Types