mysql 5.1: replication

Master server

edit /etc/mysql/conf.d/replication.cnf

1
[mysqld]

1
server-id        =
1
1

1
# By
1
default
1
, the directory is written to the directory of database.

1
# IMPORTANT: If you lose the base, having a backup and binary logs, you can restore a database at the time of collapse. For
1
this

1
# reason, the logs and databases should be stored at physically different carriers.

1
log-bin          = /db/log/mysql-bin.log

1
# This variable applies when binary logging is enabled. It controls whether stored function creators can be trusted not to create #stored functions that will cause unsafe events to be written to the binary log.

1
log_bin_trust_function_creators =
1
1

1
# The number of days
1
for
1
automatic binary log file removal..

1
expire_logs_days =
1
90

1
# >=
1
5.1
1
.
1
28
1
- you is unable to start shard without
1
this
1
option.

1
# < 
1
5.1

   

1
- you is unable to start mysqld server without
1
this
1
option.

1
binlog_format    = MIXED

1
max_binlog_size  = 100M
# In addition, the transaction can determine what needs to change the data and may be useful to diagnose various problems.
# For MySQL <= 5.0: We don't recommend to use this option due to the replication became fragile.

mysql -uroot -p

1
GRANT REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO replicator@
1
'%'
1
IDENTIFIED BY
1
'****'
1
;

/etc/init.d/mysql restart

Slave server

edit /etc/mysql/conf.d/replication.cnf

1
[mysqld]
 

1
server-id        =
1
2

1
#The host name or IP address of the master replication server

1
master-host      =
1
192
1
.xx.xx.xx

1
#The user name of the account that the slave thread uses
1
for
1
authentication when it connects to the master.

1
master-user      = replicator

1
#The password of the account that the slave thread uses
1
for
1
authentication when it connects to the master

1
master-password  = *****

1
# The host name or IP address of the slave to be reported to the master during slave registration. This value appears in the output # # of SHOW SLAVE HOSTS on the master server.

1
report-host      =
1
192
1
.xx.xx.xx
 

1
# Disabling replications
1
for
1
auction tables.

1
replicate-wild-ignore-table = auction.auction_plain_%

1
replicate-wild-ignore-table = auction.mem_params
 

1
# The replication is accessible only
1
for
1
reading.
 

1
read_only        = yes

/etc/init.d/mysql restart

For versions of MySQL lower than 5.1, you need to run the replication command:

1
CHANGE MASTER TO MASTER_HOST =
1
'192.xx.xx.xx'
1
, MASTER_USER =
1
'replicator'
1
, MASTER_PASSWORD =
1
'****'
1
;

1
START SLAVE;

How to monitore

in the master server:
show master status;
in the slave server:
show slave status;

Start replication

in the slave server:
start slave