CockroachDB

Download the CockroachDB archive for Linux, and extract the binary:
wget https://binaries.cockroachdb.com/cockroach-v1.1.3.linux-amd64.tgz
tar  xvf cockroach-v1.1.3.linux-amd64.tgz

Copy the binary into your PATH so it's easy to execute cockroach commands from any shell:
cp -i cockroach-v1.1.3.linux-amd64/cockroach /usr/local/bin

Start the first node

[root@ep2017-ibm-com ~]# cockroach start --insecure --store=node1 --host=192.168.101.131 --port=26257 --http-port=8081
*
* WARNING: RUNNING IN INSECURE MODE!
*
* - Your cluster is open for any client that can access localhost.
* - Any user, even root, can log in without providing a password.
* - Any user, connecting as root, can read or write any data in your cluster.
* - There is no network encryption nor authentication, and thus no confidentiality.
*
* Check out how to secure your cluster: https://www.cockroachlabs.com/docs/stable/secure-a-cluster.html
*
CockroachDB node starting at 2017-12-08 07:24:43.58661657 +0000 UTC (took 4.4s)
build:      CCL v1.1.3 @ 2017/11/27 13:59:10 (go1.8.3)
admin:      http://localhost:8081
sql:        postgresql://root@localhost:26257?application_name=cockroach&sslmode=disable
logs:       /root/node1/logs
store[0]:   path=/root/node1
status:     initialized new cluster
clusterID:  92c18780-485c-4d40-9910-35f7e69ed4e5
nodeID:     1


Step 2. Add nodes to the cluster
[root@ep2017-ibm-com ~]# cockroach start --insecure --store=node2 --host=192.168.101.131 --port=26258 --http-port=8082 --join=192.168.101.131:26257
*
* WARNING: RUNNING IN INSECURE MODE!
*
* - Your cluster is open for any client that can access localhost.
* - Any user, even root, can log in without providing a password.
* - Any user, connecting as root, can read or write any data in your cluster.
* - There is no network encryption nor authentication, and thus no confidentiality.
*
* Check out how to secure your cluster: https://www.cockroachlabs.com/docs/stable/secure-a-cluster.html
*
CockroachDB node starting at 2017-12-08 07:30:22.908958873 +0000 UTC (took 0.6s)
build:      CCL v1.1.3 @ 2017/11/27 13:59:10 (go1.8.3)
admin:      http://localhost:8082
sql:        postgresql://root@localhost:26258?application_name=cockroach&sslmode=disable
logs:       /root/node2/logs
store[0]:   path=/root/node2
status:     initialized new node, joined pre-existing cluster
clusterID:  92c18780-485c-4d40-9910-35f7e69ed4e5
nodeID:     2

[root@ep2017-ibm-com ~]# cockroach start --insecure --store=node3 --host=192.168.101.131 --port=26259 --http-port=8083 --join=192.168.101.131:26257
*
* WARNING: RUNNING IN INSECURE MODE!
*
* - Your cluster is open for any client that can access localhost.
* - Any user, even root, can log in without providing a password.
* - Any user, connecting as root, can read or write any data in your cluster.
* - There is no network encryption nor authentication, and thus no confidentiality.
*
* Check out how to secure your cluster: https://www.cockroachlabs.com/docs/stable/secure-a-cluster.html
*
CockroachDB node starting at 2017-12-08 07:31:17.98479275 +0000 UTC (took 0.7s)
build:      CCL v1.1.3 @ 2017/11/27 13:59:10 (go1.8.3)
admin:      http://localhost:8083
sql:        postgresql://root@localhost:26259?application_name=cockroach&sslmode=disable
logs:       /root/node3/logs
store[0]:   path=/root/node3
status:     initialized new node, joined pre-existing cluster
clusterID:  92c18780-485c-4d40-9910-35f7e69ed4e5
nodeID:     3


Step 3. Test the cluster


[root@ep2017-ibm-com ~]# cockroach sql --insecure --host=192.168.101.131
# Welcome to the cockroach SQL interface.
# All statements must be terminated by a semicolon.
# To exit: CTRL + D.
#
# Server version: CockroachDB CCL v1.1.3 (linux amd64, built 2017/11/27 13:59:10, go1.8.3) (same version as client)
# Cluster ID: 92c18780-485c-4d40-9910-35f7e69ed4e5
#
# Enter \? for a brief introduction.
#
root@:26257/> CREATE DATABASE bank;
CREATE DATABASE

Time: 288.312337ms

root@:26257/> CREATE TABLE bank.accounts (id INT PRIMARY KEY, balance DECIMAL);
CREATE TABLE

Time: 290.842263ms

root@:26257/> INSERT INTO bank.accounts VALUES (1, 1000.50);
INSERT 1

Time: 262.36214ms

root@:26257/> SELECT * FROM bank.accounts;
+----+---------+
| id | balance |
+----+---------+
|  1 | 1000.50 |
+----+---------+
(1 row)

Time: 2.838724ms

root@:26257/> \q
[root@ep2017-ibm-com ~]# cockroach sql --insecure --host=192.168.101.131 --port=26258
# Welcome to the cockroach SQL interface.
# All statements must be terminated by a semicolon.
# To exit: CTRL + D.
#
# Server version: CockroachDB CCL v1.1.3 (linux amd64, built 2017/11/27 13:59:10, go1.8.3) (same version as client)
# Cluster ID: 92c18780-485c-4d40-9910-35f7e69ed4e5
#
# Enter \? for a brief introduction.
#
root@:26258/> SELECT * FROM bank.accounts;
+----+---------+
| id | balance |
+----+---------+
|  1 | 1000.50 |
+----+---------+
(1 row)

Time: 141.337638ms

root@:26258/> \q
[tester@ep2017-ibm-com ~]$ cockroach sql --insecure --host=192.168.101.131 --port=26259
# Welcome to the cockroach SQL interface.
# All statements must be terminated by a semicolon.
# To exit: CTRL + D.
#
# Server version: CockroachDB CCL v1.1.3 (linux amd64, built 2017/11/27 13:59:10, go1.8.3) (same version as client)
# Cluster ID: 7e13e521-e449-41c6-8d93-8752c215ab43
#
# Enter \? for a brief introduction.
#
root@192.168.101.131:26259/> SELECT * FROM bank.accounts;
+----+-----------+
| id |  balance  |
+----+-----------+
|  1 |   1000.50 |
|  2 |    2000.5 |
|  3 |    4000.5 |
|  4 | 6000000.7 |
|  5 | 987897.45 |
+----+-----------+
(5 rows)

Time: 156.072985ms

root@192.168.101.131:26259/> \q
[tester@ep2017-ibm-com ~]$


Step 4. Monitor the cluster
admin:      http://localhost:8081



请使用浏览器的分享功能分享到微信等