Replicazione Database MySQL – Mysql replication

Sul MASTER:

ipotizzo che il master sia il 192.168.0.20

——————— /etc/my.cnf del Master 192.168.0.20 ————————————–

[client]
port            = 3306
socket          = /tmp/mysql.sock

[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
skip-locking
key_buffer = 256M
max_allowed_packet = 1M
table_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache = 8
query_cache_size= 16M
log-slow-queries=/var/log/mysql-slow-queries.log
thread_concurrency = 8
log-warnings

server-id = 1
relay-log = /usr/local/mysql/data/mysql-relay-bin
relay-log-index = /usr/local/mysql/data/mysql-relay-bin.index
master-info-file = /usr/local/mysql/data/mysql-master.info
relay-log-info-file = /usr/local/mysql/data/mysql-relay-log.info
log-bin = /usr/local/mysql/data/mysql-bin

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[isamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

——————————————————————————————————————-

operazioni sul master:

mysql

GRANT SUPER,REPLICATION CLIENT,REPLICATION SLAVE,RELOAD ON *.* to slaveuser@’192.168.0.25′ identified by ‘slavepw’;
FLUSH PRIVILEGES;

——————— /etc/my.cnf dello Slave 192.168.0.25 ————————————–

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

# changes made to do slave
server-id = 2
relay-log = /var/lib/mysql/mysql-relay-bin
relay-log-index = /var/lib/mysql/mysql-relay-bin.index
#log-error = /var/lib/mysql/mysql.err
master-info-file = /var/lib/mysql/mysql-master.info
relay-log-info-file = /var/lib/mysql/mysql-relay-log.info
##datadir = /var/lib/mysql
master-host=192.168.0.20
# Nome con cui lo slave si presenta al master
report-host = 192.168.0.25
master-user=slaveuser
master-password=slavepw
#master-port=3300
master-connect-retry=30
# end slave setup

log-warnings

## Risolve un bug
skip-bdb

[mysql.server]
user=mysql
basedir=/var/lib

[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

——————————————————————————————————————-

operazioni sullo Slave:

mysql -u root -p
> load data from master;

Problemi e soluzioni

Appena configurato il master-slave ho avuto i seguenti errori nei log  e conseguenti problemi di replica master-slave

Error reading slave log configuration
080811 15:01:08 [ERROR] Error reading slave log configuration
080811 15:01:08 [ERROR] Failed to initialize the master info structure

Ho risolto stoppando lo slave, stoppando il master e cancellando dal master i file:
/usr/local/mysql/data/mysql-relay-bin
/usr/local/mysql/data/mysql-relay-bin.index
/usr/local/mysql/data/mysql-master.info
/usr/local/mysql/data/mysql-relay-log.info
/usr/local/mysql/data/mysql-bin

Saluti a tutti

Maurizio