安裝
wget -qO- https://binaries.cockroachdb.com/cockroach-v2.1.0.linux-amd64.tgz | tar xvz
cp -i cockroach-v2.1.0.linux-amd64/cockroach /usr/local/bin
創(chuàng)建證書
mkdir certs my-safe-directory
cockroach cert create-ca --certs-dir=certs --ca-key=my-safe-directory/ca.key
cockroach cert create-node localhost 0.0.0.0 --certs-dir=certs --ca-key=my-safe-directory/ca.key
#為root用戶創(chuàng)建證書(連接用僧凰,不必須)
cockroach cert create-client root --certs-dir=certs --ca-key=my-safe-directory/ca.key
啟動多個節(jié)點
#寫成腳本
#!/bin/bash
cockroach start \
--certs-dir=certs \
--store=node1 \
--host=0.0.0.0 \
--port=11111 \
--http-port=8081 \
--join=0.0.0.0:11111,0.0.0.0:11112,0.0.0.0:11113 \
--background
cockroach start \
--certs-dir=certs \
--store=node2 \
--host=0.0.0.0 \
--port=11112 \
--http-port=8082 \
--join=0.0.0.0:11111,0.0.0.0:11112,0.0.0.0:11113 \
--background
cockroach start \
--certs-dir=certs \
--store=node3 \
--host=0.0.0.0 \
--port=11113 \
--http-port=8083 \
--join=0.0.0.0:11111,0.0.0.0:11112,0.0.0.0:11113 \
--background
訪問adminUI
- 瀏覽器輸入ip地址加節(jié)點端口
命令行參數(shù)
如果指定了端口奇瘦,使用命令行必須指定端口
#查看節(jié)點狀態(tài) 如果是默認(rèn)端口可以省略--port
cockroach node status --certs-dir=certs --port=11111
#進(jìn)入sql命令交互
cockroach sql --certs-dir=certs --port=11111
停止多有節(jié)點
pkill cockroach