-
Notifications
You must be signed in to change notification settings - Fork 0
/
roachprod-mr-tpcc.sh
95 lines (84 loc) · 6.74 KB
/
roachprod-mr-tpcc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
############################
# Standard Roachprod Demos
############################
export CLUSTER="${USER:0:6}-test"
export NODES=18
export CNODES=$(($NODES-1))
export VERSION=v20.2.11
### Create
#roachprod create ${CLUSTER} -n ${NODES} -c gce --gce-zones us-west2-a:5,us-east2-a:7,europe-central2-a:3,asia-northeast2-a:3
#roachprod create ${CLUSTER} -n ${NODES} -c gce --geo
roachprod create ${CLUSTER} -n ${NODES} -c aws --aws-zones us-east-2a:7,us-west-2a:5,eu-west-2b:3,ap-northeast-2a:3
roachprod stage ${CLUSTER} workload
roachprod stage ${CLUSTER} release ${VERSION}
roachprod start ${CLUSTER}
roachprod admin ${CLUSTER}:18 --open --ips
roachprod pgurl ${CLUSTER}:1
roachprod put ${CLUSTER}:1 *.sql
# init workload takes 35 minutes, this creates 4.5MM customer records
date
roachprod run ${CLUSTER}:1 -- "./cockroach workload init tpcc --warehouses=150 --db=tpcc"
date
# change schema
roachprod run ${CLUSTER}:1 "./cockroach sql --insecure < gpleaseholder.sql"
roachprod run ${CLUSTER}:1 "./cockroach sql --insecure < gpreplica.sql"
# wait for replication to complete
sleep 5m
# verify replica placement
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"SELECT start_key, lease_holder, lease_holder_locality, replicas
FROM [SHOW RANGES FROM table tpcc.customer]
WHERE start_key IS NOT NULL
AND start_key NOT LIKE '%Prefix%' ORDER BY lease_holder;\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"SELECT start_key, lease_holder, lease_holder_locality, replicas
FROM [SHOW RANGES FROM table tpcc.order_line]
WHERE start_key IS NOT NULL
AND start_key NOT LIKE '%Prefix%' ORDER BY lease_holder;\" "
# show us east and eu range and replication
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select replica_localities from [show range from table tpcc.order_line for row (0,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select replica_localities from [show range from table tpcc.order_line for row (10,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select replica_localities from [show range from table tpcc.order_line for row (20,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select replica_localities from [show range from table tpcc.order_line for row (30,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select replica_localities from [show range from table tpcc.order_line for row (40,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select replica_localities from [show range from table tpcc.order_line for row (50,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select replica_localities from [show range from table tpcc.order_line for row (60,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select replica_localities from [show range from table tpcc.order_line for row (70,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select replica_localities from [show range from table tpcc.order_line for row (80,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select replica_localities from [show range from table tpcc.order_line for row (90,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select replica_localities from [show range from table tpcc.order_line for row (100,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select replica_localities from [show range from table tpcc.order_line for row (110,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select replica_localities from [show range from table tpcc.order_line for row (120,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select replica_localities from [show range from table tpcc.order_line for row (130,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select replica_localities from [show range from table tpcc.order_line for row (140,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select replica_localities from [show range from table tpcc.order_line for row (149,1,3000,1)];\" "
# add load - not enough load -- some rows doesn't have results
#roachprod run ${CLUSTER}:2 -- './cockroach workload run tpcc --concurrency 32'
# update cluster setting
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"set cluster setting server.time_until_store_dead='2m0s'; \" "
# take down us-east region
roachprod stop ${CLUSTER}:1-7
# sleep for 1m for CRDB to consider them dead
sleep 120
# wait for it to stabilize
sleep 600
# verify how GP Replica table changes
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"SELECT start_key, lease_holder, lease_holder_locality, replicas
FROM [SHOW RANGES FROM table tpcc.customer]
WHERE start_key IS NOT NULL
AND start_key NOT LIKE '%Prefix%' ORDER BY lease_holder;\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select start_key, replica_localities from [show range from table tpcc.order_line for row (0,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select start_key, replica_localities from [show range from table tpcc.order_line for row (10,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select start_key, replica_localities from [show range from table tpcc.order_line for row (20,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select start_key, replica_localities from [show range from table tpcc.order_line for row (30,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select start_key, replica_localities from [show range from table tpcc.order_line for row (40,1,3000,1)];\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"select start_key, replica_localities from [show range from table tpcc.order_line for row (59,1,3000,1)];\" "
# bring back us east
roachprod start ${CLUSTER}:1-7
sleep 600
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"SELECT start_key, lease_holder, lease_holder_locality, replicas
FROM [SHOW RANGES FROM table tpcc.customer]
WHERE start_key IS NOT NULL
AND start_key NOT LIKE '%Prefix%' ORDER BY lease_holder;\" "
roachprod run ${CLUSTER}:18 -- "./cockroach sql --insecure --execute \"SELECT start_key, lease_holder, lease_holder_locality, replicas
FROM [SHOW RANGES FROM table tpcc.order_line]
WHERE start_key IS NOT NULL
AND start_key NOT LIKE '%Prefix%' ORDER BY lease_holder;\" "