| | 81 | |
| | 82 | === Replication === |
| | 83 | In order to have a backup instance, configure replication from the Master node to a Backup node: |
| | 84 | * http://www.debiantutorials.net/mysql-database-replication-masterslave/ |
| | 85 | * http://www.howtoforge.com/how-to-repair-mysql-replication |
| | 86 | |
| | 87 | ==== On Master: ==== |
| | 88 | {{{ |
| | 89 | pico /etc/mysql/my.cnf |
| | 90 | #bind-address = 127.0.0.1 |
| | 91 | server-id = 1 |
| | 92 | log_bin = /var/log/mysql/mysql-bin.log |
| | 93 | binlog_do_db = sahana |
| | 94 | |
| | 95 | /etc/init.d/mysql restart |
| | 96 | |
| | 97 | mysql -u root -p |
| | 98 | GRANT REPLICATION SLAVE ON sahana.* to username@'sl.av.e.ip' IDENTIFIED BY 'mypassword'; |
| | 99 | FLUSH PRIVILEGES; |
| | 100 | SHOW MASTER STATUS; |
| | 101 | }}} |
| | 102 | Read log filename & position for configuring the slave (see below). |
| | 103 | |
| | 104 | ==== On Slave: ==== |
| | 105 | {{{ |
| | 106 | pico /etc/mysql/my.cnf |
| | 107 | server-id = 2 |
| | 108 | master-host = ma.st.er.ip |
| | 109 | master-user = username |
| | 110 | master-password = mypassword |
| | 111 | master-connect-retry = 60 |
| | 112 | replicate-do-db = sahana |
| | 113 | |
| | 114 | /etc/init.d/mysql restart |
| | 115 | |
| | 116 | mysql -u root -p |
| | 117 | |
| | 118 | SLAVE STOP; |
| | 119 | CHANGE MASTER TO MASTER_HOST='ma.st.er.ip', MASTER_USER='username', MASTER_PASSWORD='mypassword', MASTER_LOG_FILE='log_file', MASTER_LOG_POS=log_position; |
| | 120 | SLAVE START; |
| | 121 | |
| | 122 | crontab -e |
| | 123 | # m h dom mon dow command |
| | 124 | 55 * * * * /home/instance/scripts/automysqlbackup |
| | 125 | 55 * * * * /home/instance/scripts/sync-dir |
| | 126 | }}} |
| | 127 | |
| | 128 | ==== IP Failover ==== |
| | 129 | Can configure the slave to adopt the same IP as the master using a Heartbeat: |
| | 130 | * http://www.srg.cs.hku.hk/srg/html/cprobe/ha/GettingStarted.html |
| | 131 | |
| | 132 | If using Slicehost: |
| | 133 | * http://articles.slicehost.com/2008/10/28/ip-failover-slice-setup-and-installing-heartbeat |
| | 134 | |
| | 135 | |
| 157 | | --- |
| 158 | | == Replication == |
| 159 | | In order to have a backup instance, configure replication from the Master node to a Backup node: |
| 160 | | * http://www.debiantutorials.net/mysql-database-replication-masterslave/ |
| 161 | | * http://www.howtoforge.com/how-to-repair-mysql-replication |
| 162 | | |
| 163 | | === On Master: === |
| 164 | | {{{ |
| 165 | | pico /etc/mysql/my.cnf |
| 166 | | #bind-address = 127.0.0.1 |
| 167 | | server-id = 1 |
| 168 | | log_bin = /var/log/mysql/mysql-bin.log |
| 169 | | binlog_do_db = sahana |
| 170 | | |
| 171 | | /etc/init.d/mysql restart |
| 172 | | |
| 173 | | mysql -u root -p |
| 174 | | GRANT REPLICATION SLAVE ON sahana.* to username@'sl.av.e.ip' IDENTIFIED BY 'mypassword'; |
| 175 | | FLUSH PRIVILEGES; |
| 176 | | SHOW MASTER STATUS; |
| 177 | | }}} |
| 178 | | Read log filename & position for configuring the slave (see below). |
| 179 | | |
| 180 | | === On Slave: === |
| 181 | | {{{ |
| 182 | | pico /etc/mysql/my.cnf |
| 183 | | server-id = 2 |
| 184 | | master-host = ma.st.er.ip |
| 185 | | master-user = username |
| 186 | | master-password = mypassword |
| 187 | | master-connect-retry = 60 |
| 188 | | replicate-do-db = sahana |
| 189 | | |
| 190 | | /etc/init.d/mysql restart |
| 191 | | |
| 192 | | mysql -u root -p |
| 193 | | |
| 194 | | SLAVE STOP; |
| 195 | | CHANGE MASTER TO MASTER_HOST='ma.st.er.ip', MASTER_USER='username', MASTER_PASSWORD='mypassword', MASTER_LOG_FILE='log_file', MASTER_LOG_POS=log_position; |
| 196 | | SLAVE START; |
| 197 | | |
| 198 | | crontab -e |
| 199 | | # m h dom mon dow command |
| 200 | | 55 * * * * /home/instance/scripts/automysqlbackup |
| 201 | | 55 * * * * /home/instance/scripts/sync-dir |
| 202 | | }}} |
| 203 | | |
| 204 | | === IP Failover === |
| 205 | | Can configure the slave to adopt the same IP as the master using a Heartbeat: |
| 206 | | * http://www.srg.cs.hku.hk/srg/html/cprobe/ha/GettingStarted.html |
| 207 | | |
| 208 | | If using Slicehost: |
| 209 | | * http://articles.slicehost.com/2008/10/28/ip-failover-slice-setup-and-installing-heartbeat |