We need to create an online database, for this, we will Launch a new DB instance in RDS.
Here are the Specifications for the Database;
- · Micro instance
- · Multi-AZ deployment
- · Storage type = general purpose (SSD)
- · 5GB storage
- · DB Instance Identifier = AmbersDinoStoreInstance
- · Master username = Admin
- · Master password = **********************
- · Use default VPC
- · Security group = create the new security group
- · Database name = AmbersDinoStoreDB
- · Enabled automatic backups by selecting a period of days (N.B.: 0 = disabled)
The instance is being created, this will take awhile.
This takes about 15 mins and then you have an instance that is up and running. Grab the end point this is shown below.
The end point is listed as;
We must go into EC2 and change the inbound rules for the security group that has just been created. I suggest changing this from what the lab states, to being completely open, so you are not tied to one IP address.
Now I need to go into MySQL and create a new Connection, we will add in the details from the end point and the administrator account as stated before. This should be correct and connect as shown below.
Now to log into that Instance, we need to get out of our login and go into the AWS log in, after this, we need to Copy the original data from the previous database over to the new one.
Ok, now I’m going to write this out in detail because this took me hours of working out to figure out.
- In the Original data folder, you need to find the create table code, this was something I found one moment and lost the next, and now I have no clue where it is.
- open this in your new connection AWS as shown above so now press the Lightning button above, and that will create tables.
- After this, you need to go back to your original database and export the data, in this you need to run the Selected * ….. as shown below, and then go into the Import/ Export section and Click Export, and find somewhere to Export it to.
- After this you need to go into the coneected database and the tables that have been created as showen below, once you hover over them you have a button that pops up for importing.
- From here you import it, and it imports into the database.
The next step is to Create a read-replica of the DB instance, this will be stored somewhere else other than where i have created the instance.
After this, we need to create another connection to Mysql to the replica database. In this, we put the end point to the replica, but because its a replica the Acounts user and password is still the same. This has been tested and it connected as showen below. AFter this was created i had a look around and everything was the same as the previous one.
AFter this we need to go into my sql and change some of the code inside of the web.config file, in this we need to change the Server source from the local host to the AWS read-replica of the database. We will do this for both this line and the next. Making sure we change the account and password to the databases, We also need to copy the bottom code and paste below then we need to change the name from “StoreSqlDb” to “StoreSqlDbReplica” as shown below.
AFter this we need to go into the Default.aspx.cs’s code and change the code where it says “//connectstring for MySQL” in this we will be changing the Connection string from the “StoreSqlDb” to “StoreSqlDbReplica” as showen below.
Now we need to Open the new connection to see if they work, and as showen below they were up and running.
Now after this we need to create a User account, in this we will go into the a Account tab and then into the Create Account tab, we will go throught creating a user as showen below.
After creating a user we can then see that its logged on and then this infomation will populate the dinostorememebershipdb table as showen below.
Now we need to cheak that the website is backed up correctly, this is done with Rebooting the RDS server. While this was happing the website still was up there. thats because this is backed up from the replica. And this is the end of the lab.