Use the following instructions to set up universes for running the examples in Explore.

Set up YugabyteDB universe

You can run examples using a universe set up on your local machine, assuming you have Installed YugabyteDB.

Use the yugabyted utility to create and manage universes.

Single-node universe

If a local universe is currently running, first destroy it.

You can create a single-node local universe with a replication factor (RF) of 1 by running the following command:

./bin/yugabyted start --advertise_address=127.0.0.1

Or, if you are running macOS Monterey, use the following command:

./bin/yugabyted start --advertise_address=127.0.0.1 \
                      --master_webserver_port=9999

To check the status of a running single-node universe, run the following command:

./bin/yugabyted status

For more information, refer to Quick Start.

Multi-node universe

The following instructions show how to simulate a multi-node universe on a single computer. To deploy an actual multi-zone universe using yugabyted, follow the instructions in Create a multi-zone cluster.

Set up a local cluster

If a local universe is currently running, first destroy it.

Start a local three-node universe with an RF of 3 by first creating a single node, as follows:

./bin/yugabyted start \
                --advertise_address=127.0.0.1 \
                --base_dir=${HOME}/var/node1 \
                --cloud_location=aws.us-east-2.us-east-2a

On macOS, the additional nodes need loopback addresses configured, as follows:

sudo ifconfig lo0 alias 127.0.0.2
sudo ifconfig lo0 alias 127.0.0.3

Next, join more nodes with the previous node as needed. yugabyted automatically applies a replication factor of 3 when a third node is added.

Start the second node as follows:

./bin/yugabyted start \
                --advertise_address=127.0.0.2 \
                --base_dir=${HOME}/var/node2 \
                --cloud_location=aws.us-east-2.us-east-2b \
                --join=127.0.0.1

Start the third node as follows:

./bin/yugabyted start \
                --advertise_address=127.0.0.3 \
                --base_dir=${HOME}/var/node3 \
                --cloud_location=aws.us-east-2.us-east-2c \
                --join=127.0.0.1

After starting the yugabyted processes on all the nodes, configure the data placement constraint of the universe, as follows:

./bin/yugabyted configure data_placement --base_dir=${HOME}/var/node1 --fault_tolerance=zone

This command can be executed on any node where you already started YugabyteDB.

To check the status of a running multi-node universe, run the following command:

./bin/yugabyted status --base_dir=${HOME}/var/node1

Connect to universes

To run the examples in your universe, you use either the ysqlsh or ycqlsh CLI to interact with YugabyteDB via the YSQL or YCQL API.

You can start ysqlsh as follows:

./bin/ysqlsh
ysqlsh (15.2-YB-2.25.1.0-b0)
Type "help" for help.

yugabyte=#

You can start ycqlsh as follows:

./bin/ycqlsh
Connected to local cluster at 127.0.0.1:9042.
[ycqlsh 5.0.1 | Cassandra 3.9-SNAPSHOT | CQL spec 3.4.2 | Native protocol v4]
Use HELP for help.
ycqlsh>

Set up YB Workload Simulator

YB Workload Simulator is a Java application that simulates workloads against YugabyteDB and provides live metrics of latency and throughput from the application's point of view.

The application is used to demonstrate the following Explore topics:

The application uses the YugabyteDB JDBC Smart Driver, which features universe- and topology-aware connection load balancing. The driver automatically balances application connections across the nodes in a universe, and re-balances connections when a node fails. For more information, see YB Workload Simulator.

Download

YB Workload Simulator requires Java 11 or later installed on your computer. JDK installers for Linux and macOS can be downloaded from Oracle, Adoptium (OpenJDK), or Azul Systems (OpenJDK). Homebrew users on macOS can install using brew install openjdk.

Download the YB Workload Simulator JAR file using the following command:

wget https://github.com/YugabyteDB-Samples/yb-workload-simulator/releases/download/v0.0.8/yb-workload-sim-0.0.8.jar

Use the application

To start the application against a running local universe, use the following command:

java -jar \
    -Dnode=127.0.0.1 \
    ./yb-workload-sim-0.0.8.jar

The -Dnode flag specifies the IP address of the node to which to connect.

The -Dspring.datasource flag enables topology-aware load balancing for the application connections. If you created a universe using different zones, replace the zones with the corresponding zones in your universe, comma-separated, in the format cloud.region.zone.

To view the application UI, navigate to http://<machine_ip_or_dns>:8080 (for example, http://localhost:8080).

Start a read and write workload

You can start a workload that performs read and write operations across all the nodes of the universe as follows:

  1. In the application UI, click the hamburger icon at the top of the page beside Active Workloads for Generic.
  2. Select Usable Operations.
  3. Under Create Tables, click Run Create Tables Workload to add tables to the database.
  4. Under Seed Data, click Run Seed Data Workload to add data to the tables.
  5. Under Simulation, select the Include new Inserts option, and click Run Simulation Workload.
  6. Click Close.

The Latency and Throughput charts show the workload running on the universe.