github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/cli/cliflags/flags.go (about) 1 // Copyright 2015 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package cliflags 12 13 import ( 14 "bytes" 15 "fmt" 16 "strings" 17 18 "github.com/kr/text" 19 ) 20 21 // FlagInfo contains the static information for a CLI flag and helper 22 // to format the description. 23 type FlagInfo struct { 24 // Name of the flag as used on the command line. 25 Name string 26 27 // Shorthand is the short form of the flag (optional). 28 Shorthand string 29 30 // EnvVar is the name of the environment variable through which the flag value 31 // can be controlled (optional). 32 EnvVar string 33 34 // Description of the flag. 35 // 36 // The text will be automatically re-wrapped. The wrapping can be stopped by 37 // embedding the tag "<PRE>": this tag is removed from the text and 38 // signals that everything that follows should not be re-wrapped. To start 39 // wrapping again, use "</PRE>". 40 Description string 41 } 42 43 const usageIndentation = 8 44 const wrapWidth = 79 - usageIndentation 45 46 // wrapDescription wraps the text in a FlagInfo.Description. 47 func wrapDescription(s string) string { 48 var result bytes.Buffer 49 50 // split returns the parts of the string before and after the first occurrence 51 // of the tag. 52 split := func(str, tag string) (before, after string) { 53 pieces := strings.SplitN(str, tag, 2) 54 switch len(pieces) { 55 case 0: 56 return "", "" 57 case 1: 58 return pieces[0], "" 59 default: 60 return pieces[0], pieces[1] 61 } 62 } 63 64 for len(s) > 0 { 65 var toWrap, dontWrap string 66 // Wrap everything up to the next stop wrap tag. 67 toWrap, s = split(s, "<PRE>") 68 result.WriteString(text.Wrap(toWrap, wrapWidth)) 69 // Copy everything up to the next start wrap tag. 70 dontWrap, s = split(s, "</PRE>") 71 result.WriteString(dontWrap) 72 } 73 return result.String() 74 } 75 76 // Usage returns a formatted usage string for the flag, including: 77 // * line wrapping 78 // * indentation 79 // * env variable name (if set) 80 func (f FlagInfo) Usage() string { 81 s := "\n" + wrapDescription(f.Description) + "\n" 82 if f.EnvVar != "" { 83 // Check that the environment variable name matches the flag name. Note: we 84 // don't want to automatically generate the name so that grepping for a flag 85 // name in the code yields the flag definition. 86 correctName := "COCKROACH_" + strings.ToUpper(strings.Replace(f.Name, "-", "_", -1)) 87 if f.EnvVar != correctName { 88 panic(fmt.Sprintf("incorrect EnvVar %s for flag %s (should be %s)", 89 f.EnvVar, f.Name, correctName)) 90 } 91 s = s + "Environment variable: " + f.EnvVar + "\n" 92 } 93 // github.com/spf13/pflag appends the default value after the usage text. Add 94 // the correct indentation (7 spaces) here. This is admittedly fragile. 95 return text.Indent(s, strings.Repeat(" ", usageIndentation)) + 96 strings.Repeat(" ", usageIndentation-1) 97 } 98 99 // Attrs and others store the static information for CLI flags. 100 var ( 101 Attrs = FlagInfo{ 102 Name: "attrs", 103 Description: ` 104 An ordered, colon-separated list of node attributes. Attributes are arbitrary 105 strings specifying machine capabilities. Machine capabilities might include 106 specialized hardware or number of cores (e.g. "gpu", "x16c"). For example: 107 <PRE> 108 109 --attrs=x16c:gpu`, 110 } 111 112 Locality = FlagInfo{ 113 Name: "locality", 114 Description: ` 115 An ordered, comma-separated list of key-value pairs that describe the topography 116 of the machine. Topography might include country, datacenter or rack 117 designations. Data is automatically replicated to maximize diversities of each 118 tier. The order of tiers is used to determine the priority of the diversity, so 119 the more inclusive localities like country should come before less inclusive 120 localities like datacenter. The tiers and order must be the same on all nodes. 121 Including more tiers is better than including fewer. For example: 122 <PRE> 123 124 --locality=country=us,region=us-west,datacenter=us-west-1b,rack=12 125 --locality=country=ca,region=ca-east,datacenter=ca-east-2,rack=4 126 127 --locality=planet=earth,province=manitoba,colo=secondary,power=3`, 128 } 129 130 Background = FlagInfo{ 131 Name: "background", 132 Description: ` 133 Start the server in the background. This is similar to appending "&" 134 to the command line, but when the server is started with --background, 135 control is not returned to the shell until the server is ready to 136 accept requests.`, 137 } 138 139 SQLMem = FlagInfo{ 140 Name: "max-sql-memory", 141 Description: ` 142 Maximum memory capacity available to store temporary data for SQL clients, 143 including prepared queries and intermediate data rows during query execution. 144 Accepts numbers interpreted as bytes, size suffixes (e.g. 1GB and 1GiB) or a 145 percentage of physical memory (e.g. .25). 146 If left unspecified, defaults to 25% of physical memory. 147 `, 148 } 149 150 SQLAuditLogDirName = FlagInfo{ 151 Name: "sql-audit-dir", 152 Description: ` 153 If non-empty, create a SQL audit log in this drectory. 154 `, 155 } 156 157 SQLTempStorage = FlagInfo{ 158 Name: "max-disk-temp-storage", 159 Description: ` 160 Maximum storage capacity available to store temporary disk-based data for SQL 161 queries that exceed the memory budget (e.g. join, sorts, etc are sometimes able 162 to spill intermediate results to disk). 163 Accepts numbers interpreted as bytes, size suffixes (e.g. 32GB and 32GiB) or a 164 percentage of disk size (e.g. 10%). 165 If left unspecified, defaults to 32GiB. 166 167 The location of the temporary files is within the first store dir (see --store). 168 If expressed as a percentage, --max-disk-temp-storage is interpreted relative to 169 the size of the storage device on which the first store is placed. The temp 170 space usage is never counted towards any store usage (although it does share the 171 device with the first store) so, when configuring this, make sure that the size 172 of this temp storage plus the size of the first store don't exceed the capacity 173 of the storage device. 174 If the first store is an in-memory one (i.e. type=mem), then this temporary "disk" 175 data is also kept in-memory. A percentage value is interpreted as a percentage 176 of the available internal memory. If not specified, the default shifts to 100MiB 177 when the first store is in-memory. 178 `, 179 } 180 181 AuthTokenValidityPeriod = FlagInfo{ 182 Name: "expire-after", 183 Description: ` 184 Duration after which the newly created session token expires.`, 185 } 186 187 OnlyCookie = FlagInfo{ 188 Name: "only-cookie", 189 Description: ` 190 Display only the newly created cookie on the standard output 191 without additional details and decoration.`, 192 } 193 194 Cache = FlagInfo{ 195 Name: "cache", 196 Description: ` 197 Total size in bytes for caches, shared evenly if there are multiple 198 storage devices. Size suffixes are supported (e.g. 1GB and 1GiB). 199 If left unspecified, defaults to 128MiB. A percentage of physical memory 200 can also be specified (e.g. .25).`, 201 } 202 203 ClientHost = FlagInfo{ 204 Name: "host", 205 EnvVar: "COCKROACH_HOST", 206 Description: ` 207 CockroachDB node to connect to. 208 This can be specified either as an address/hostname, or 209 together with a port number as in -s myhost:26257. 210 If the port number is left unspecified, it defaults to 26257. 211 An IPv6 address can also be specified with the notation [...], for 212 example [::1]:26257 or [fe80::f6f2:::]:26257.`, 213 } 214 215 ClientPort = FlagInfo{ 216 Name: "port", 217 Shorthand: "p", 218 EnvVar: "COCKROACH_PORT", 219 Description: `Deprecated. Use --host=<host>:<port>.`, 220 } 221 222 Database = FlagInfo{ 223 Name: "database", 224 Shorthand: "d", 225 EnvVar: "COCKROACH_DATABASE", 226 Description: `The name of the database to connect to.`, 227 } 228 229 DumpMode = FlagInfo{ 230 Name: "dump-mode", 231 Description: ` 232 What to dump. "schema" dumps the schema only. "data" dumps the data only. 233 "both" (default) dumps the schema then the data.`, 234 } 235 236 DumpTime = FlagInfo{ 237 Name: "as-of", 238 Description: ` 239 Dumps the data as of the specified timestamp. Formats supported are the same 240 as the timestamp type.`, 241 } 242 243 DumpAll = FlagInfo{ 244 Name: "dump-all", 245 Description: ` 246 Dumps all databases, for each non-system database provides dump of all available tables.`, 247 } 248 249 Execute = FlagInfo{ 250 Name: "execute", 251 Shorthand: "e", 252 Description: ` 253 Execute the SQL statement(s) on the command line, then exit. This flag may be 254 specified multiple times and each value may contain multiple semicolon 255 separated statements. If an error occurs in any statement, the command exits 256 with a non-zero status code and further statements are not executed. The 257 results of each SQL statement are printed on the standard output.`, 258 } 259 260 Watch = FlagInfo{ 261 Name: "watch", 262 Description: ` 263 Repeat the SQL statement(s) specified with --execute 264 with the specified period. The client will stop watching 265 if an execution of the SQL statement(s) fail.`, 266 } 267 268 EchoSQL = FlagInfo{ 269 Name: "echo-sql", 270 Description: ` 271 Reveal the SQL statements sent implicitly by the command-line utility.`, 272 } 273 274 CliDebugMode = FlagInfo{ 275 Name: "debug-sql-cli", 276 Description: ` 277 Simplify the SQL CLI to ease troubleshooting of CockroachDB 278 issues. This echoes sent SQL, removes the database name and txn status 279 from the prompt, and forces behavior to become independent on current 280 transaction state. Equivalent to --echo-sql, \unset check_syntax and 281 \set prompt1 %n@%M>.`, 282 } 283 284 SafeUpdates = FlagInfo{ 285 Name: "safe-updates", 286 Description: ` 287 Disable SQL statements that may have undesired side effects. For 288 example a DELETE or UPDATE without a WHERE clause. By default, this 289 setting is enabled (true) and such statements are rejected to prevent 290 accidents. This can also be overridden in a session with SET 291 sql_safe_updates = FALSE.`, 292 } 293 294 Set = FlagInfo{ 295 Name: "set", 296 Description: ` 297 Set a client-side configuration parameter before running the SQL 298 shell. This flag may be specified multiple times.`, 299 } 300 301 TableDisplayFormat = FlagInfo{ 302 Name: "format", 303 Description: ` 304 Selects how to display table rows in results. Possible values: tsv, 305 csv, table, records, sql, raw, html. If left unspecified, defaults to 306 tsv for non-interactive sessions and table for interactive sessions.`, 307 } 308 309 ClusterName = FlagInfo{ 310 Name: "cluster-name", 311 Description: ` 312 Sets a name to verify the identity of a remote node or cluster. The 313 value must match between this node and the remote node(s) specified 314 via --join. 315 316 This can be used as an additional verification when either the node or 317 cluster, or both, have not yet been initialized and do not yet know 318 their cluster ID. 319 320 To introduce a cluster name into an already-initialized cluster, pair 321 this flag with --disable-cluster-name-verification.`, 322 } 323 324 DisableClusterNameVerification = FlagInfo{ 325 Name: "disable-cluster-name-verification", 326 Description: ` 327 Tell the server to ignore cluster name mismatches. This is meant for 328 use when opting an existing cluster into starting to use cluster name 329 verification, or when changing the cluster name. 330 331 The cluster should be restarted once with --cluster-name and 332 --disable-cluster-name-verification combined, and once all nodes have 333 been updated to know the new cluster name, the cluster can be 334 restarted again with this flag removed.`, 335 } 336 337 Join = FlagInfo{ 338 Name: "join", 339 Shorthand: "j", 340 Description: ` 341 The addresses for connecting a node to a cluster. 342 <PRE> 343 344 </PRE> 345 When starting a multi-node cluster for the first time, set this flag 346 to the addresses of 3-5 of the initial nodes. Then run the cockroach 347 init command against one of the nodes to complete cluster startup. 348 <PRE> 349 350 </PRE> 351 When starting a singe-node cluster, leave this flag out. This will 352 cause the node to initialize a new single-node cluster without 353 needing to run the cockroach init command. 354 <PRE> 355 356 </PRE> 357 When adding a node to an existing cluster, set this flag to 3-5 358 of the nodes already in the cluster; it's easiest to use the same 359 list of addresses that was used to start the initial nodes. 360 <PRE> 361 362 </PRE> 363 This flag can be specified separately for each address: 364 <PRE> 365 366 --join=localhost:1234 --join=localhost:2345 367 368 </PRE> 369 Or can be specified as a comma separated list in single flag, 370 or both forms can be used together, for example: 371 <PRE> 372 373 --join=localhost:1234,localhost:2345 --join=localhost:3456 374 375 </PRE>`, 376 } 377 378 JoinPreferSRVRecords = FlagInfo{ 379 Name: "experimental-dns-srv", 380 Description: ` 381 When enabled, the node will first attempt to fetch SRV records 382 from DNS for every name specified with --join. If a valid 383 SRV record is found, that information is used instead 384 of regular DNS A/AAAA lookups. 385 This feature is experimental and may be removed or modified 386 in a later version.`, 387 } 388 389 ListenAddr = FlagInfo{ 390 Name: "listen-addr", 391 Description: ` 392 The address/hostname and port to listen on for intra-cluster 393 communication, for example --listen-addr=myhost:26257 or 394 --listen-addr=:26257 (listen on all interfaces). 395 Unless --sql-addr is also specified, this address is also 396 used to accept SQL client connections. 397 <PRE> 398 399 </PRE> 400 If the address part is left unspecified, it defaults to 401 the "all interfaces" address (0.0.0.0 IPv4 / [::] IPv6). 402 If the port part is left unspecified, it defaults to 26257. 403 <PRE> 404 405 </PRE> 406 An IPv6 address can also be specified with the notation [...], for 407 example [::1]:26257 or [fe80::f6f2:::]:26257. 408 <PRE> 409 410 </PRE> 411 If --advertise-addr is left unspecified, the node will also announce 412 this address for use by other nodes. It is strongly recommended to use 413 --advertise-addr in cloud and container deployments or any setup where 414 NAT is present between cluster nodes.`, 415 } 416 417 ServerHost = FlagInfo{ 418 Name: "host", 419 Description: `Alias for --listen-addr. Deprecated.`, 420 } 421 422 ServerPort = FlagInfo{ 423 Name: "port", 424 Description: `Alias for --listen-port. Deprecated.`, 425 } 426 427 AdvertiseAddr = FlagInfo{ 428 Name: "advertise-addr", 429 Description: ` 430 The address/hostname and port to advertise to other CockroachDB nodes 431 for intra-cluster communication. It must resolve and be routable from 432 other nodes in the cluster. 433 <PRE> 434 435 </PRE> 436 If left unspecified, it defaults to the setting of --listen-addr. 437 If the flag is provided but either the address part or the port part 438 is left unspecified, that particular part defaults to the 439 same part in --listen-addr. 440 <PRE> 441 442 </PRE> 443 An IPv6 address can also be specified with the notation [...], for 444 example [::1]:26257 or [fe80::f6f2:::]:26257. 445 <PRE> 446 447 </PRE> 448 The port number should be the same as in --listen-addr unless port 449 forwarding is set up on an intermediate firewall/router.`, 450 } 451 452 SQLAdvertiseAddr = FlagInfo{ 453 Name: "advertise-sql-addr", 454 Description: ` 455 The SQL address/hostname and port to advertise to CLI admin utilities 456 and via SQL introspection for the purpose of SQL address discovery. 457 It must resolve and be routable from clients. 458 <PRE> 459 460 </PRE> 461 If left unspecified, it defaults to the setting of --sql-addr. 462 If the flag is provided but either the address part or the port part 463 is left unspecified, that particular part defaults to the 464 same part in --sql-addr. 465 <PRE> 466 467 </PRE> 468 An IPv6 address can also be specified with the notation [...], for 469 example [::1]:26257 or [fe80::f6f2:::]:26257. 470 <PRE> 471 472 </PRE> 473 The port number should be the same as in --sql-addr unless port 474 forwarding is set up on an intermediate firewall/router.`, 475 } 476 477 AdvertiseHost = FlagInfo{ 478 Name: "advertise-host", 479 Description: `Alias for --advertise-addr. Deprecated.`, 480 } 481 482 AdvertisePort = FlagInfo{ 483 Name: "advertise-port", 484 Description: `Deprecated. Use --advertise-addr=<host>:<port>.`, 485 } 486 487 ListenSQLAddr = FlagInfo{ 488 Name: "sql-addr", 489 Description: ` 490 The hostname or IP address to bind to for SQL clients, for example 491 --sql-addr=myhost:26257 or --sql-addr=:26257 (listen on all interfaces). 492 If left unspecified, the address specified by --listen-addr will be 493 used for both RPC and SQL connections. 494 <PRE> 495 496 </PRE> 497 If specified but the address part is omitted, the address part 498 defaults to the address part of --listen-addr. 499 If specified but the port number is omitted, the port 500 number defaults to 26257. 501 <PRE> 502 503 </PRE> 504 To actually use separate bindings, it is recommended to specify 505 both flags and use a different port number via --listen-addr, for 506 example --sql-addr=:26257 --listen-addr=:26258. Ensure that 507 --join is set accordingly on other nodes. It is also possible 508 to use the same port number but separate host addresses. 509 <PRE> 510 511 </PRE> 512 An IPv6 address can also be specified with the notation [...], for 513 example [::1]:26257 or [fe80::f6f2:::]:26257.`, 514 } 515 516 ListenHTTPAddr = FlagInfo{ 517 Name: "http-addr", 518 Description: ` 519 The hostname or IP address to bind to for HTTP requests. 520 If left unspecified, the address part defaults to the setting of 521 --listen-addr. The port number defaults to 8080. 522 An IPv6 address can also be specified with the notation [...], for 523 example [::1]:8080 or [fe80::f6f2:::]:8080.`, 524 } 525 526 UnencryptedLocalhostHTTP = FlagInfo{ 527 Name: "unencrypted-localhost-http", 528 Description: ` 529 When specified, restricts HTTP connections to localhost-only and disables 530 TLS for the HTTP interface. The hostname part of --http-addr, if specified, 531 is then ignored. This flag is intended for use to facilitate 532 local testing without requiring certificate setups in web browsers.`, 533 } 534 535 LocalityAdvertiseAddr = FlagInfo{ 536 Name: "locality-advertise-addr", 537 Description: ` 538 List of ports to advertise to other CockroachDB nodes for intra-cluster 539 communication for some locality. This should be specified as a commma 540 separated list of locality@address. Addresses can also include ports. 541 For example: 542 <PRE> 543 "region=us-west@127.0.0.1,datacenter=us-west-1b@127.0.0.1" 544 "region=us-west@127.0.0.1:26257,datacenter=us-west-1b@127.0.0.1:26258" 545 </PRE> 546 `, 547 } 548 549 ListenHTTPAddrAlias = FlagInfo{ 550 Name: "http-host", 551 Description: `Alias for --http-addr. Deprecated.`, 552 } 553 554 ListenHTTPPort = FlagInfo{ 555 Name: "http-port", 556 Description: `Deprecated. Use --http-addr=<host>:<port>.`, 557 } 558 559 ListeningURLFile = FlagInfo{ 560 Name: "listening-url-file", 561 Description: ` 562 After the CockroachDB node has started up successfully, it will 563 write its connection URL to the specified file.`, 564 } 565 566 PIDFile = FlagInfo{ 567 Name: "pid-file", 568 Description: ` 569 After the CockroachDB node has started up successfully, it will 570 write its process ID to the specified file.`, 571 } 572 573 Socket = FlagInfo{ 574 Name: "socket", 575 EnvVar: "COCKROACH_SOCKET", 576 Description: ` 577 Accept client connections using a Unix domain socket with the 578 given name. 579 580 Note: for compatibility with PostgreSQL clients and drivers, 581 ensure that the socket name has the form "/path/to/.s.PGSQL.NNNN", 582 where NNNN is a number. PostgreSQL clients only take a port 583 number and directory as input and construct the socket name 584 programmatically. 585 586 To use, for example: psql -h /path/to -p NNNN ... 587 `, 588 } 589 590 SocketDir = FlagInfo{ 591 Name: "socket-dir", 592 EnvVar: "COCKROACH_SOCKET_DIR", 593 Description: `Deprecated in favor of --socket-dir.`, 594 } 595 596 ClientInsecure = FlagInfo{ 597 Name: "insecure", 598 EnvVar: "COCKROACH_INSECURE", 599 Description: ` 600 Connect to an insecure cluster. This is strongly discouraged for 601 production usage.`, 602 } 603 604 ServerInsecure = FlagInfo{ 605 Name: "insecure", 606 Description: ` 607 Start an insecure node, using unencrypted (non-TLS) connections, 608 listening on all IP addresses (unless --listen-addr is provided) and 609 disabling password authentication for all database users. This is 610 strongly discouraged for production usage and should never be used on 611 a public network without combining it with --listen-addr.`, 612 } 613 614 ExternalIODisableHTTP = FlagInfo{ 615 Name: "external-io-disable-http", 616 Description: `Disable use of HTTP when accessing external data.`, 617 } 618 619 ExtenralIODisableImplicitCredentials = FlagInfo{ 620 Name: "external-io-disable-implicit-credentials", 621 Description: ` 622 Disable use of implicit credentials when accessing external data. 623 Instead, require the user to always specify access keys.`, 624 } 625 626 // KeySize, CertificateLifetime, AllowKeyReuse, and OverwriteFiles are used for 627 // certificate generation functions. 628 KeySize = FlagInfo{ 629 Name: "key-size", 630 Description: `Key size in bits for CA/Node/Client certificates.`, 631 } 632 633 CertificateLifetime = FlagInfo{ 634 Name: "lifetime", 635 Description: `Certificate lifetime.`, 636 } 637 638 AllowCAKeyReuse = FlagInfo{ 639 Name: "allow-ca-key-reuse", 640 Description: `Use the CA key if it exists.`, 641 } 642 643 OverwriteFiles = FlagInfo{ 644 Name: "overwrite", 645 Description: `Certificate and key files are overwritten if they exist.`, 646 } 647 648 GeneratePKCS8Key = FlagInfo{ 649 Name: "also-generate-pkcs8-key", 650 Description: `Also write the key in pkcs8 format to <certs-dir>/client.<username>.key.pk8.`, 651 } 652 653 Password = FlagInfo{ 654 Name: "password", 655 Description: `Prompt for the new user's password.`, 656 } 657 658 CertsDir = FlagInfo{ 659 Name: "certs-dir", 660 EnvVar: "COCKROACH_CERTS_DIR", 661 Description: `Path to the directory containing SSL certificates and keys.`, 662 } 663 664 // Server version of the certs directory flag, cannot be set through environment. 665 ServerCertsDir = FlagInfo{ 666 Name: "certs-dir", 667 Description: CertsDir.Description, 668 } 669 670 CertPrincipalMap = FlagInfo{ 671 Name: "cert-principal-map", 672 Description: ` 673 A comma separated list of <cert-principal>:<db-principal> mappings. This allows 674 mapping the principal in a cert to a DB principal such as "node" or "root" or 675 any SQL user. This is intended for use in situations where the certificate 676 management system places restrictions on the Subject.CommonName or 677 SubjectAlternateName fields in the certificate (e.g. disallowing a CommonName 678 such as "node" or "root"). If multiple mappings are provided for the same 679 <cert-principal>, the last one specified in the list takes precedence. A 680 principal not specified in the map is passed through as-is via the identity 681 function. A cert is allowed to authenticate a DB principal if the DB principal 682 name is contained in the mapped CommonName or DNS-type SubjectAlternateName 683 fields. 684 `, 685 } 686 687 CAKey = FlagInfo{ 688 Name: "ca-key", 689 EnvVar: "COCKROACH_CA_KEY", 690 Description: `Path to the CA key.`, 691 } 692 693 ClockDevice = FlagInfo{ 694 Name: "clock-device", 695 Description: ` 696 Override HLC to use PTP hardware clock user space API when querying for current time. 697 The value corresponds to the clock device to be used. This is currently only tested 698 and supported on Linux. 699 <PRE> 700 701 --clock-device=/dev/ptp0 702 703 </PRE> 704 `, 705 } 706 707 MaxOffset = FlagInfo{ 708 Name: "max-offset", 709 Description: ` 710 Maximum allowed clock offset for the cluster. If observed clock offsets exceed 711 this limit, servers will crash to minimize the likelihood of reading 712 inconsistent data. Increasing this value will increase the time to recovery of 713 failures as well as the frequency of uncertainty-based read restarts. 714 <PRE> 715 716 </PRE> 717 Note that this value must be the same on all nodes in the cluster. In order to 718 change it, all nodes in the cluster must be stopped simultaneously and restarted 719 with the new value.`, 720 } 721 722 Store = FlagInfo{ 723 Name: "store", 724 Shorthand: "s", 725 Description: ` 726 The file path to a storage device. This flag must be specified separately for 727 each storage device, for example: 728 <PRE> 729 730 --store=/mnt/ssd01 --store=/mnt/ssd02 --store=/mnt/hda1 731 732 </PRE> 733 For each store, the "attrs" and "size" fields can be used to specify device 734 attributes and a maximum store size (see below). When one or both of these 735 fields are set, the "path" field label must be used for the path to the storage 736 device, for example: 737 <PRE> 738 739 --store=path=/mnt/ssd01,attrs=ssd,size=20GiB 740 741 </PRE> 742 In most cases, node-level attributes are preferable to store-level attributes. 743 However, the "attrs" field can be used to match capabilities for storage of 744 individual databases or tables. For example, an OLTP database would probably 745 want to allocate space for its tables only on solid state devices, whereas 746 append-only time series might prefer cheaper spinning drives. Typical 747 attributes include whether the store is flash (ssd), spinny disk (hdd), or 748 in-memory (mem), as well as speeds and other specs. Attributes can be arbitrary 749 strings separated by colons, for example: 750 <PRE> 751 752 --store=path=/mnt/hda1,attrs=hdd:7200rpm 753 754 </PRE> 755 The store size in the "size" field is not a guaranteed maximum but is used when 756 calculating free space for rebalancing purposes. The size can be specified 757 either in a bytes-based unit or as a percentage of hard drive space, 758 for example: 759 <PRE> 760 761 --store=path=/mnt/ssd01,size=10000000000 -> 10000000000 bytes 762 --store=path=/mnt/ssd01,size=20GB -> 20000000000 bytes 763 --store=path=/mnt/ssd01,size=20GiB -> 21474836480 bytes 764 --store=path=/mnt/ssd01,size=0.02TiB -> 21474836480 bytes 765 --store=path=/mnt/ssd01,size=20% -> 20% of available space 766 --store=path=/mnt/ssd01,size=0.2 -> 20% of available space 767 --store=path=/mnt/ssd01,size=.2 -> 20% of available space 768 769 </PRE> 770 For an in-memory store, the "type" and "size" fields are required, and the 771 "path" field is forbidden. The "type" field must be set to "mem", and the 772 "size" field must be set to the true maximum bytes or percentage of available 773 memory that the store may consume, for example: 774 <PRE> 775 776 --store=type=mem,size=20GiB 777 --store=type=mem,size=90% 778 779 </PRE> 780 Commas are forbidden in all values, since they are used to separate fields. 781 Also, if you use equal signs in the file path to a store, you must use the 782 "path" field label.`, 783 } 784 785 StorageEngine = FlagInfo{ 786 Name: "storage-engine", 787 Description: ` 788 Storage engine to use for all stores on this cockroach node. Options are default, 789 rocksdb, or pebble. 790 791 If default is specified, the storage engine last used to write to the first 792 store directory is used (see --store). If the store directory is uninitialized 793 and default is specified, rocksdb is used as the default storage engine.`, 794 } 795 796 Size = FlagInfo{ 797 Name: "size", 798 Shorthand: "z", 799 Description: ` 800 The Size to fill Store upto(using a ballast file): 801 Negative value means denotes amount of space that should be left after filling the disk. 802 If the Size is left unspecified, it defaults to 1GB. 803 <PRE> 804 805 --size=20GiB 806 807 </PRE> 808 The size can be given in various ways: 809 <PRE> 810 811 --size=10000000000 -> 10000000000 bytes 812 --size=20GB -> 20000000000 bytes 813 --size=20GiB -> 21474836480 bytes 814 --size=0.02TiB -> 21474836480 bytes 815 --size=20% -> 20% of available space 816 --size=0.2 -> 20% of available space 817 --size=.2 -> 20% of available space 818 819 </PRE>`, 820 } 821 822 TempDir = FlagInfo{ 823 Name: "temp-dir", 824 Description: ` 825 The parent directory path where a temporary subdirectory will be created to be used for temporary files. 826 This path must exist or the node will not start. 827 The temporary subdirectory is used primarily as working memory for distributed computations 828 and CSV importing. 829 For example, the following will generate an arbitrary, temporary subdirectory 830 "/mnt/ssd01/temp/cockroach-temp<NUMBER>": 831 <PRE> 832 833 --temp-dir=/mnt/ssd01/temp 834 835 </PRE> 836 If this flag is unspecified, the temporary subdirectory will be located under 837 the root of the first store.`, 838 } 839 840 ExternalIODir = FlagInfo{ 841 Name: "external-io-dir", 842 Description: ` 843 The local file path under which remotely-initiated operations that can specify 844 node-local I/O paths, such as BACKUP, RESTORE or IMPORT, can access files. 845 Following symlinks _is_ allowed, meaning that other paths can be added by 846 symlinking to them from within this path. 847 848 Note: operations in a distributed cluster can run across many nodes, so reading 849 or writing to any given node's local file system in a distributed cluster is not 850 usually useful unless that filesystem is actually backed by something like NFS. 851 852 If left empty, defaults to the "extern" subdirectory of the first store directory. 853 854 The value "disabled" will disable all local file I/O. `, 855 } 856 857 URL = FlagInfo{ 858 Name: "url", 859 EnvVar: "COCKROACH_URL", 860 Description: ` 861 Connection URL, e.g. "postgresql://myuser@localhost:26257/mydb". 862 If left empty, the connection flags are used (host, port, user, 863 database, insecure, certs-dir).`, 864 } 865 866 User = FlagInfo{ 867 Name: "user", 868 Shorthand: "u", 869 EnvVar: "COCKROACH_USER", 870 Description: `Database user name.`, 871 } 872 873 From = FlagInfo{ 874 Name: "from", 875 Description: ` 876 Start key and format as [<format>:]<key>. Supported formats: raw, hex, human, 877 rangeID. The raw format supports escaped text. For example, "raw:\x01k" is the 878 prefix for range local keys. The hex format takes an encoded MVCCKey.`, 879 } 880 881 To = FlagInfo{ 882 Name: "to", 883 Description: ` 884 Exclusive end key and format as [<format>:]<key>. Supported formats: raw, hex, 885 human, rangeID. The raw format supports escaped text. For example, "raw:\x01k" 886 is the prefix for range local keys. The hex format takes an encoded MVCCKey.`} 887 888 Limit = FlagInfo{ 889 Name: "limit", 890 Description: `Maximum number of keys to return.`, 891 } 892 893 Values = FlagInfo{ 894 Name: "values", 895 Description: `Print values along with their associated key.`, 896 } 897 898 Sizes = FlagInfo{ 899 Name: "sizes", 900 Description: `Print key and value sizes along with their associated key.`, 901 } 902 903 Replicated = FlagInfo{ 904 Name: "replicated", 905 Description: "Restrict scan to replicated data.", 906 } 907 908 GossipInputFile = FlagInfo{ 909 Name: "file", 910 Shorthand: "f", 911 Description: ` 912 File containing the JSON output from a node's /_status/gossip/ endpoint. 913 If specified, takes priority over host/port flags.`, 914 } 915 916 PrintSystemConfig = FlagInfo{ 917 Name: "print-system-config", 918 Description: ` 919 If specified, print the system config contents. Beware that the output will be 920 long and not particularly human-readable.`, 921 } 922 923 DrainWait = FlagInfo{ 924 Name: "drain-wait", 925 Description: ` 926 When non-zero, wait for the specified amount of time for the node to 927 drain all active client connections and migrate away range leases.`, 928 } 929 930 Wait = FlagInfo{ 931 Name: "wait", 932 Description: ` 933 Specifies when to return after having marked the targets as decommissioning. 934 Takes any of the following values: 935 <PRE> 936 937 - all: waits until all target nodes' replica counts have dropped to zero. 938 This is the default. 939 - none: marks the targets as decommissioning, but does not wait for the process to complete. 940 Use when polling manually from an external system. 941 942 </PRE>`, 943 } 944 945 Timeout = FlagInfo{ 946 Name: "timeout", 947 Description: ` 948 If nonzero, return with an error if the operation does not conclude within the specified timeout. 949 The timeout is specified with a suffix of 's' for seconds, 'm' for minutes, and 'h' for hours.`, 950 } 951 952 NodeRanges = FlagInfo{ 953 Name: "ranges", 954 Description: `Show node details for ranges and replicas.`, 955 } 956 957 NodeStats = FlagInfo{ 958 Name: "stats", 959 Description: `Show node disk usage details.`, 960 } 961 962 NodeAll = FlagInfo{ 963 Name: "all", Description: `Show all node details. 964 When no node ID is specified, also lists all nodes that have been decommissioned 965 in the history of the cluster.`, 966 } 967 968 NodeDecommission = FlagInfo{ 969 Name: "decommission", Description: `Show node decommissioning details. 970 When no node ID is specified, also lists all nodes that have been decommissioned 971 in the history of the cluster.`, 972 } 973 974 SQLFmtLen = FlagInfo{ 975 Name: "print-width", 976 Description: ` 977 The line length where sqlfmt will try to wrap.`, 978 } 979 980 SQLFmtSpaces = FlagInfo{ 981 Name: "use-spaces", 982 Description: `Indent with spaces instead of tabs.`, 983 } 984 985 SQLFmtTabWidth = FlagInfo{ 986 Name: "tab-width", 987 Description: `Number of spaces per indentation level.`, 988 } 989 990 SQLFmtNoSimplify = FlagInfo{ 991 Name: "no-simplify", 992 Description: `Don't simplify output.`, 993 } 994 995 SQLFmtAlign = FlagInfo{ 996 Name: "align", 997 Description: `Align the output.`, 998 } 999 1000 DemoNodes = FlagInfo{ 1001 Name: "nodes", 1002 Description: `How many in-memory nodes to create for the demo.`, 1003 } 1004 1005 DemoNodeSQLMemSize = FlagInfo{ 1006 Name: "max-sql-memory", 1007 Description: ` 1008 Maximum memory capacity available for each node to store temporary data for SQL clients, 1009 including prepared queries and intermediate data rows during query execution. 1010 Accepts numbers interpreted as bytes, size suffixes (e.g. 1GB and 1GiB) or a 1011 percentage of physical memory (e.g. .25). 1012 If left unspecified, defaults to 128MiB. 1013 `, 1014 } 1015 DemoNodeCacheSize = FlagInfo{ 1016 Name: "cache", 1017 Description: ` 1018 Total size in bytes for caches per node, shared evenly if there are multiple 1019 storage devices. Size suffixes are supported (e.g. 1GB and 1GiB). 1020 If left unspecified, defaults to 64MiB. A percentage of physical memory 1021 can also be specified (e.g. .25).`, 1022 } 1023 1024 RunDemoWorkload = FlagInfo{ 1025 Name: "with-load", 1026 Description: `Run a demo workload against the pre-loaded database.`, 1027 } 1028 1029 DemoNodeLocality = FlagInfo{ 1030 Name: "demo-locality", 1031 Description: ` 1032 Locality information for each demo node. The input is a colon separated 1033 list of localities for each node. The i'th locality in the colon separated 1034 list sets the locality for the i'th demo cockroach node. For example: 1035 <PRE> 1036 1037 --demo-locality=region=us-east1,az=1:region=us-east1,az=2:region=us-east1,az=3 1038 1039 Assigns node1's region to us-east1 and availability zone to 1, node 2's 1040 region to us-east1 and availability zone to 2, and node 3's region 1041 to us-east1 and availability zone to 3. 1042 `, 1043 } 1044 1045 DemoGeoPartitionedReplicas = FlagInfo{ 1046 Name: "geo-partitioned-replicas", 1047 Description: ` 1048 When used with the Movr dataset, create a 9 node cluster and automatically apply 1049 the geo-partitioned replicas topology across 3 virtual regions named us-east1, us-west1, and 1050 europe-west1. This command will fail with an error if an enterprise license could not 1051 be acquired, or if the Movr dataset is not used. More information about the geo-partitioned 1052 replicas topology can be found at this URL: 1053 https://www.cockroachlabs.com/docs/v19.1/topology-geo-partitioned-replicas.html 1054 `, 1055 } 1056 1057 DemoNoLicense = FlagInfo{ 1058 Name: "disable-demo-license", 1059 Description: ` 1060 If set, disable cockroach demo from attempting to obtain a temporary license.`, 1061 } 1062 1063 UseEmptyDatabase = FlagInfo{ 1064 Name: "empty", 1065 Description: ` 1066 Start with an empty database: avoid pre-loading a default dataset in 1067 the demo shell.`, 1068 } 1069 1070 GeoLibsDir = FlagInfo{ 1071 Name: "geo-libs", 1072 Description: ` 1073 The location where all libraries for Geospatial operations is located.`, 1074 } 1075 1076 Global = FlagInfo{ 1077 Name: "global", 1078 Description: ` 1079 Simulate a global cluster. This adds artificial latencies to nodes in different 1080 regions. This flag only works with the default node localities. This setting is experimental.`, 1081 } 1082 1083 LogDir = FlagInfo{ 1084 Name: "log-dir", 1085 Description: ` 1086 If non-empty, write log files in this directory. If empty, write log files to 1087 <store-dir>/logs where <store-dir> is the directory of the first on disk store. 1088 `, 1089 } 1090 1091 LogDirMaxSize = FlagInfo{ 1092 Name: "log-dir-max-size", 1093 Description: ` 1094 Maximum combined size of all log files. 1095 `, 1096 } 1097 1098 LogFileMaxSize = FlagInfo{ 1099 Name: "log-file-max-size", 1100 Description: ` 1101 Maximum size of each log file. 1102 `, 1103 } 1104 1105 LogFileVerbosity = FlagInfo{ 1106 Name: "log-file-verbosity", 1107 Description: ` 1108 Minimum verbosity of messages written to the log file. 1109 `, 1110 } 1111 1112 WriteSize = FlagInfo{ 1113 Name: "write-size", 1114 Description: ` 1115 Size of blocks to write to storage device.`, 1116 } 1117 1118 SyncInterval = FlagInfo{ 1119 Name: "sync-interval", 1120 Description: ` 1121 Number of bytes to write before running fsync.`, 1122 } 1123 1124 BenchConcurrency = FlagInfo{ 1125 Name: "concurrency", 1126 Description: ` 1127 Number of workers for benchmarking.`, 1128 } 1129 1130 BenchDuration = FlagInfo{ 1131 Name: "duration", 1132 Description: ` 1133 Amount of time to run workers.`, 1134 } 1135 1136 BenchServer = FlagInfo{ 1137 Name: "server", 1138 Description: ` 1139 Run as server for network benchmark.`, 1140 } 1141 1142 BenchPort = FlagInfo{ 1143 Name: "port", 1144 Description: ` 1145 Port for network benchmark.`, 1146 } 1147 1148 BenchAddresses = FlagInfo{ 1149 Name: "addresses", 1150 Description: ` 1151 Addresses for network benchmark.`, 1152 } 1153 BenchLatency = FlagInfo{ 1154 Name: "latency", 1155 Description: ` 1156 Latency or throughput mode.`, 1157 } 1158 1159 ZipNodes = FlagInfo{ 1160 Name: "nodes", 1161 Description: ` 1162 List of nodes to include. Can be specified as a comma-delimited 1163 list of node IDs or ranges of node IDs, for example: 5,10-20,23. 1164 The default is to include all nodes.`, 1165 } 1166 1167 ZipExcludeNodes = FlagInfo{ 1168 Name: "exclude-nodes", 1169 Description: ` 1170 List of nodes to exclude. Can be specified as a comma-delimited 1171 list of node IDs or ranges of node IDs, for example: 5,10-20,23. 1172 The default is to not exclude any node.`, 1173 } 1174 )