Using Google Cloud with Linux
1. Introduction
Google Cloud Platform (GCP) is a suite of cloud computing services that runs on the same infrastructure that Google uses internally for its end-user products. This tutorial will guide you through the steps to use Google Cloud with a Linux operating system.
2. Setting Up Google Cloud SDK on Linux
Google Cloud SDK is a set of tools that you can use to manage resources and applications hosted on Google Cloud. Follow these steps to install and set up Google Cloud SDK on your Linux machine:
Open your terminal and run the following commands to install Google Cloud SDK:
sudo apt-get update sudo apt-get install apt-transport-https ca-certificates gnupg echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list sudo apt-get install curl curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - sudo apt-get update sudo apt-get install google-cloud-sdk
To initialize the Google Cloud SDK, run:
gcloud init
Follow the on-screen instructions to authenticate and configure the SDK.
3. Creating and Managing Virtual Machines
Google Compute Engine lets you create and run virtual machines on Google infrastructure. Here’s how to create and manage VMs:
To create a new VM instance, run:
gcloud compute instances create INSTANCE_NAME --zone=ZONE_NAME
Replace INSTANCE_NAME
with your desired instance name and ZONE_NAME
with the zone where you want to create the instance.
To list all VM instances, run:
gcloud compute instances list
To stop a VM instance, run:
gcloud compute instances stop INSTANCE_NAME --zone=ZONE_NAME
To start a VM instance, run:
gcloud compute instances start INSTANCE_NAME --zone=ZONE_NAME
4. Setting Up Cloud Storage
Google Cloud Storage is a service for storing and accessing data on Google's infrastructure. Here’s how to use it with Linux:
To create a new storage bucket, run:
gsutil mb gs://BUCKET_NAME
Replace BUCKET_NAME
with your desired bucket name.
To upload a file to the bucket, run:
gsutil cp FILE_PATH gs://BUCKET_NAME
Replace FILE_PATH
with the path to your file.
To list all files in a bucket, run:
gsutil ls gs://BUCKET_NAME
5. Setting Up Cloud SQL
Google Cloud SQL is a fully-managed database service that makes it easy to set up, maintain, manage, and administer relational databases on Google Cloud Platform. Follow these steps to set up Cloud SQL:
To create a new Cloud SQL instance, run:
gcloud sql instances create INSTANCE_NAME --database-version=MYSQL_5_7 --tier=db-n1-standard-1 --region=REGION_NAME
Replace INSTANCE_NAME
with your desired instance name and REGION_NAME
with the region where you want to create the instance.
To connect to your Cloud SQL instance, run:
gcloud sql connect INSTANCE_NAME --user=root
Replace INSTANCE_NAME
with your instance name.
6. Conclusion
In this tutorial, we covered the basics of using Google Cloud with a Linux operating system. We went through the steps to set up Google Cloud SDK, create and manage VM instances, use Google Cloud Storage, and set up Cloud SQL. With these tools and commands, you can effectively manage your Google Cloud resources from a Linux environment.