-
Notifications
You must be signed in to change notification settings - Fork 379
/
Copy pathCreate and Manage Bigtable Instances Challenge Lab
90 lines (49 loc) · 3.69 KB
/
Create and Manage Bigtable Instances Challenge Lab
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
export ZONE=us-west4-c
export ZONE_2=us-west4-b
export REGION="${ZONE%-*}"
gcloud services disable dataflow.googleapis.com
gcloud services enable dataflow.googleapis.com
gcloud bigtable instances create ecommerce-recommendations \
--display-name=ecommerce-recommendations \
--cluster-storage-type=SSD \
--cluster-config="id=ecommerce-recommendations-c1,zone=$ZONE"
gcloud bigtable clusters update ecommerce-recommendations-c1 \
--instance=ecommerce-recommendations \
--autoscaling-max-nodes=5 \
--autoscaling-min-nodes=1 \
--autoscaling-cpu-target=60
gsutil mb gs://$DEVSHELL_PROJECT_ID
gcloud bigtable instances tables create SessionHistory \
--instance=ecommerce-recommendations \
--project=$DEVSHELL_PROJECT_ID \
--column-families=Engagements,Sales
gcloud bigtable instances tables create PersonalizedProducts \
--instance=ecommerce-recommendations \
--project=$DEVSHELL_PROJECT_ID \
--column-families=Recommendations
gcloud dataflow jobs run import-sessions --gcs-location gs://dataflow-templates-$REGION/latest/GCS_SequenceFile_to_Cloud_Bigtable --region $REGION --staging-location gs://$DEVSHELL_PROJECT_ID/temp --parameters bigtableProject=$DEVSHELL_PROJECT_ID,bigtableInstanceId=ecommerce-recommendations,bigtableTableId=SessionHistory,sourcePattern=gs://cloud-training/OCBL377/retail-engagements-sales-00000-of-00001,mutationThrottleLatencyMs=0
gcloud dataflow jobs run import-recommendations --gcs-location gs://dataflow-templates-$REGION/latest/GCS_SequenceFile_to_Cloud_Bigtable --region $REGION --staging-location gs://$DEVSHELL_PROJECT_ID/temp --parameters bigtableProject=$DEVSHELL_PROJECT_ID,bigtableInstanceId=ecommerce-recommendations,bigtableTableId=PersonalizedProducts,sourcePattern=gs://cloud-training/OCBL377/retail-recommendations-00000-of-00001
gcloud bigtable clusters create ecommerce-recommendations-c2 \
--instance=ecommerce-recommendations \
--zone=$ZONE_2
gcloud bigtable clusters update ecommerce-recommendations-c2 \
--instance=ecommerce-recommendations \
--autoscaling-max-nodes=5 \
--autoscaling-min-nodes=1 \
--autoscaling-cpu-target=60
gcloud bigtable backups create PersonalizedProducts_7 --instance=ecommerce-recommendations \
--cluster=ecommerce-recommendations-c1 \
--table=PersonalizedProducts \
--retention-period=7d
gcloud bigtable instances tables restore \
--source=projects/$DEVSHELL_PROJECT_ID/instances/ecommerce-recommendations/clusters/ecommerce-recommendations-c1/backups/PersonalizedProducts_7 \
--async \
--destination=PersonalizedProducts_7_restored \
--destination-instance=ecommerce-recommendations \
--project=$DEVSHELL_PROJECT_ID
sleep 100
gcloud dataflow jobs run import-sessions --gcs-location gs://dataflow-templates-$REGION/latest/GCS_SequenceFile_to_Cloud_Bigtable --region $REGION --staging-location gs://$DEVSHELL_PROJECT_ID/temp --parameters bigtableProject=$DEVSHELL_PROJECT_ID,bigtableInstanceId=ecommerce-recommendations,bigtableTableId=SessionHistory,sourcePattern=gs://cloud-training/OCBL377/retail-engagements-sales-00000-of-00001,mutationThrottleLatencyMs=0
gcloud dataflow jobs run import-recommendations --gcs-location gs://dataflow-templates-$REGION/latest/GCS_SequenceFile_to_Cloud_Bigtable --region $REGION --staging-location gs://$DEVSHELL_PROJECT_ID/temp --parameters bigtableProject=$DEVSHELL_PROJECT_ID,bigtableInstanceId=ecommerce-recommendations,bigtableTableId=PersonalizedProducts,sourcePattern=gs://cloud-training/OCBL377/retail-recommendations-00000-of-00001
gcloud bigtable backups delete PersonalizedProducts_7 --instance=ecommerce-recommendations \
--cluster=ecommerce-recommendations-c1 --quiet
gcloud bigtable instances delete ecommerce-recommendations --quiet