Note: Because this is an ongoing series, viewers will not receive a certificate of completion.
Skill Level Intermediate
- [Instructor] One common use of the cloud is to be able to get some recoverability, have high availability. For instance, if a data center were to go down, I've got a backup somewhere else. How do you set up and manage that with data? In SQL Database, which is where I can use the transactional version of SQL Server, the T-SQL, and I have my database available to me, I can do a replication of that to another environment in another data center. What I'm going to do is I'm going to go out and I'm going to take a database that we created called mydemodata and I'm going to go down to where I've got Geo-Replication.
What this does is it allows me to say, create a backup database, so I've got a failover group by adding my database to that replication. The way that it works is you can see that there's a map of places that I could replicate from my source database, the blue check, in the east data center, I could pick another data center. So, scroll down and you'll see that there's a list of different regions we could go to. Now I'm going to pick the West US although I could have maybe one in Europe, maybe one in Asia, I could have different places that I want to send this to, and then I can set up that replication.
To do that, we specify our region. Secondary type is going to be Readable. I'm going to pick the Target server, so I'm going to create a new server. I'm going to call this mydemowestdb. Make sure that that name is uniquely available within the database.windows.net. I'm going to use the same admin login and password that I used on the other one just for simplicity purposes.
Now, as a DBA, you may have complex, different passwords for each of the different environments but once you set up your parameters for it, you can say, okay, Select. This will then create that secondary demowestdb. And then I can go out and specify the size of it, and say OK. And what this is going to do is it's going to submit a deployment, which is going to be a job that will go out and take all the schema and all the data and replicate between the two servers. So, pretty quickly, this is going to then get updated and we'll see that the database is initializing.
And you can see on the map that the data is now flowing from the main database to the backup. And once that gets done, then we can go out and we can actually connect up to that database and start querying it. So, this is taking a few minutes here. If I go back over to my Home page and I search for mydemodb two by clicking on my servers, what I'll find is that the database will get replicated.
And if I look at my database servers, you'll see here's mydemowestdb, which is the new server I just created. If I click on that and I go down to where I've got my databases, this will eventually create that database and then that data would be replicated. Now, it may take a few minutes for it to finish replicating, but we'll speed it along here. In here, we can see that the database got created. If I click on it, then I can come over and I can actually log in and I could then go out and make a query.
Log in to this database. I'm now on the copy in the west region. Say OK. And then I can go out and you can see here's the tables. If I wanted to, I could go and say select star from customer. Execute. And this is a read-only copy of the database that was set up. Now, if I look at the geo-replication on the configuration for this, I can see that this is the secondary database and that the primary is going to be the East US.
So, that is how we can go out and we can set up geo-replication of our databases between regions and you can set it up for multiple replica copies. You can use it for your high availability scenarios. So, this is a great thing to have. And so, that's how you can set up geo-replication between databases.