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:Flags
Thegen 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 tostderr. 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:
Generate a bash autocompletion script
Generate bash autocompletion script:
.bashrc and .bash_profle:
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 examplestartrek database, which contains 2 tables, episodes and quotes.
-
Start up :
-
Pipe the output from
cockroach gento : -
Open a to view it:
-
Generate an example
introdatabase, which contains 1 table,mytable, with a hidden message: -
Launch the SQL client to view it:
-
Show the tables in the
introdatabase: -
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.- Secure
- Insecure
To generate an HAProxy config file for an entire secure cluster, run the To limit the HAProxy config file to nodes matching specific , use the
cockroach gen haproxy command, specifying the location of and the address of any instance running a CockroachDB node:--localities flag, specifying the explicit locality tier(s) or a regular expression to match against:haproxy.cfg and looks as follows, with the server addresses pre-populated correctly:
For full details on these and other configuration settings, see the HAProxy Configuration Manual.
See also
- (using HAProxy for load balancing)

