[go: up one dir, main page]

100% found this document useful (1 vote)
27 views2 pages

Labs AlloyDB

The document shows how to create an AlloyDB cluster and instance, create tables to store region, country and department data, insert sample data, create a read pool instance, and take a backup of the database.

Uploaded by

xiyoge5514
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
27 views2 pages

Labs AlloyDB

The document shows how to create an AlloyDB cluster and instance, create tables to store region, country and department data, insert sample data, create a read pool instance, and take a backup of the database.

Uploaded by

xiyoge5514
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

ping -c 3 <10.138.0.

2>

export ALLOYDB=172.23.0.2

Change3Me

Task 1. Create a cluster and instance

gcloud beta alloydb clusters create lab-cluster \


--password=Change3Me \
--network=peering-network \
--region=us-central1 \
--project=qwiklabs-gcp-03-8685fe1045fa

gcloud beta alloydb instances create lab-instance \


--instance-type=PRIMARY \
--cpu-count=2 \
--region=us-central1 \
--cluster=lab-cluster \
--project=qwiklabs-gcp-03-8685fe1045fa

CREATE TABLE regions (


region_id bigint NOT NULL,
region_name varchar(25)
);
ALTER TABLE regions ADD PRIMARY KEY (region_id);

CREATE TABLE countries (


country_id char(2) NOT NULL,
country_name varchar(40),
region_id bigint
);
ALTER TABLE countries ADD PRIMARY KEY (country_id);

CREATE TABLE departments (


department_id smallint NOT NULL,
department_name varchar(30),
manager_id integer,
location_id smallint
);
ALTER TABLE departments ADD PRIMARY KEY (department_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');

INSERT INTO countries VALUES ('IT', 'Italy', 1);


INSERT INTO countries VALUES ('JP', 'Japan', 3 );
INSERT INTO countries VALUES ('US', 'United States of America', 2 );
INSERT INTO countries VALUES ('CA', 'Canada', 2 );
INSERT INTO countries VALUES ('CN', 'China', 3 );
INSERT INTO countries VALUES ('IN', 'India', 3 );
INSERT INTO countries VALUES ('AU', 'Australia', 3);
INSERT INTO countries VALUES ('ZW', 'Zimbabwe', 4 );
INSERT INTO countries VALUES ('SG', 'Singapore', 3 );

INSERT INTO departments VALUES (10, 'Administration', 200, 1700);


INSERT INTO departments VALUES (20, 'Marketing', 201, 1800);
INSERT INTO departments VALUES (30, 'Purchasing', 114, 1700);
INSERT INTO departments VALUES (40, 'Human Resources', 203, 2400);
INSERT INTO departments VALUES (50, 'Shipping', 121, 1500);
INSERT INTO departments VALUES (60, 'IT', 103, 1400);

Task 4. Create a Read Pool instance


gcloud beta alloydb instances create lab-instance-rp1 \
--instance-type=READ_POOL \
--cpu-count=2 \
--read-pool-node-count=2 \
--region=us-central1 \
--cluster=lab-cluster \
--project=qwiklabs-gcp-03-8685fe1045fa

Task 5. Create a backup

gcloud beta alloydb backups create lab-backup \


--cluster=lab-cluster \
--region=us-central1 \
--project=qwiklabs-gcp-03-8685fe1045fa

You might also like