MySQL Replication

Create Replication User on master

mysql> create user dbsync@'192.168.188.%' identified by 'password';
mysql> grant replication slave, replication client on *.* to dbsync@'192.168.188.%';

Configure /etc/my.cnf on master

[mysqld]
log_bin=mysql-bin
binlog_format=row
server_id=1
relay-log=relay-bin
relay-log-index=relay-bin-index

Configure /etc/my.cnf on slave

[mysqld]
log_bin=mysql-bin
server_id=2
relay-log=relay-bin
relay-log-index=relay-bin-index
 
read-only=true
log-slave-updates=true
 
binlog-do-db=jiradb
replicate-do-db=jiradb

Create a Snapshot of DB on master

/* Open a session of terminal: */
mysql> FLUSH TABLES WITH READ LOCK;
 
/* Open another session of terminal:  */
# mysqldump -uroot -p --databases jiradb --lock-all-tables >/tmp/dbdump.db
Import Snapshot of master DB to slave
# mysql -uroot -p </tmp/dbdump.db
 
Slave Configuration
mysql> CHANGE MASTER TO
              MASTER_HOST='192.168.188.146',
              MASTER_USER='dbsyncuser',
              MASTER_PASSWORD='1234',
              MASTER_LOG_FILE='mysql-bin.000002',
              MASTER_LOG_POS=107;
 
mysql> start slave;

The master_log_file and master_log_pos shall be same with result of " show master status" on master.

show master status

Unlock MySQL on master

mysql> UNLOCK TABLES;

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值