-
Notifications
You must be signed in to change notification settings - Fork 353
/
AlloyDB - Database Fundamentals
60 lines (43 loc) · 1.51 KB
/
AlloyDB - Database Fundamentals
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
export ZONE=$(gcloud compute instances list alloydb-client --format 'csv[no-heading](zone)')
export REGION="${ZONE%-*}"
gcloud beta alloydb clusters create lab-cluster \
--password=Change3Me \
--network=peering-network \
--region=$REGION \
--project=$DEVSHELL_PROJECT_ID
gcloud beta alloydb instances create lab-instance\
--instance-type=PRIMARY \
--cpu-count=2 \
--region=$REGION \
--cluster=lab-cluster \
--project=$DEVSHELL_PROJECT_ID
gcloud compute ssh alloydb-client --project=$DEVSHELL_PROJECT_ID --zone=$ZONE --quiet
export ALLOYDB=
https://console.cloud.google.com/alloydb/clusters?
echo $ALLOYDB > alloydbip.txt
psql -h $ALLOYDB -U postgres
Change3Me
CREATE TABLE regions (
region_id bigint NOT NULL,
region_name varchar(25)
) ;
ALTER TABLE regions ADD PRIMARY KEY (region_id);
INSERT INTO regions VALUES ( 1, 'Europe' );
INSERT INTO regions VALUES ( 2, 'Americas' );
INSERT INTO regions VALUES ( 3, 'Asia' );
INSERT INTO regions VALUES ( 4, 'Middle East and Africa' );
\q
exit
export ZONE=$(gcloud compute instances list alloydb-client --format 'csv[no-heading](zone)')
export REGION="${ZONE%-*}"
gcloud beta alloydb clusters create gcloud-lab-cluster \
--password=Change3Me \
--network=peering-network \
--region=$REGION \
--project=$DEVSHELL_PROJECT_ID
gcloud beta alloydb instances create gcloud-lab-instance\
--instance-type=PRIMARY \
--cpu-count=2 \
--region=$REGION \
--cluster=gcloud-lab-cluster \
--project=$DEVSHELL_PROJECT_ID