Lab Review: Cloud SQL
1. Lab Review: Cloud SQL
In this lab, you created a Cloud SQL database and configured it to use both an external connection over a secure proxy and a private IP address, which is more secure and performant. If your application is hosted in another region, VPC, or even project, use a proxy to secure its connection over the external connection. You can stay for a lab walkthrough, but remember that Google Cloud's user interface can change, so your environment might look slightly different. Welcome to the lab walkthrough for implementing Cloud SQL. At this point in the lab, I have logged in with the username and password that QwikLabs has provided me. My first task is to create a Cloud SQL database. And go here to SQL, And hit Create Instance. I'm going to choose my SQL, And I'm going to call this wordpress-db. For password I'm just going to use the word password, so that I make sure I'm not forgetting it. I recommend you use something very simple. I'm going to use US Central 1. I am going to expand the configuration options, and then in Connectivity I'm going to select the private IP. Hit Enable API, and once that's been enabled, which could take a couple of seconds, I'm going to hit Allocate and Connect. And just so you know, this could take three to five minutes, so just be patient. Once that's done, it is going to make this Create button enabled. Feel free to look through some of the other things that it's calling out in the lab, like configuring the machine type and changing the storage capacity. If you add a couple of zeros, you can see the throughput increases. Set it back to 10, hit Close here. Again, this could take three to five minutes, so be patient. Once it's done, it'll say Create here. All right, so my IP has been allocated, and now I can hit Create. Here we go. And now, that took a while, but creating your Cloud SQL instance or Cloud SQL instance, might take even longer. So be patient, but while this is creating I can do other steps in the lab. The verification in step 15 is going to require that your Cloud SQL instance is running, and that there is a green check here. So you won't be able to get that step and those five points until this is done, but you can do some of the other steps while we wait. So while this is going, I'm going to open another tab so that this is still running and I can check on it. And I am now going to go to Compute Engine, which I could either go here, or this tile right here has my Compute Engine instances. As you can see, two have been created for me. wordpress-europe-proxy, which is the proxy for my Cloud SQL instance and for the private IP instance. So for this one, I'm going to click SSH. And when that is ready, to SSH into I am going to download the Cloud SQL proxy and then I'm going to make it executable. So I'm going to do a wget, Enter. It's copied it and made it executable. So in order to start the proxy, you need the connection name of the Cloud SQL instance, which requires that it's actually running. So we'll go ahead, and go back here, and see what the status is. I'm going to refresh and see if anything is there. Now it's not there, but it does let me click on it. And let's see if the connection name is there, and it is here. Instance connection name, so I'm going to copy that, and I'm going to go back to my SSH window. And I am going to create an environment variable for that connection instance. So I'm going to do an export SQL_CONNECTION =, paste that in there. And if I want to verify that that environment variable is set, I'm going to do an echo SQL, oops, spell it right. And it should output that, and there it is. So I'm not going to get too far ahead, because the rest of the steps do require that my Cloud SQL instance is running. You can see it's still creating, so it is not going to let me create a database yet. So I'm just going to leave it on this screen, so that when it is completely done it'll let me create a database, which I need for the next step. All right, at this point my instance is running. So if I go to Cloud SQL, it'll have a green checkmark next to wordpress-db. Right here, it says it's runnable. So the step I was missing is I need to create a database, and I am going to create a database called wordpress, because that's what the application expects, and I'm going to hit Create. And now I am going to return to, My SSH window, and I'm just going to make sure that it still has my environment variable. Then I am going to activate the proxy connection to my SQL database. By running this, I'll run it in the background. And then I'm going to expect that it says Ready for new connections, which it has output. I'm going to press Enter. And this is a point in the lab where you can also hit Check my Progress. And at this point you should have all ten points in the lab, but we're still going to do one more step, which is task 3. Actually, task 3 and task 4, where we're going to connect the application to the Cloud SQL instance. So I'm going to configure the wordpress application. So I'm going to copy the curl command. Go ahead and run that, and it is going to output the external IP address for my virtual machine. I'm going to copy that, and open it here, And then I'm going to hit Let's Go. I am going to leave everything with default, except I'm going to change the username to root and I'm going to put in the password that I defined, which is password. And then for database host I am going to use a localhost IP, which is 127.0.0.1, and then I'm going to hit Submit. Now, when the connection has been made, it is going to let me install WordPress, and I'm going to click Run the Installation. This could take a few moments to complete. Once this is done I should get a success window, and this can take up to three minutes depending on where you are running your lab from. So here it goes, apparently it's very fast for me. And so once the connection has been made, I am going to go here, and I am going to remove everything passed to the external IP. Delete, hit Enter. And when this loads, I should be able to see my blog. So it looks like it's still installing, so I will go ahead and be patient. Add some Information that I don't need to remember. So this is My Fake Site title. Any username, leave that password it gave me, [email protected], and Install. And this was actually a step in the lab that I ignored, which was step 7, so don't do what I did and skip a step. So I had a successful installation. So what I'm going to do here is I'm going to remove all of the information that's after the external IP. When I hit Enter, it should take me to my blog. And Hello world! This is my blog, success. So the last task is to connect to Cloud SQL via the internal IP. So I'm going to go back here, and go to SQL and gcp. I'm going to click on wordpress-db, and then I am going to note the private IP address here. And I'm actually going to note it on a note, because pretty sure that it's going to have me copy something else. So make sure you copy it down somewhere in a clipboard, and then I'm going to go to Compute Engine. And it is going to want me to copy the external IP address for WordPress private IP. I'm going to copy that, and paste it in a new tab, press Enter. I'm going to hit Let's Go, and then the database name I'm going to leave alone, and I'm going to change this to root, and leave password because that's what I put before. Then I'm going to put the SQL private IP that I copied earlier to my Notepad, just need to find it. It's here, I'm going to copy that in here and hit Submit. And then I'm going to hit Run the Installation, and I should get Already Installed. So I created a direct connection to a private IP instead of configuring a proxy, and that connection is private. If I remove here, the same private IP should get my blog, and there it is. So in review, we created a Cloud SQL database and we configured it to use an external connection over a secure proxy as well as a private IP address. Hope you enjoyed the lab, thanks for watching.2. Let's practice!
Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.