
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create a secure, highly available SQL Server database using Cloud SQL
/ 20
Perform backup and restore operations
/ 30
Connect to the database using its private IP address
/ 30
Trigger a failover to test high availability
/ 20
In this lab, you create a SQL Server database using Cloud SQL. You enable high availability and deploy it securely with only a private IP address. You then load a sample database into it and connect to the database using a client machine. You also perform backup and restore operations and test high availability by triggering a failover.
In this lab, you learn how to perform the following tasks:
In this task, you use Qwiklabs and perform initialization steps for your lab.
For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
Sign in to Qwiklabs using an incognito window.
Note the lab's access time (for example, 1:15:00
), and make sure you can finish within that time.
There is no pause feature. You can restart if needed, but you have to start at the beginning.
When ready, click Start lab.
Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.
Click Open Google Console.
Click Use another account and copy/paste credentials for this lab into the prompts.
If you use other credentials, you'll receive errors or incur charges.
Accept the terms and skip the recovery resource page.
Open a new web browser window and navigate to the Google Cloud Console (console.cloud.google.com). Use the project selector to choose the first project with a leading name of 'qwiklabs-gcp.'
On the Navigation menu (), click SQL.
Click Create Instance, and then select SQL Server.
For Instance ID, type sql-server, and then for Password, click Generate.
Copy and paste your generated password into a text file so you don't lose it. (If you prefer, you can enter a password that you can remember.)
For Database version, select the default SQL Server 2019 Standard edition of SQL Server.
For Choose region and zonal availability set the region to
Click Show Configuration Options and expand the Machine configuration section. Change the machine type to 4vCPUs, 16GB.
Expand the Storage section and select 20 GB for Storage capacity. Also, make sure that Enable automatic storage increases option is selected.
Expand the Connections section.
Select Private IP and choose default network from the dropdown menu.
Click on Set Up Connection and then in the dialog, click on Enable API.
For Allocate an IP range, select Use an automatically allocated IP range and click Continue.
Click Create connection (this will take a minute), and then clear Public IP.
Expand the Data Protection section and note that Automate daily backups is selected.
Click Create Instance to create your database server.
(This will take a few minutes, but you can continue with the next few steps while you are waiting.)
Click Check my progress to verify the objective.
Click Activate Cloud Shell () in the upper-right corner of the Console. If prompted click Continue.
The Cloud Shell terminal will open in a pane at the bottom of the window.
To download a sample database to use in this exercise, enter the following command:
Type ls.
A SQL backup file named AdventureWorksLT2017.bak is listed that allows you to restore the Microsoft Adventure Works sample database.
In Cloud Shell,to see the environment variable that is set to your current project's ID, run the following command:
Look at your Cloud SQL server in the Console. If it is ready, continue; otherwise, take a short break.
When the server is ready, click its name to see its details.
On the Overview page, click Import.
Browse to your bucket and select the AdventureWorksLT2017.bak file.
Under Destination, name the database AdventureWorks, and then click Import.
(It will take a short time for the import to complete.)
When the import job completes, click the Backups link on the left.
Backups are set to run automatically, but click Create backup now.
For Description, type Initial AdventureWorks backup and click Create. (It will take a short time for the backup to complete.)
Click the Operations link on the left, it tracks what has happened on the database so far.
Click Check my progress to verify the objective.
A user named sqlserver is automatically created for you. The password for this user is the one you generated when you created the database. (You should have pasted the password in a text file. You can create additional users now if you want to.)
When the command completes, navigate to the Compute Engine > VM Instance service to see your virtual machine, and then click SSH in the row for that machine.
To download the Microsoft SQL Server client software, run the following commands:
When prompted, select Yes.
To add the client software to your path, run the following commands:
Enter your password when prompted.
To see the databases, enter the following two commands separately and in order:
SELECT
query again:The results are not quite accurate.
To proceed to restore the backup you created earlier, return to Cloud SQL in the Console. Select your server to view its details, and then click the Backups link.
Click Restore next to your backup, then select Overwrite the source instance (sql-server) as restore destination and then enter the instance name as instructed and click Restore. (This will take a few minutes.)
When the restore operation completes, return to your client machine and run the SELECT
query again to confirm that your backup was restored correctly:
Click Check my progress to verify the objective.
Return to your Cloud SQL database Overview page, and at the top, click Failover.
Enter the database name as instructed, and click Trigger Failover.
It will take about a minute for the failover operation to finish.
When the operation completes, return to your client and run your query again.
To change to one of the records, run the following command:
Click Check my progress to verify the objective.
Return to the Overview page, click Failover to return to the main database, and then confirm that the change made on the Failover is reflected on the main server.
To delete the database, from the Overview page, click Delete and follow the instructions. You can also go to the Compute Engine service and delete the client machine.
You have created a SQL Server database using Cloud SQL. You enabled high availability and deployed it securely with only a private IP address. You then loaded a sample database into it and connected to the database using a client machine. You also performed backup and restore operations and tested high availability by triggering a failover.
When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one