|
|
|
|
|
|
dlostboy (at) lostinfo (dot) com Home | Journal | Multimedia | Files | Other | Links | About |
|
|
|
FreeBSD 4.4 HOWTO for setting up replication of mySQL
Here's the scenario: We have a mySQL server (pre-4.0) and we want to replicate the data from it to another
mySQL server so that in the event that the primary server has a catastrophic failure, we'd have a
spare copy of the data. If you're using a 4.0+ mySQL server, this won't apply the same way as they
are making it much easier to implement in the newer versions of the database.
Go to your primary (we'll call it #1) mySQL server. First thing to do is to make a my.cnf file. It
will need to go into /etc (it should check /usr/local/etc but it doesn't). Create a file called
my.cnf and populate it with this information
Now go back to the first machine, that's now running, and issue the mySQL command: "GRANT FILE ON *.* TO username@slave_ip_address IDENTIFIED BY 'password';" then a "FLUSH PRIVILEGES;". Now go back to the #2 machine, and start the mySQL server. It should immediately create a file called master.info in your /var/db/mysql directory which contains internal information as to where the master server is, and whereabouts in the log file that it's caught up to.Connect to the #2 machine and execute the SQL "show slave status;" What you should see is a return set containing the Master_Host and Master_User among other things. You want to see something in the column "Log_File" and in the "Slave_Running". If there's an error, the replication will not occur and the error message will be in the "Last_error" column. If the "Log_File" column is empty, then it has not successfully connected to the master yet. Regrettibly, this connection should be instant so if it's not populated, something is wrong. Lastly, as it's updating you should see the "Pos" column increment. If it's not working, verify that the master server is actually set up to replicate by connecting to it and running a "show master status;" command. That should have the filename that it's outputting the log to.Congratulations on a working master-slave mySQL setup. |
| ©2000, ©2001 LostInformation |