replication on mysql:
master/slave.
master server is the production mysql instance.
slave server is the java host (123.57.39.*).
first we need to install mysql server and client on the java host(123.57.39.*).
1.in master execute:
create user 'replica'@'123.57.39.*' identified by 'replica@123';
grant replication slave on *.* to 'replica'@'123.57.39.*';
flush privileges;
2.
add the following to [mysqld] segment in /etc/my.cnf of master db. and make sure mysql user is the owner of log-bin direcotry. otherwise you
will get error when you startup mysql.
server-id=1
log-bin=/var/lib/mysql/binlog/mysql-bin
expire_logs_days=7
3.
on slave,add the following to [mysqld] segment in /etc/my.cnf
server-id=2
innodb_flush_log_at_trx_commit=2 //this line is not required,just improve innodb performance
expire_logs_days=7
4.in master,then copy data to slave
mysqldump --master-data=2 --user=root --password=fadfafafad --single-transaction --all-databases > replica.sql
5.copy the replica.sql to slave server,then import data in slave.
mysql --user=root --password=fadfafafad
6.change master settting on slave;view the privious replica.sql,using more replica.sql,you will see some text like the follwing,
-- change master to master_log_file='mysql-bin.000001', master_log_pos=107;
record the red font part,then fill them into the following statement,then execute the following statement in slave mysql server.
change master to
master_host = '123.57.38.*',
master_user = 'replica',
master_password = 'replica@123',
master_log_file = 'mysql-bin.000001',
master_log_pos = 107;
7.finally start slave;
be don't forget to issue show slave status\g' to check whether slave runs normally.