Terriermon - Digimon

17. AlloyDB - Database Fundamentals

2024. 11. 25. 14:02클라우드/GCP

 PostgreSQL 인스턴스와 데이터베이스용 AlloyDB 생성 및 관리 test

 

Task 1. Create a cluster and instance

 

Task 2. Create tables and insert data in your database

export ALLOYDB=ALLOYDB_ADDRESS
echo $ALLOYDB  > alloydbip.txt
psql -h $ALLOYDB -U postgres

 

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' );
SELECT region_id, region_name from regions;

\q 입력하여 psql 클라이언트를 종료

 

Run the following command to download a file containing DDL and DML for three tables: countriesdepartments, and jobs.

gsutil cp gs://cloud-training/OCBL403/hrm_load.sql hrm_load.sql

\dt

 

 

Run a spot check query to examine the data in one of the tables you just created and loaded.

select job_title, max_salary
from jobs
order by max_salary desc;

 

Task 3. Use the Google Cloud CLI with AlloyDB

Create a cluster and instance with CLI

gcloud beta alloydb clusters create gcloud-lab-cluster \
    --password=Change3Me \
    --network=peering-network \
    --region=us-east1 \
    --project=qwiklabs-gcp-04-77fb03a73d99

 

gcloud beta alloydb instances create gcloud-lab-instance\
    --instance-type=PRIMARY \
    --cpu-count=2 \
    --region=us-east1  \
    --cluster=gcloud-lab-cluster \
    --project=qwiklabs-gcp-04-77fb03a73d99
gcloud beta alloydb clusters list

 

Task 4. Deleting a cluster

gcloud beta alloydb clusters delete gcloud-lab-cluster \
    --force \
    --region=us-east1 \
    --project=qwiklabs-gcp-04-77fb03a73d99

 

gcloud beta alloydb clusters list

 

 

 

참고: https://www.cloudskillsboost.google/course_templates/642/labs/501230?locale=ko

 

AlloyDB - Database Fundamentals | Google Cloud Skills Boost

In this lab, you perform several key fundamental tasks for creating and managing AlloyDB for PostgreSQL instances and databases.

www.cloudskillsboost.google

 

반응형