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: countries, departments, 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
반응형
'클라우드 > GCP' 카테고리의 다른 글
19. Administering an AlloyDB Database (0) | 2024.11.27 |
---|---|
18. Migrating to AlloyDB from PostgreSQL Using Database Migration Service (0) | 2024.11.26 |
16. Connect an App to a Cloud SQL for PostgreSQL Instance (0) | 2024.11.24 |
15. Migrate to Cloud SQL for PostgreSQL using Database Migration Service (0) | 2024.11.23 |
14. Cloud Composer: Copying BigQuery Tables Across Different Locations (0) | 2024.11.22 |