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

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

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

Once you've <InternalLink path="install-cockroachdb">installed CockroachDB</InternalLink>, you can simulate multi-region cluster on your local machine using <InternalLink path="cockroach-demo">`cockroach demo`</InternalLink>to learn about CockroachDB's <InternalLink path="multiregion-overview">multi-region abstractions</InternalLink>.

<Note>
  <InternalLink path="cockroach-demo">`cockroach demo`</InternalLink> is not suitable for production deployments. Additionally, simulating multiple geographically distributed nodes on a single host is not representative of the <InternalLink path="frequently-asked-questions">performance you should expect</InternalLink> in a production deployment. To learn more about production multi-region deployments, refer to <InternalLink path="orchestrate-cockroachdb-with-kubernetes-multi-cluster">Orchestrate CockroachDB Across Multiple Kubernetes Clusters</InternalLink> and <InternalLink path="movr-flask-deployment">Deploy a Global, Serverless Application</InternalLink>, and review the <InternalLink path="recommended-production-settings">Production Checklist</InternalLink>.
</Note>

## Before you begin

<InternalLink version="releases" path="index">Download</InternalLink> and <InternalLink path="install-cockroachdb">Install CockroachDB</InternalLink>.

## Step 1. Start the cluster

Use the following <InternalLink path="cockroach-demo">`cockroach demo`</InternalLink> 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 <InternalLink path="cockroach-start#locality">node localities</InternalLink> and also simulates the network latency that would occur between nodes in these localities. For more information about each flag, see the <InternalLink path="cockroach-demo#flags">`cockroach demo`</InternalLink> documentation, especially for <InternalLink path="cockroach-demo">`--global`</InternalLink>.

```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 <InternalLink path="ui-overview">DB Console</InternalLink>: `http://127.0.0.1:8080`.
* Connecting to the database from a <InternalLink path="cockroach-sql">SQL shell</InternalLink> or a <InternalLink path="connect-to-the-database">programming language</InternalLink>: `postgres://root@127.0.0.1:26257?sslmode=disable`.

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
#
# 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">Download</InternalLink>    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:

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
root@127.0.0.1:26257/defaultdb>
```

You can run some basic <InternalLink path="learn-cockroachdb-sql">CockroachDB SQL statements</InternalLink>:

```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;
```

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  id | balance
+----+---------+
   1 | 1000.50
(1 row)
```

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

The <InternalLink path="ui-overview">DB Console</InternalLink> gives you insight into the overall health of your cluster, as well as the performance of any <InternalLink path="cockroach-workload">client workloads</InternalLink>.

To verify that the 9 nodes you specified are up and running as expected, go to the <InternalLink path="ui-cluster-overview-page">**Cluster Overview**</InternalLink> 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 <InternalLink path="ui-cluster-overview-page#capacity-metrics">Capacity metrics</InternalLink>.
</Note>

To see which nodes are located in which regions, and to see the simulated latencies between them, go to the <InternalLink path="ui-network-latency-page">**Network Diagnostics**</InternalLink> 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 <InternalLink path="ui-sql-dashboard#sql-queries-per-second">SQL queries</InternalLink> and <InternalLink path="ui-sql-dashboard#service-latency-sql-99th-percentile">SQL service latency</InternalLink>, go to the <InternalLink path="ui-overview-dashboard">**Metrics**</InternalLink> page at [http://localhost:8080/#/metrics](http://localhost:8080/#/metrics)

You may also find the following pages useful:

* The <InternalLink path="ui-databases-page">**Databases**</InternalLink> page at [http://localhost:8080/#/databases](http://localhost:8080/#/databases) shows details about your databases and tables.
* The <InternalLink path="ui-statements-page">**Statements**</InternalLink> page at [http://localhost:8080/#/statements](http://localhost:8080/#/statements) is used to assess the performance of specific queries.
* The <InternalLink path="ui-jobs-page">**Jobs**</InternalLink> page at [http://localhost:8080/#/jobs](http://localhost:8080/#/jobs) is used to monitor the status of long-running operations like <InternalLink path="online-schema-changes">schema changes</InternalLink>.

## 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 <InternalLink path="cockroach-demo">`cockroach demo`</InternalLink> documentation.

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

## What's next?

* <InternalLink path="install-client-drivers">Install the client driver</InternalLink> for your preferred language
* Learn more about <InternalLink path="learn-cockroachdb-sql">CockroachDB SQL</InternalLink> and the <InternalLink path="cockroach-sql">built-in SQL client</InternalLink>
* <InternalLink path="example-apps">Build an app with CockroachDB</InternalLink>
* Further explore CockroachDB capabilities like:
  * <InternalLink path="demo-low-latency-multi-region-deployment">Low Latency Reads and Writes in a Multi-Region Cluster</InternalLink>
  * <InternalLink path="demo-cockroachdb-resilience">Fault tolerance and automated repair</InternalLink>
  * <InternalLink path="demo-serializable">Serializable transactions</InternalLink>
  * <InternalLink path="demo-json-support">JSON support</InternalLink>
