> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cockroachlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Simulate a Multi-Region Cluster on localhost (Insecure)

Once you've [installed CockroachDB](https://docs.cockroachlabs.com/docs/stable/install-cockroachdb.md), you can simulate multi-region cluster on your local machine using [`cockroach demo`](https://docs.cockroachlabs.com/docs/stable/cockroach-demo)to learn about CockroachDB's [multi-region abstractions](https://docs.cockroachlabs.com/docs/stable/multiregion-overview.md).

> [!NOTE]
>
> [`cockroach demo`](https://docs.cockroachlabs.com/docs/stable/cockroach-demo) is not suitable for production deployments. Additionally, simulating multiple geographically distributed nodes on a single host is not representative of the [performance you should expect](https://docs.cockroachlabs.com/docs/stable/frequently-asked-questions.md#single-row-perf) in a production deployment. To learn more about production multi-region deployments, refer to [Orchestrate CockroachDB Across Multiple Kubernetes Clusters](https://docs.cockroachlabs.com/docs/stable/orchestrate-cockroachdb-with-kubernetes-multi-cluster.md) and review the [Production Checklist](https://docs.cockroachlabs.com/docs/stable/recommended-production-settings.md).

## Before you begin

[Download](https://docs.cockroachlabs.com/docs/releases/index.md) and [Install CockroachDB](https://docs.cockroachlabs.com/docs/stable/install-cockroachdb.md).

## Step 1. Start the cluster

Use the following [`cockroach demo`](https://docs.cockroachlabs.com/docs/stable/cockroach-demo) command to start the cluster. This particular combination of flags results in a demo cluster of 9 nodes, with 3 nodes in each region. It sets the appropriate [node localities](https://docs.cockroachlabs.com/docs/stable/cockroach-start.md#locality) and also simulates the network latency that would occur between nodes in these localities. For more information about each flag, see the [`cockroach demo`](https://docs.cockroachlabs.com/docs/stable/cockroach-demo#flags) documentation, especially for [`--global`](https://docs.cockroachlabs.com/docs/stable/cockroach-demo).

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
$ cockroach demo --global --nodes 9 --no-example-database --insecure
```

When the cluster starts, you'll see a message like the one shown below, followed by a SQL prompt. Note the URLs for:

* Viewing the [DB Console](https://docs.cockroachlabs.com/docs/stable/ui-overview.md): `http://127.0.0.1:8080`.
* Connecting to the database from a [SQL shell](https://docs.cockroachlabs.com/docs/stable/cockroach-sql.md) or a [programming language](https://docs.cockroachlabs.com/docs/stable/connect-to-the-database.md): `postgres://root@127.0.0.1:26257?sslmode=disable`.

```
#
# Welcome to the CockroachDB demo database!
#
# You are connected to a temporary, in-memory CockroachDB cluster of 9 nodes.
#
# This demo session will attempt to enable enterprise features
# by acquiring a temporary license from Cockroach Labs in the background.
# To disable this behavior, set the environment variable
# COCKROACH_SKIP_ENABLING_DIAGNOSTIC_REPORTING=true.
#
# Reminder: your changes to data stored in the demo session will not be saved!
#
# Connection parameters:
#   (webui)    http://127.0.0.1:8080/demologin?password=demo76950&username=demo
#   (sql)      postgres://demo:demo76950@127.0.0.1:26257?sslmode=require
#   (sql/unix) postgres://demo:demo76950@?host=%2Fvar%2Ffolders%2Fc8%2Fb_q93vjj0ybfz0fz0z8vy9zc0000gp%2FT%2Fdemo070856957&port=26257
#
# To display connection parameters for other nodes, use \demo ls.
#
# The user "demo" with password "demo76950" has been created. Use it to access the Web UI!
#
# Server version: CockroachDB CCL v21.1.2 (x86_64-apple-darwin19, built 2021/06/07 18:13:04, go1.15.11) (same version as client)
# Cluster ID: bfd9fc91-69bd-4417-a2f7-66e556bf2cfd
# Organization: Cockroach Demo
#
# Enter \? for a brief introduction.
#
```

## Step 2. Enter SQL statements at the prompt

Now that your simulated multi-region cluster is running, you are presented with a SQL prompt:

```
root@127.0.0.1:26257/defaultdb>
```

You can run some basic [CockroachDB SQL statements](https://docs.cockroachlabs.com/docs/stable/learn-cockroachdb-sql):

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> CREATE DATABASE bank;
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> USE bank;
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> CREATE TABLE bank.accounts (id INT PRIMARY KEY, balance DECIMAL);
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> INSERT INTO bank.accounts VALUES (1, 1000.50);
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SELECT * FROM bank.accounts;
```

```
  id | balance
+----+---------+
   1 | 1000.50
(1 row)
```

## Step 3. View cluster health and performance in the DB Console

The [DB Console](https://docs.cockroachlabs.com/docs/stable/ui-overview.md) gives you insight into the overall health of your cluster, as well as the performance of any [client workloads](https://docs.cockroachlabs.com/docs/stable/cockroach-workload.md).

To verify that the 9 nodes you specified are up and running as expected, go to the [**Cluster Overview**](https://docs.cockroachlabs.com/docs/stable/ui-cluster-overview-page.md) at [http://localhost:8080/#/overview/list](http://localhost:8080/#/overview/list).

> [!NOTE]
>
> Capacity metrics can be incorrect when running multiple nodes on a single machine. For more details, refer to [Capacity metrics](https://docs.cockroachlabs.com/docs/stable/ui-cluster-overview-page.md#capacity-metrics).

To see which nodes are located in which regions, and to see the simulated latencies between them, go to the [**Network Diagnostics**](https://docs.cockroachlabs.com/docs/stable/ui-network-latency-page.md) page at [http://localhost:8080/#/reports/network/region](http://localhost:8080/#/reports/network/region)

To access a variety of time series charts, including graphs of [SQL queries](https://docs.cockroachlabs.com/docs/stable/ui-sql-dashboard.md#sql-queries-per-second) and [SQL service latency](https://docs.cockroachlabs.com/docs/stable/ui-sql-dashboard.md#service-latency-sql-99th-percentile), go to the [**Metrics**](https://docs.cockroachlabs.com/docs/stable/ui-overview-dashboard.md) page at [http://localhost:8080/#/metrics](http://localhost:8080/#/metrics)

You may also find the following pages useful:

* The [**Databases**](https://docs.cockroachlabs.com/docs/stable/ui-databases-page.md) page at [http://localhost:8080/#/databases](http://localhost:8080/#/databases) shows details about your databases and tables.
* The [**Statements**](https://docs.cockroachlabs.com/docs/stable/ui-statements-page.md) page at [http://localhost:8080/#/statements](http://localhost:8080/#/statements) is used to assess the performance of specific queries.
* The [**Jobs**](https://docs.cockroachlabs.com/docs/stable/ui-jobs-page.md) page at [http://localhost:8080/#/jobs](http://localhost:8080/#/jobs) is used to monitor the status of long-running operations like [schema changes](https://docs.cockroachlabs.com/docs/stable/online-schema-changes.md).

## Step 4. Wipe the cluster

When you're done with your demo cluster, you can wipe the cluster by typing the command shown below at the SQL prompt. Note that because this is a temporary, in-memory cluster, this will wipe any data you have added to the cluster. For more information, see the [`cockroach demo`](https://docs.cockroachlabs.com/docs/stable/cockroach-demo) documentation.

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
\quit
```

## What's next?

* [Install the client driver](https://docs.cockroachlabs.com/docs/stable/install-client-drivers.md) for your preferred language
* Learn more about [CockroachDB SQL](https://docs.cockroachlabs.com/docs/stable/learn-cockroachdb-sql) and the [built-in SQL client](https://docs.cockroachlabs.com/docs/stable/cockroach-sql.md)
* Further explore CockroachDB capabilities like:
  * [Fault tolerance and automated repair](https://docs.cockroachlabs.com/docs/stable/demo-cockroachdb-resilience.md)
  * [Serializable transactions](https://docs.cockroachlabs.com/docs/stable/demo-serializable.md)
