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

# Deploy CockroachDB on Google Cloud Platform GCE (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>;
};

This page shows you how to manually deploy an insecure multi-node CockroachDB cluster on Google Cloud Platform's Compute Engine (GCE), using Google's TCP Proxy Load Balancing service to distribute client traffic.

<Danger>
  The `--insecure` flag used in this tutorial is intended for non-production testing only. To run CockroachDB in production, use a secure cluster instead.
</Danger>

<Tip>
  To try CockroachDB Cloud instead of running CockroachDB yourself, refer to the <InternalLink version="cockroachcloud" path="quickstart">Cloud Quickstart</InternalLink>.
</Tip>

## Before you begin

### Requirements

* You must have [SSH access](https://cloud.google.com/compute/docs/instances/connecting-to-instance) to each machine. This is necessary for distributing and starting CockroachDB binaries.

* Your network configuration must allow TCP communication on the following ports:
  * `26257` for intra-cluster and client-cluster communication
  * `8080` to expose your DB Console

* Carefully review the <InternalLink path="recommended-production-settings">Production Checklist</InternalLink> and recommended <InternalLink path="topology-patterns">Topology Patterns</InternalLink>.

* Do not run multiple node processes on the same VM or machine. This defeats CockroachDB's replication and causes the system to be a single point of failure. Instead, start each node on a separate VM or machine.

* To start a node with multiple disks or SSDs, provide a separate `--store` flag for each disk when starting the `cockroach` process on the node. For more details about stores, see <InternalLink path="cockroach-start#store">Start a Node</InternalLink>.

  If you start a node with multiple `--store` flags, it is not possible to scale back down to only using a single store on the node. Instead, you must decommission the node and start a new node with the updated `--store`.

* When starting each node, use the <InternalLink path="cockroach-start#locality">`--locality`</InternalLink> flag to describe the node's location, for example, `--locality=region=west,zone=us-west-1`. The key-value pairs should be ordered from most to least inclusive, and the keys and order of key-value pairs must be the same on all nodes.

* When deploying in a single availability zone:
  * To be able to tolerate the failure of any 1 node, use at least 3 nodes with the <InternalLink path="configure-replication-zones#view-the-default-replication-zone">`default` 3-way replication factor</InternalLink>. In this case, if 1 node fails, each range retains 2 of its 3 replicas, a majority.
  * To be able to tolerate 2 simultaneous node failures, use at least 5 nodes and <InternalLink path="configure-replication-zones#edit-the-default-replication-zone">increase the `default` replication factor for user data</InternalLink> to 5. The replication factor for <InternalLink path="configure-replication-zones#create-a-replication-zone-for-a-system-range">important internal data</InternalLink> is 5 by default, so no adjustments are needed for internal data. In this case, if 2 nodes fail at the same time, each range retains 3 of its 5 replicas, a majority.

* When deploying across multiple availability zones:
  * To be able to tolerate the failure of 1 entire AZ in a region, use at least 3 AZs per region and set `--locality` on each node to spread data evenly across regions and AZs. In this case, if 1 AZ goes offline, the 2 remaining AZs retain a majority of replicas.
  * To ensure that ranges are split evenly across nodes, use the same number of nodes in each AZ. This is to avoid overloading any nodes with excessive resource consumption.

* When deploying across multiple regions:
  * To be able to tolerate the failure of 1 entire region, use at least 3 regions.

* This article covers the use of Linux instances with GCE. You may wish to review the instructions for [connecting to Windows instances](https://cloud.google.com/compute/docs/instances/connecting-to-instance#windows).

### Recommendations

* Consider using a <InternalLink path="manual-deployment">secure cluster</InternalLink> instead. Using an insecure cluster comes with risks:
  * Your cluster is open to any client that can access any node's IP addresses.
  * Any user, even `root`, can log in without providing a password.
  * Any user, connecting as `root`, can read or write any data in your cluster.
  * There is no network encryption or authentication, and thus no confidentiality.
* Decide how you want to access your DB Console:

| Access Level      | Description                                                                                                                                                           |
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Partially open    | Set a firewall rule to allow only specific IP addresses to communicate on port `8080`.                                                                                |
| Completely open   | Set a firewall rule to allow all IP addresses to communicate on port `8080`.                                                                                          |
| Completely closed | Set a firewall rule to disallow all communication on port `8080`. In this case, a machine with SSH access to a node could use an SSH tunnel to access the DB Console. |

## Step 1. Configure your network

CockroachDB requires TCP communication on two ports:

* `26257` for inter-node communication (i.e., working as a cluster)
* `8080` for exposing your DB Console

To expose your DB Console and allow traffic from the TCP proxy load balancer and health checker to your instances, [create firewall rules](https://cloud.google.com/compute/docs/vpc/firewalls) for your project. When creating firewall rules, we recommend using Google Cloud Platform's **tag** feature to apply the rule only to instances with the same tag.

#### DB Console

| Field                | Recommended Value              |
| -------------------- | ------------------------------ |
| Name                 | **cockroachadmin**             |
| Source filter        | IP ranges                      |
| Source IP ranges     | Your local network's IP ranges |
| Allowed protocols... | **tcp:8080**                   |
| Target tags          | **cockroachdb**                |

#### Application data

Applications will not connect directly to your CockroachDB nodes. Instead, they'll connect to GCE's TCP Proxy Load Balancing service, which automatically routes traffic to the instances that are closest to the user. Because this service is implemented at the edge of the Google Cloud, you'll need to create a firewall rule to allow traffic from the load balancer and health checker to your instances. This is covered in [Step 4](#step-4-set-up-load-balancing).

## Step 2. Create instances

[Create an instance](https://cloud.google.com/compute/docs/instances/create-start-instance) for each node you plan to have in your cluster. If you plan to run a sample workload against the cluster, create a separate instance for that workload.

* Run at least 3 nodes to <InternalLink path="recommended-production-settings#topology">ensure survivability</InternalLink>.
* Use general-purpose [`t2d-standard`, `n2-standard`, or `n2d-standard`](https://cloud.google.com/compute/pricing#predefined_machine_types) VMs, or use [custom VMs](https://cloud.google.com/compute/docs/instances/creating-instance-with-custom-machine-type). For example, Cockroach Labs has used `t2d-standard-8`, `n2-standard-8`, and `n2d-standard-8` for performance benchmarking.

<Danger>
  Do not use `f1` or `g1` [shared-core machines](https://cloud.google.com/compute/docs/machine-types#sharedcore), which limit the load on CPU resources.
</Danger>

* If you used a tag for your firewall rules, when you create the instance, click **Management, security, disks, networking, sole tenancy**. Under the **Networking** tab, in the **Network tags** field, enter **cockroachdb**.

For more details, see <InternalLink path="recommended-production-settings#hardware">Hardware Recommendations</InternalLink> and <InternalLink path="recommended-production-settings#topology">Cluster Topology</InternalLink>.

## Step 3. Synchronize clocks

CockroachDB requires moderate levels of <InternalLink path="recommended-production-settings#clock-synchronization">clock synchronization</InternalLink> to preserve data consistency. For this reason, when a node detects that its clock is out of sync with at least half of the other nodes in the cluster by 80% of the maximum offset allowed (500ms by default), it spontaneously shuts down. This avoids the risk of consistency anomalies, but it's best to prevent clocks from drifting too far in the first place by running clock synchronization software on each node.

Compute Engine instances are preconfigured to use [NTP](http://www.ntp.org/), which should keep offsets in the single-digit milliseconds. However, Google can’t predict how external NTP services, such as `pool.ntp.org`, will handle the leap second. Therefore, you should:

* [Configure each GCE instance to use Google's internal NTP service](https://cloud.google.com/compute/docs/instances/configure-ntp#configure_ntp_for_your_instances).
* If you plan to run a hybrid cluster across GCE and other cloud providers or environments, note that all of the nodes must be synced to the same time source, or to different sources that implement leap second smearing in the same way. See the <InternalLink path="recommended-production-settings#considerations">Production Checklist</InternalLink> for details.

## Step 4. Set up load balancing

Each CockroachDB node is an equally suitable SQL gateway to your cluster, but to ensure client performance and reliability, it's important to use load balancing:

* **Performance:** Load balancers spread client traffic across nodes. This prevents any one node from being overwhelmed by requests and improves overall cluster performance (queries per second).
* **Reliability:** Load balancers decouple client health from the health of a single CockroachDB node. In cases where a node fails, the load balancer redirects client traffic to available nodes.

GCE offers fully-managed [TCP Proxy Load Balancing](https://cloud.google.com/load-balancing/docs/tcp). This service lets you use a single IP address for all users around the world, automatically routing traffic to the instances that are closest to the user.

<Danger>
  When using TCP Proxy Load Balancing, you cannot use firewall rules to control access to the load balancer. If you need such control, consider using [Network TCP Load Balancing](https://cloud.google.com/compute/docs/load-balancing/network) instead, but note that it cannot be used across regions. You might also consider using the HAProxy load balancer (see the <InternalLink path="deploy-cockroachdb-on-premises-insecure">On-Premises</InternalLink> tutorial for guidance).
</Danger>

To use GCE's TCP Proxy Load Balancing service:

1. For each zone in which you're running an instance, [create a distinct instance group](https://cloud.google.com/compute/docs/instance-groups/creating-groups-of-unmanaged-instances).
   * To ensure that the load balancer knows where to direct traffic, specify a port name mapping, with `tcp26257` as the **Port name** and `26257` as the **Port number**.
2. [Add the relevant instances to each instance group](https://cloud.google.com/compute/docs/instance-groups/creating-groups-of-unmanaged-instances#addinstances).
3. [Configure Proxy Load Balancing](https://cloud.google.com/load-balancing/docs/tcp/setting-up-tcp#configure_load_balancer).
   * During backend configuration, create a health check, setting the **Protocol** to `HTTP`, the **Port** to `8080`, and the **Request path** to path `/health?ready=1`. This <InternalLink path="monitoring-and-alerting">health endpoint</InternalLink> ensures that load balancers do not direct traffic to nodes that are live but not ready to receive requests.
     * If you want to maintain long-lived SQL connections that may be idle for more than tens of seconds, increase the backend timeout setting accordingly.
   * During frontend configuration, reserve a static IP address and choose a port. Note this address/port combination, as you'll use it for all of you client connections.
4. [Create a firewall rule](https://cloud.google.com/load-balancing/docs/tcp/setting-up-tcp#config-hc-firewall) to allow traffic from the load balancer and health checker to your instances. This is necessary because TCP Proxy Load Balancing is implemented at the edge of the Google Cloud.
   * Be sure to set **Source IP ranges** to `130.211.0.0/22` and `35.191.0.0/16` and set **Target tags** to `cockroachdb` (not to the value specified in the linked instructions).

## Step 5. Start nodes

<Note>
  By default, inter-node communication uses the internal IP addresses of your GCE instances.
</Note>

You can start the nodes manually or automate the process using [systemd](https://www.freedesktop.org/wiki/Software/systemd).

For each initial node of your cluster, complete the following steps:

<Note>
  After completing these steps, nodes will not yet be live. They will complete the startup process and join together to form a cluster as soon as the cluster is initialized in the next step.
</Note>

1. Visit <InternalLink version="releases" path="index">Releases</InternalLink> and download the full binary of CockroachDB to the node.
2. On the node, follow the instructions to <InternalLink path="install-cockroachdb">install CockroachDB</InternalLink>.
3. Run the <InternalLink path="cockroach-start">`cockroach start`</InternalLink> command:

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   $ cockroach start \
   --insecure \
   --advertise-addr=<node1 address \
   --join=<node1 address,<node2 address,<node3 address \
   --cache=.25 \
   --max-sql-memory=.25 \
   --background
   ```

   This command primes the node to start, using the following flags:

| Flag                         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--insecure`                 | Indicates that the cluster is insecure, with no network encryption or authentication.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `--advertise-addr`           | Specifies the IP address/hostname and port to tell other nodes to use. The port number can be omitted, in which case it defaults to `26257`.  This value must route to an IP address the node is listening on (with `--listen-addr` unspecified, the node listens on all IP addresses).  In some networking scenarios, you may need to use `--advertise-addr` and/or `--listen-addr` differently. For more details, see <InternalLink path="recommended-production-settings#networking">Networking</InternalLink>.                                                                  |
| `--join`                     | Identifies the address of 3-5 of the initial nodes of the cluster. These addresses should match the addresses that the target nodes are advertising.                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `--cache` `--max-sql-memory` | Increases the node's cache size to 25% of available system memory to improve read performance. The capacity for in-memory SQL processing defaults to 25% of system memory but can be raised, if necessary, to increase the number of simultaneous client connections allowed by the node as well as the node's capacity for in-memory processing of rows when using `ORDER BY`, `GROUP BY`, `DISTINCT`, joins, and window functions. For more details, see <InternalLink path="recommended-production-settings#cache-and-sql-memory-size">Cache and SQL Memory Size</InternalLink>. |
| `--background`               | Starts the node in the background so you gain control of the terminal to issue more commands.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

When deploying across multiple datacenters, or when there is otherwise high latency between nodes, it is recommended to set `--locality` as well. It is also required to use certain enterprise features. For more details, see <InternalLink path="cockroach-start#locality">Locality</InternalLink>.

For other flags not explicitly set, the command uses default values. For example, the node stores data in `--store=cockroach-data` and binds DB Console HTTP requests to `--http-addr=localhost:8080`. To set these options manually, see <InternalLink path="cockroach-start">Start a Node</InternalLink>.
4\. Repeat these steps for each additional node that you want in your cluster.

For each initial node of your cluster, complete the following steps:

After completing these steps, nodes will not yet be live. They will complete the startup process and join together to form a cluster as soon as the cluster is initialized in the next step.

1. SSH to the machine where you want the node to run. Ensure you are logged in as the `root` user.
2. <InternalLink path="install-cockroachdb">Install CockroachDB for Linux</InternalLink>.
3. Create the Cockroach directory:

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   $ mkdir /var/lib/cockroach
   ```
4. Create a Unix user named `cockroach`:

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   $ useradd cockroach
   ```
5. Change the ownership of the `cockroach` directory to the user `cockroach`:

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   $ chown cockroach /var/lib/cockroach
   ```
6. Download the [sample configuration template](https://raw.githubusercontent.com/cockroachlabs/docs/main/src/current/_includes/v24.3/prod-deployment/insecurecockroachdb.service) and save the file in the `/etc/systemd/system/` directory:

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   curl -o insecurecockroachdb.service https://raw.githubusercontent.com/cockroachlabs/docs/main/src/current/_includes/v24.3/prod-deployment/insecurecockroachdb.service
   ```

   Alternatively, you can create the file yourself and copy the script into it:

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   [Unit]
   Description=Cockroach Database cluster node
   Requires=network.target
   [Service]
   Type=notify
   WorkingDirectory=/var/lib/cockroach
   ExecStart=/usr/local/bin/cockroach start --insecure --advertise-addr=<node1 address --join=<node1 address,<node2 address,<node3 address --cache=.25 --max-sql-memory=.25
   TimeoutStopSec=300
   Restart=always
   RestartSec=10
   StandardOutput=syslog
   StandardError=syslog
   SyslogIdentifier=cockroach
   User=cockroach
   [Install]
   WantedBy=default.target
   ```

<Note>
  Previously, the sample configuration file set `TimeoutStopSec` to 60 seconds. This recommendation has been lengthened to 300 seconds, to give the `cockroach` process more time to stop gracefully.
</Note>

7. In the sample configuration template, specify values for the following flags:

| Flag               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--advertise-addr` | Specifies the IP address/hostname and port to tell other nodes to use. The port number can be omitted, in which case it defaults to `26257`.  This value must route to an IP address the node is listening on (with `--listen-addr` unspecified, the node listens on all IP addresses).  In some networking scenarios, you may need to use `--advertise-addr` and/or `--listen-addr` differently. For more details, see <InternalLink path="recommended-production-settings#networking">Networking</InternalLink>. |
| `--join`           | Identifies the address of 3-5 of the initial nodes of the cluster. These addresses should match the addresses that the target nodes are advertising.                                                                                                                                                                                                                                                                                                                                                               |

When deploying across multiple datacenters, or when there is otherwise high latency between nodes, it is recommended to set `--locality` as well. It is also required to use certain enterprise features. For more details, see <InternalLink path="cockroach-start#locality">Locality</InternalLink>.

For other flags not explicitly set, the command uses default values. For example, the node stores data in `--store=cockroach-data` and binds DB Console HTTP requests to `--http-port=8080`. To set these options manually, see <InternalLink path="cockroach-start">Start a Node</InternalLink>.
8\. Start the CockroachDB cluster:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
$ systemctl start insecurecockroachdb
```

9. Configure `systemd` to start CockroachDB automatically after a reboot:

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   systemctl enable insecurecockroachdb
   ```
10. Repeat these steps for each additional node that you want in your cluster.

<Note>
  `systemd` handles node restarts in case of node failure. To stop a node without `systemd` restarting it, run `systemctl stop insecurecockroachdb`
</Note>

## Step 6. Initialize the cluster

On your local machine, complete the node startup process and have them join together as a cluster:

1. <InternalLink path="install-cockroachdb">Install CockroachDB</InternalLink> on your local machine, if you haven't already.
2. Run the <InternalLink path="cockroach-init">`cockroach init`</InternalLink> command, with the `--host` flag set to the address of any node:

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   $ cockroach init --insecure --host=<address of any node on --join list
   ```

   Each node then prints helpful details to the <InternalLink path="cockroach-start#standard-output">standard output</InternalLink>, such as the CockroachDB version, the URL for the DB Console, and the SQL URL for clients.

## Step 7. Test the cluster

CockroachDB replicates and distributes data behind-the-scenes and uses a [Gossip protocol](https://wikipedia.org/wiki/Gossip_protocol) to enable each node to locate data across the cluster. Once a cluster is live, any node can be used as a SQL gateway.

When using a load balancer, you should issue commands directly to the load balancer, which then routes traffic to the nodes.

Use the <InternalLink path="cockroach-sql">built-in SQL client</InternalLink> locally as follows:

1. On your local machine, launch the built-in SQL client, with the `--host` flag set to the address of the load balancer:

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   $ cockroach sql --insecure --host=<address of load balancer
   ```
2. Create an `insecurenodetest` database:

   ```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   > CREATE DATABASE insecurenodetest;
   ```
3. View the cluster's databases, which will include `insecurenodetest`:

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

   ```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   +--------------------+
   |      Database      |
   +--------------------+
   | crdb_internal      |
   | information_schema |
   | insecurenodetest   |
   | pg_catalog         |
   | system             |
   +--------------------+
   (5 rows)
   ```
4. Use `\q` to exit the SQL shell.

## Step 8. Run a sample workload

CockroachDB comes with a number of <InternalLink path="cockroach-workload">built-in workloads</InternalLink> for simulating client traffic. This step features CockroachDB's version of the [TPC-C](http://www.tpc.org/tpcc) workload.

<Note>
  Be sure that you have configured your network to allow traffic from the application to the load balancer. In this case, you will run the sample workload on one of your machines. The traffic source should therefore be the **internal (private)** IP address of that machine.
</Note>

<Tip>
  For comprehensive guidance on benchmarking CockroachDB with TPC-C, see <InternalLink path="performance-benchmarking-with-tpcc-local">Performance Benchmarking</InternalLink>.
</Tip>

1. SSH to the machine where you want the run the sample TPC-C workload.

   This should be a machine that is not running a CockroachDB node.
2. <InternalLink path="install-cockroachdb">Install CockroachDB for Linux</InternalLink>.
3. Use the <InternalLink path="cockroach-workload">`cockroach workload`</InternalLink> command to load the initial schema and data, pointing it at the IP address of the load balancer:

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   $ cockroach workload init tpcc \
   'postgresql://root@<IP ADDRESS OF LOAD BALANCER>:26257/tpcc?sslmode=disable'
   ```
4. Use the `cockroach workload` command to run the workload for 10 minutes:

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   $ cockroach workload run tpcc \
   --duration=10m \
   'postgresql://root@<IP ADDRESS OF LOAD BALANCER>:26257/tpcc?sslmode=disable'
   ```

   You'll see per-operation statistics print to standard output every second:

   ```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   _elapsed___errors__ops/sec(inst)___ops/sec(cum)__p50(ms)__p95(ms)__p99(ms)_pMax(ms)
         1s        0         1443.4         1494.8      4.7      9.4     27.3     67.1 transfer
         2s        0         1686.5         1590.9      4.7      8.1     15.2     28.3 transfer
         3s        0         1735.7         1639.0      4.7      7.3     11.5     28.3 transfer
         4s        0         1542.6         1614.9      5.0      8.9     12.1     21.0 transfer
         5s        0         1695.9         1631.1      4.7      7.3     11.5     22.0 transfer
         6s        0         1569.2         1620.8      5.0      8.4     11.5     15.7 transfer
         7s        0         1614.6         1619.9      4.7      8.1     12.1     16.8 transfer
         8s        0         1344.4         1585.6      5.8     10.0     15.2     31.5 transfer
         9s        0         1351.9         1559.5      5.8     10.0     16.8     54.5 transfer
        10s        0         1514.8         1555.0      5.2      8.1     12.1     16.8 transfer
   ...
   ```

   After the specified duration (10 minutes in this case), the workload will stop and you'll see totals printed to standard output:

   ```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   _elapsed___errors_____ops(total)___ops/sec(cum)__avg(ms)__p50(ms)__p95(ms)__p99(ms)_pMax(ms)__result
     600.0s        0         823902         1373.2      5.8      5.5     10.0     15.2    209.7
   ```

<Tip>
  For more `tpcc` options, use `cockroach workload run tpcc --help`. For details about other workloads built into the `cockroach` binary, use `cockroach workload --help`.
</Tip>

5. To monitor the load generator's progress, open the <InternalLink path="ui-overview">DB Console</InternalLink> by pointing a browser to the address in the `admin` field in the standard output of any node on startup.

   Since the load generator is pointed at the load balancer, the connections will be evenly distributed across nodes. To verify this, click **Metrics** on the left, select the **SQL** dashboard, and then check the **SQL Connections** graph. You can use the **Graph** menu to filter the graph for specific nodes.

## Step 9. Monitor the cluster

Despite CockroachDB's various <InternalLink path="frequently-asked-questions">built-in safeguards against failure</InternalLink>, it is critical to actively monitor the overall health and performance of a cluster running in production and to create alerting rules that promptly send notifications when there are events that require investigation or intervention.

For details about available monitoring options and the most important events and metrics to alert on, see <InternalLink path="monitoring-and-alerting">Monitoring and Alerting</InternalLink>.

## Step 10. Scale the cluster

You can start the nodes manually or automate the process using [systemd](https://www.freedesktop.org/wiki/Software/systemd).

For each additional node you want to add to the cluster, complete the following steps:

1. SSH to the machine where you want the node to run.
2. <InternalLink path="install-cockroachdb">Install CockroachDB for Linux</InternalLink>.
3. Run the <InternalLink path="cockroach-start">`cockroach start`</InternalLink> command, passing the new node's address as the `--advertise-addr` flag and pointing `--join` to the three existing nodes (also include `--locality` if you set it earlier).

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   $ cockroach start \
   --insecure \
   --advertise-addr=<node4 address \
   --join=<node1 address,<node2 address,<node3 address \
   --cache=.25 \
   --max-sql-memory=.25 \
   --background
   ```
4. Update your load balancer to recognize the new node.

For each additional node you want to add to the cluster, complete the following steps:

1. SSH to the machine where you want the node to run. Ensure you are logged in as the `root` user.

2. <InternalLink path="install-cockroachdb">Install CockroachDB for Linux</InternalLink>.

3. Create the Cockroach directory:

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   mkdir /var/lib/cockroach
   ```

4. Create a Unix user named `cockroach`:

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   useradd cockroach
   ```

5. Change the ownership of the `cockroach` directory to the user `cockroach`:

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   chown cockroach /var/lib/cockroach
   ```

6. Download the [sample configuration template](https://raw.githubusercontent.com/cockroachlabs/docs/master/_includes/v24.3/prod-deployment/insecurecockroachdb.service):

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   curl -o insecurecockroachdb.service https://raw.githubusercontent.com/cockroachlabs/docs/master/_includes/v24.3/prod-deployment/insecurecockroachdb.service
   ```

   Alternatively, you can create the file yourself and copy the script into it:

   ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
   [Unit]
   Description=Cockroach Database cluster node
   Requires=network.target
   [Service]
   Type=notify
   WorkingDirectory=/var/lib/cockroach
   ExecStart=/usr/local/bin/cockroach start --insecure --advertise-addr=<node1 address --join=<node1 address,<node2 address,<node3 address --cache=.25 --max-sql-memory=.25
   TimeoutStopSec=300
   Restart=always
   RestartSec=10
   StandardOutput=syslog
   StandardError=syslog
   SyslogIdentifier=cockroach
   User=cockroach
   [Install]
   WantedBy=default.target
   ```

   Previously, the sample configuration file set `TimeoutStopSec` to 60 seconds. This recommendation has been lengthened to 300 seconds, to give the `cockroach` process more time to stop gracefully.

   Save the file in the `/etc/systemd/system/` directory

7. Customize the sample configuration template for your deployment:

   Specify values for the following flags in the sample configuration template:

| Flag               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--advertise-addr` | Specifies the IP address/hostname and port to tell other nodes to use. The port number can be omitted, in which case it defaults to `26257`.  This value must route to an IP address the node is listening on (with `--listen-addr` unspecified, the node listens on all IP addresses).  In some networking scenarios, you may need to use `--advertise-addr` and/or `--listen-addr` differently. For more details, see <InternalLink path="recommended-production-settings#networking">Networking</InternalLink>. |
| `--join`           | Identifies the address of 3-5 of the initial nodes of the cluster. These addresses should match the addresses that the target nodes are advertising.                                                                                                                                                                                                                                                                                                                                                               |

8. Repeat these steps for each additional node that you want in your cluster.

## Step 11. Use the cluster

Now that your deployment is working, you can:

1. <InternalLink path="sql-statements">Implement your data model</InternalLink>.
2. <InternalLink path="create-user">Create users</InternalLink> and <InternalLink path="grant">grant them privileges</InternalLink>.
3. <InternalLink path="install-client-drivers">Connect your application</InternalLink>. Be sure to connect your application to the GCE load balancer, not to a CockroachDB node.

## See also

* <InternalLink path="recommended-production-settings">Production Checklist</InternalLink>
* <InternalLink path="manual-deployment">Manual Deployment</InternalLink>
* <InternalLink path="kubernetes-overview">Orchestrated Deployment</InternalLink>
* <InternalLink path="monitoring-and-alerting">Monitoring and Alerting</InternalLink>
* <InternalLink path="performance-benchmarking-with-tpcc-small">Performance Benchmarking</InternalLink>
* <InternalLink path="performance-best-practices-overview">Performance Tuning</InternalLink>
* <InternalLink path="start-a-local-cluster">Local Deployment</InternalLink>
