Skip to main content
The cockroach gen can generate command-line interface (CLI) utilities (man pages and a bash autocompletion script), example SQL data suitable to populate test databases, and an HAProxy configuration file for load balancing a running cluster.

Subcommands

Synopsis

Generate man pages:
Generate bash autocompletion script:
Generate example SQL data:
Generate an HAProxy config file for a running cluster:
View help:

Flags

The gen subcommands supports the following general-use, logging, and client connection flags.

General

man

autocomplete

example-data

No flags are supported. See the Generate Example Data example for guidance.

haproxy

Logging

By default, this command logs messages to stderr. This includes events with WARNING and higher. If you need to troubleshoot this command’s behavior, you can .

Client Connection

haproxy

Examples

Generate man pages

Generate man pages:
Move the man pages to the man directory:
Access man pages:

Generate a bash autocompletion script

Generate bash autocompletion script:
Add the script to your .bashrc and .bash_profle:
You can now use tab to autocomplete cockroach commands.

Generate example data

You can also use the command to generate these sample datasets in a persistent cluster and the command to generate these datasets in a temporary, in-memory cluster. To test out CockroachDB, you can generate an example startrek database, which contains 2 tables, episodes and quotes.
  1. Start up :
  2. Pipe the output from cockroach gen to :
  3. Open a to view it:
  4. Generate an example intro database, which contains 1 table, mytable, with a hidden message:
  5. Launch the SQL client to view it:
  6. Show the tables in the intro database:
  7. Select the message from the table:

Generate an HAProxy config file

HAProxy is one of the most popular open-source TCP load balancers, and CockroachDB includes a built-in command for generating a configuration file that is preset to work with your running cluster.
To generate an HAProxy config file for an entire secure cluster, run the cockroach gen haproxy command, specifying the location of and the address of any instance running a CockroachDB node:
To limit the HAProxy config file to nodes matching specific , use the --localities flag, specifying the explicit locality tier(s) or a regular expression to match against:
By default, the generated configuration file is called haproxy.cfg and looks as follows, with the server addresses pre-populated correctly:
The file is preset with the minimal configurations needed to work with your running cluster:
For full details on these and other configuration settings, see the HAProxy Configuration Manual.

See also

  • (using HAProxy for load balancing)