|
|
Line 1: |
Line 1: |
− | === Prepare mysql setup ===
| |
− | After installation, depending on distribution, find my.cnf and under mysqld add (or uncomment) : <br>
| |
| | | |
− | '''Server 1:'''
| |
− | <pre>
| |
− | [mysqld]
| |
− | server_id = 1
| |
− | log_bin = /var/lib/mysql/mysql-bin.log
| |
− | log_bin_index = /var/lib/mysql/mysql-bin.log.index
| |
− | relay_log = /var/lib/mysql/mysql-relay-bin
| |
− | relay_log_index = /var/lib/mysql/mysql-relay-bin.index
| |
− | expire_logs_days = 10
| |
− | max_binlog_size = 100M
| |
− | log_slave_updates = 1
| |
− | auto-increment-increment = 2
| |
− | auto-increment-offset = 1
| |
− | </pre>
| |
− |
| |
− |
| |
− | '''Server 2:'''
| |
− | <pre>
| |
− | [mysqld]
| |
− | server_id = 2
| |
− | log_bin = /var/lib/mysql/mysql-bin.log
| |
− | log_bin_index = /var/lib/mysql/mysql-bin.log.index
| |
− | relay_log = /var/lib/mysql/mysql-relay-bin
| |
− | relay_log_index = /var/lib/mysql/mysql-relay-bin.index
| |
− | expire_logs_days = 10
| |
− | max_binlog_size = 100M
| |
− | log_slave_updates = 1
| |
− | auto-increment-increment = 2
| |
− | auto-increment-offset = 2
| |
− | </pre>
| |
− |
| |
− | Update bind-address with your local servers ip:
| |
− | <pre>
| |
− | bind-address = x.x.x.x
| |
− | </pre>
| |
− |
| |
− | Create user which is going to be used on slave (adding slave IP):
| |
− | <syntaxhighlight lang="mysql">
| |
− | GRANT REPLICATION SLAVE ON *.* TO 'repl'@'x.x.x.x' IDENTIFIED BY 'password';
| |
− | </syntaxhighlight>
| |
− |
| |
− | === Configure MySQL Master-Master replication ===
| |
− | <syntaxhighlight lang="mysql">
| |
− | mysql> SHOW MASTER STATUS;
| |
− | +------------------+----------+--------------+------------------+
| |
− | | File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
| |
− | +------------------+----------+--------------+------------------+
| |
− | | mysql-bin.000001 | 277 | | |
| |
− | +------------------+----------+--------------+------------------+
| |
− | 1 row in set (0.00 sec)
| |
− | </syntaxhighlight>
| |