200
cockroach start --insecure --store=node1 --host=172.16.0.200 --port=26257 --http-port=8090
189
cockroach start --insecure --store=node2 --host=172.16.0.189 --port=26258 --http-port=8091 --join=172.16.0.200:26257
199
cockroach start --insecure --store=node3 --host=172.16.0.199 --port=26259 --http-port=8092 --join=172.16.0.200:26257
30.1.0.20
cockroach start --insecure --store=node1 --host=30.1.0.20 --port=26257 --http-port=8090
30.1.0.22
cockroach start --insecure --store=node2 --host=30.1.0.22 --port=26258 --http-port=8091 --join=30.1.0.20:26257
192.168.240.92
cockroach start --insecure --store=node3 --host=192.168.240.92 --port=26259 --http-port=8092 --join=30.1.0.20:26257
cockroach sql --insecure --host=172.16.0.200 --port=26257 --database=test --user=maxroach
cockroach sql --insecure --host=172.16.0.200 --port=26257 --database=bank
cockroach sql --insecure --host=172.16.0.189 --port=26258 --database=bank
cockroach sql --insecure --host=172.16.0.199 --port=26259 --database=bank
create database bank;
set database = bank;
CREATE USER test WITH PASSWORD '123456';
GRANT CREATE ON DATABASE test TO bank;
SHOW GRANTS ON DATABASE bank;
CREATE TABLE gps_location_data
(
guid varchar(64) ,
system_id varchar(16) ,
device_id varchar(64) ,
device_alias varchar(100) ,
number_type int,
device_type int,
staff_code varchar(50),
gps_datetime timestamp,
gps_av varchar(1) ,
long_we varchar(1) ,
longitude numeric(20,16),
lat_ns varchar(1) ,
latitude numeric(20,16),
speed numeric(20,16),
direction numeric(20,16),
state varchar(256),
receive_datetime timestamp,
tsc_id int,
channel_id int,
rssi_up int,
rssi_down int,
power_mode int,
power_grage int,
angle varchar(256)
);
insert into gps_location_data (guid,receive_datetime) values('1',now())
在新终端中,作为root用户,使用该cockroach user命令创建新用户test。
create database bank;
set database = bank;
CREATE USER test WITH PASSWORD '123456';
GRANT ALL ON DATABASE bank TO test;
SHOW GRANTS ON DATABASE bank;
cockroach sql --insecure --host=172.16.0.199 --port=26259 --database=bank --user=test
wget -qO- https://binaries.cockroachdb.com/cockroach-v2.0.4.linux-amd64.tgz | tar xvz
cp -i cockroach-v2.0.4.linux-amd64/cockroach /usr/local/bin