MySQL is very easy to setup and requires minimum of time and resources.
In this tutorial we will setup a simple Master - Slave replication.
[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
innodb_flush_log_at_trx_commit=1
sync_binlog=1
auto_increment_increment = 2
bind-address = 0.0.0.0
auto_increment_offset = 1
[mysqld]
server_id = 3
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
innodb_flush_log_at_trx_commit=1
sync_binlog=1
auto_increment_increment = 2
bind-address = 0.0.0.0
auto_increment_offset = 1
[root@bih002 ~]# /etc/init.d/mysqld start
Starting mysqld: [ OK ]
GRANT REPLICATION SLAVE ON *.* TO REPLICATION@'10.000.1.210' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
mysql SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000004 | 383 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
mysqlCHANGE MASTER TO master_host='10.000.1.189', master_port=3306, master_user='replication',
master_password='password', master_log_file='mysql-bin.000004', master_log_pos=383;
mysqlstart slave;
mysql show slave statusG
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.000.1.189
Master_User: replication
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000003
Read_Master_Log_Pos: 383
Relay_Log_File: mysql-relay-bin.000008
Relay_Log_Pos: 251
Relay_Master_Log_File: mysql-bin.000003
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 383
Relay_Log_Space: 551
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)
mysql