One my clients complained the other day that their application using Covalentia with MySQL database has become a lil bit slower than usual as the data grows in size. So, I thought I should come up with a version that supports Master & Slaves (MySQL Replication) servers. The idea is to execute the CREATE, UPDATE and DELETE functions on the Master database server, and READ on one of the Slave machines. In addition, I will have to move the Reporting Service to another machine which will Read from another Slave machine. This way I can minimize the load on the current application and database servers.
And apparently, it didn't take me too long to do this:
- Changed the web.config file to add the following connection string for the Slave database server:
<add key="SlaveConnectionString" value="server=localhost; UID=<slave_user>; Password=<slave_password>; Database=covalentia_v22; Max Pool Size=500"/> - Opened up the /DataAccess/Objects.cs file
- Looked for GetObject & GetObjects regions
- Looked for methods under these two regions that do not have "string connectionString" parameter - these methods load the connection string from the web.config file
- Added the following codes:
if (System.Configuration.ConfigurationManager.AppSettings["SlaveConnectionString"] != null)
{
return whatever - edited to System.Configuration.ConfigurationManager.AppSettings["SlaveConnectionString"]
}
else
{
return whatever - no change
}
There should be 4 methods in total. - Compiled
However, before I could proceed with the testing, I needed a Slave database server. Luckily, I still have my old-and-underutilized iASUS notebook which I primarily use to back-up my files. And so, I installed MySQL Server 5.0 on this machine and set it up as a Slave as follows:
Slave (old notebook - Windows XP Professional):
- Opened up the my.ini file
- Added the following:
log-error
master-host=
master-user=
master-password=
server-id=2
replicate-do-db=covalentia_v22
relay-log=-relay-bin
Master (my current notebook - Windows XP Professional):
- Opened up the my.ini file
- Added the following:
log-error
log-bin=
server-id=1 - Opened up MySQL Command Line, entered and executed the following command:
mysql>grant all privileges on *.* to ''@'%' identified by '' with grant option;
- Restarted the MySQL Master database server
- Restarted the MySQL Slave database server
And that should be it. Done! Oh not quite. I needed to test it to see that this setup's really working. And the simplest test was to logon to Covalentia and browse to Administration Module --> Log Management --> User Log, and hit the Search button. I could see the latest log entry and, thus, the READing from my Slave server was successful.
I shall be a good slave and upload this latest version ASAP ;)