MySQL
From Wikitech
(Difference between revisions)
(→Installing required packages on the "new" slave:) |
(more fixme) |
||
| Line 1: | Line 1: | ||
{{document me}} | {{document me}} | ||
| − | {{fixme| | + | {{fixme| |
| + | |||
| + | * Packaging, patches, configuration, installation | ||
| + | * How to change masters | ||
| + | * How to debug replication lag | ||
| + | * How to fix broken replication | ||
| + | |||
| + | }} | ||
Revision as of 21:09, 19 October 2009
- MySQL server tools - setup outline, quick howtos
- http://wp.wikidev.net/Special:Search?search=mysql&fulltext=Search
Contents |
Installing a new Slave host
In this section, I will describe the steps to take in order to create a new slave from scratch.
To summarize the steps:
* De-pool another slave from the same cluster, which will be used as the base. * Clean up the existing slave from replication errors * Install required packages on the new slave server * Tweak the configuration file of the new slave * Binary copy of relevant data from existing slave to new slave * Add both servers to the pool * Cross fingers and make sure everything works...
De-pooling / Clean up / Shutdown
- The file we are going to be working on is: /home/wikipedia/common/wmf-deployment/wmf-config/db-pmtpa.php
- In this file, find the cluster you are working with. In this case, we want to add a slave to the commons db, ergo the cluster is: s2commons
- The 'sectionLoads' array will show the current members of the cluster. The FIRST member is ALWAYS the MASTER! In this case, the master would be db13.
- Pick a slave. For this we will use db3, and we will be working on installing db8 as the new slave.
- De-pool db3 so that we can copy data from it when the data is not changing. In the same array, comment out db3, and sync-file db-pmtpa.php.
- Clean up the slave by running reset-mysql-slave db3.pmtpa.wmnet on Zwinger
- Shut down mysqld on db3 and wait for the shutdown to complete (can take up to 1/2 hour).
Installing required packages on the "new" slave:
- On db8 (our new slave server), install the following:
- wikimedia-mysql4 (our default mysql server package)
- pv (to monitor the data transmission as described below)
Tweak configuration file on the new slave:
- edit the /etc/my.cnf file and change the line:
#id = 1 + zero-filled last 4 digits of internal IP server-id = 100241
Binary copy:
As usual, there is more than one way to do it. However the most efficient way that was pointed out to me is to use nc+tar combination to transfer everything from one slave to the other. You could just as well use mysql-dump or mydumper, scp and then re-import everything, but it is a lot more time-consuming.