Skip to main content
Version: 2.x(alpha)

Run a multi-node, scalable cluster

For highly-available and highly-scalable setups, SurrealDB can be run on top of a TiKV cluster, with the ability to horizontally scale to 100+ terabytes of data. In this example, we will start a local TiKV cluster with a single node, for development and testing purposes only. To install TiKV on your development machine, run the following command. This will install the tiup command-line tool, which enables deploying and managing TiKV clusters of any size.

curl -sSf https://tiup-mirrors.pingcap.com/install.sh | sh

Once installed we shall start up a simple single-node development cluster.

tiup playground --tag surrealdb --mode tikv-slim --pd 1 --kv 1

Once TiKV is up and running, we can start a SurrealDB server instance, specifying the TiKV cluster endpoint as the backing data store.

surreal start tikv://127.0.0.1:2379

The default logging level for the database server is info, resulting in any informational logs to be output to the standard output. To control the logging verbosity, specify the --log argument. The following command starts the database with trace level logging, resulting in most logs being output to the terminal.

surreal start --log trace tikv://127.0.0.1:2379

In order to keep SurrealDB secure, configure your initial root-level user by setting the --user and --pass command-line arguments. The following command starts the database with a top-level user named root with a password also set to root. The root user will be persisted in storage, which means you don't have to include the command line arguments next time you start SurrealDB.

surreal start --log trace --user root --pass root tikv://127.0.0.1:2379

In order to change the default port that SurrealDB uses for web connections and from database clients you can use the --bind argument. The following command starts the database on port 8080.

surreal start --log trace --user root --pass root --bind 0.0.0.0:8080 tikv://placement.driver.hostname.or.ip:2379

After running the above command, you should see the SurrealDB server startup successfully.

surreal start --user root --pass root --bind 0.0.0.0:8080 file:mydatabase.db
2023-08-30T15:06:34.788739Z INFO surreal::dbs: ✅🔒 Authentication is enabled 🔒✅
2023-08-30T15:06:34.788821Z INFO surrealdb::kvs::ds: Starting kvs store in file:mydatabase.db
2023-08-30T15:06:34.788859Z INFO surrealdb::kvs::ds: Started kvs store in file:mydatabase.db
2023-08-30T15:06:34.789222Z INFO surrealdb::kvs::ds: Initial credentials were provided and no existing root-level users were found: create the initial user 'root'.
2023-08-30T15:06:35.205123Z INFO surrealdb::node: Started node agent
2023-08-30T15:06:35.205827Z INFO surrealdb::net: Started web server on 0.0.0.0:8080

For details on the different commands available, visit the CLI tool documentation.