Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Are you interested in knowing the set of tools provided by the google cloud? So let's learn about the Command Line Tool in GCloud
The Google Cloud CLI is a set of tools to create and to manage Google Cloud resources. You can use these tools to perform many common platform tasks from command line or through scripts and other automation.
Setup - Installing the gcloud CLI and setting up the Cloud Spanner API
You can follow the instructions on this page to set up the Cloud Spanner API for usage with the Google Cloud CLI and client libraries.
Set up a Google Cloud project
1.Open the Google Cloud console and navigate to the Projects page.
2. By clicking on the project name, you can start a brand-new Google Cloud project or access an already-existing one.
3. Set your project as the default project for the Google Cloud CLI by opening a terminal window and changing MY PROJECT ID with your project ID (not your project name):
OAuth 2.0 is used by Cloud Spanner for API authentication and authorization.
Use the Google Cloud CLI and Application Default Credentials to run your code locally while developing and testing. Open a command prompt and enter:
gcloud auth application-default login
Run the Google Cloud CLI
Run the gcloud command-line tool for interaction with the Cloud Spanner now that your development environment and authentication have been configured:
gcloud Spanner instance-configs list
Your setup is finished!
Create the database and query a database using gcloud CLI
The gcloud command-line program is used to guide you through the following tasks in this tutorial.
Set a default project
Set the ID of the Google Cloud Platform project as the default project for the Google Cloud CLI if you haven't already:
gcloud config set project PROJECT_ID
The first input to gcloud Spanner for each of the commands following must be —project PROJECT ID if the default project is not set. For Instance:
gcloud spanner --project=PROJECT_ID instance-configs list
Instances
When using Cloud Spanner for the first time, you must build an instance, which is a resource allocation that Cloud Spanner databases use. You get to pick the location of your data storage and the Instance's computation capacity when you create it.
Instances and instance configurations
You must choose an instance configuration before you can establish an instance. An instance configuration is a kind of blueprint for your Instance that specifies the geographical placement and replication of your Cloud Spanner data.
List instance configurations
When you create an instance, you give it an instance configuration, which determines the location of the database and how they will be replicated there.
Command available set of Instance for your project
gcloud Spanner instance-configs list
Create an instance
Using the regional Instance of configuration regional-us-central1 with one node, build an instance with the name test-instance and the display name My Instance.
Drop the database and get rid of the Instance you made in order to keep your Google Cloud account from being charged extra for the resources used in this tutorial.
Drop a database
To drop a database
gcloud spanner databases delete example-db
Delete an instance
To drop an instance
gcloud spanner instances delete test-instance
Frequently Asked Questions
What is a Cloud Database?
A database service created and accessible using a cloud platform is known as a cloud database.
What type of database is Cloud spanner?
Running on Google Cloud, Google Cloud Spanner is a distributed relational database service.
How do Cloud SQL and Cloud spanner differ from one another?
Cloud SQL has a 30 TB data storage capacity. More than 30 TB of data is kept in Cloud Spanner.
Is Spanner horizontally scalable?
Since Spanner automatically provides dynamic data resharding and data replication, achieving horizontal or vertical scaling requires no work.
Does cloud spanner support MySQL?
Different sets of data types are supported by Spanner versus MySQL.
Conclusion
This blog has extensively discussed Command Line Tool in GCloud, Installing gcloud CLI, etc. We hope This article was helpful and it enhanced your knowledge about the Command Line Tool in GCloud. If you want to learn more deeply, check out the excellent content on the Coding Ninjas Website: