1#Geo-Partitioning
2#execute below query from same machines Windows/Linux
3
4cockroach start --insecure --locality=country=us,region=us-east --store=node1 --listen-addr=localhost:26257 --http-addr=localhost:8080 --join=localhost:26257,localhost:26258,localhost:26259
5cockroach start --insecure --locality=country=us,region=us-east --store=node2 --listen-addr=localhost:26258 --http-addr=localhost:8081 --join=localhost:26257,localhost:26258,localhost:26259
6cockroach start --insecure --locality=country=us,region=us-east --store=node3 --listen-addr=localhost:26259 --http-addr=localhost:8082 --join=localhost:26257,localhost:26258,localhost:26259
7cockroach start --insecure --locality=country=us,region=us-central --store=node4 --listen-addr=localhost:26260 --http-addr=localhost:8083 --join=localhost:26257,localhost:26258,localhost:26259
8cockroach start --insecure --locality=country=us,region=us-central --store=node5 --listen-addr=localhost:26261 --http-addr=localhost:8084 --join=localhost:26257,localhost:26258,localhost:26259
9cockroach start --insecure --locality=country=us,region=us-central --store=node6 --listen-addr=localhost:26262 --http-addr=localhost:8085 --join=localhost:26257,localhost:26258,localhost:26259
10cockroach start --insecure --locality=country=us,region=us-west --store=node7 --listen-addr=localhost:26263 --http-addr=localhost:8086 --join=localhost:26257,localhost:26258,localhost:26259
11cockroach start --insecure --locality=country=us,region=us-west --store=node8 --listen-addr=localhost:26264 --http-addr=localhost:8087 --join=localhost:26257,localhost:26258,localhost:26259
12cockroach start --insecure --locality=country=us,region=us-west --store=node9 --listen-addr=localhost:26265 --http-addr=localhost:8088 --join=localhost:26257,localhost:26258,localhost:26259
13cockroach init --insecure --host=localhost:26257
14cockroach workload init movr
15cockroach sql --execute="SET CLUSTER SETTING cluster.organization = '<enter_cluster_org_here>'; SET CLUSTER SETTING enterprise.license = '<enter_license_here>';"
16
17#SQL Shell
18SHOW RANGES FROM TABLE movr.vehicles;
19
20ALTER TABLE movr.vehicles
21PARTITION BY LIST (city) (
22 PARTITION new_york VALUES IN ('new york'),
23 PARTITION boston VALUES IN ('boston'),
24 PARTITION washington_dc VALUES IN ('washington dc'),
25 PARTITION seattle VALUES IN ('seattle'),
26 PARTITION san_francisco VALUES IN ('san francisco'),
27 PARTITION los_angeles VALUES IN ('los angeles')
28);
29
30ALTER PARTITION new_york OF TABLE movr.vehicles
31CONFIGURE ZONE USING constraints='[+region=us-east]';
32
33ALTER PARTITION boston OF TABLE movr.vehicles
34CONFIGURE ZONE USING constraints='[+region=us-east]';
35
36ALTER PARTITION washington_dc OF TABLE movr.vehicles
37CONFIGURE ZONE USING constraints='[+region=us-central]';
38
39ALTER PARTITION seattle OF TABLE movr.vehicles
40CONFIGURE ZONE USING constraints='[+region=us-west]';
41
42ALTER PARTITION san_francisco OF TABLE movr.vehicles
43CONFIGURE ZONE USING constraints='[+region=us-west]';
44
45ALTER PARTITION los_angeles OF TABLE movr.vehicles
46CONFIGURE ZONE USING constraints='[+region=us-west]';
47
48SELECT start_key, end_key, lease_holder_locality, replicas, replica_localities FROM [SHOW RANGES FROM TABLE movr.vehicles]
49WHERE "start_key" NOT LIKE '%Prefix%' AND "end_key" NOT LIKE '%Prefix';