3.5 Cockroach命令
使用cockroachDB命令配置管理使用一個cockroachDB的集羣,登陸標識可以設置環境變量。
可以運行cockroachhelp在你的shell中或者相似指引。
**部分未翻譯
zone: 配置具體數據集中副本集的位置和數量
gen: 管理腳本,實例SQL數據,或者HAProxy 配置文件
3.5.1 cockroach help
[root@localhost cockroach-v1.1.4]# cockroach help
CockroachDB command-line interface and server.
Usage:
cockroach [command]
Available Commands:
start start a node
init initialize a cluster
cert create ca, node, and client certs
quit drain and shutdown node
sql open a sql shell
user get, set, list and remove users
zone get, set, list and remove zones
node list, inspect or remove nodes
dump dump sql tables
gen generate auxiliary files
version output version information
debug debugging commands
load loading commands
help Help about any command
Flags:
--log-backtrace-at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log-dir string if non-empty, write log files in this directory
--log-dir-max-size bytes maximum combined size of all log files (default 100 MiB)
--log-file-max-size bytes maximum size of each log file (default 10 MiB)
--log-file-verbosity Severity minimum verbosity of messages written to the log file (default INFO)
--logtostderr Severity[=DEFAULT] logs at or above this threshold go to stderr (default NONE)
--no-color disable standard error log colorization
--verbosity level log level for V logs
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging
Use "cockroach [command] --help" for more information about a command.
3.5.2 Cockroach version
[root@localhost cockroach-v1.1.4]# cockroach version
Build Tag: v1.1.4
Build Time: 2018/01/08 17:32:42
Distribution: CCL
Platform: linux amd64
Go Version: go1.8.3
C Compiler: gcc 6.3.0
Build SHA-1: b794b52cbfffa2340cdaabf1c33be716ebde1db4
Build Type: release-gnu
環境變量:
對於cockroach的標識,例如--port和 --user,你可以一次性的設置環境變量,不需要每次執行命令手動輸入
--輸出上千的cockroachDB或者其他環境的配置使用env
--使用環境變量startup,變量名被打印到節點的log中,但是變量值不打印
Cockroach優先級
當使用命令行設置一個flag,cockroach使用它
當命令行沒有設置,cockroach使用相應的環境變量
當命令行和環境變量都沒設置,使用默認的flag
否則,報錯
3.5.3 Cockroach start
https://www.cockroachlabs.com/docs/stable/start-a-node.html#standard-output
--advertise-host 主機名或者ip告知其他節點,如果是主機名,必須被所有節點解析,如果是ip,可以被所有節點路由,如果沒有設置,講尋找 –host參數
--attrs 任意字符串,以冒號分隔,定義節點的容量,或者其他具體的硬件,如核數。--attrs=ram:64gb ,影響數據副本的位置