mysql设置slave复制_mysql master/slave复制设置

1.在主库上创建replicate用户且赋予replication slave权限mysql> GRANT REPLICATION SLAVE ON *.* TO repclub2 IDENTIFIED BY 'repclub2'

2.enable binary logging

3.设置server id ---在文件/etc/my.cnf主库设为1从库设为2[mysqld]log-bin=mysql-binserver-id=1

4.主库的其它设置

For the greatest possible durability and consistency in a replication setup using InnoDB with transactions, you should use innodb_flush_log_at_trx_commit=1 and sync_binlog=1 in the master my.cnf file.

Ensure that the skip-networking option has not been enabled on your replication master. If networking has been disabled, then your slave will not able to communicate with the master and replication will fail.

5.导出主库数据mysql> FLUSH TABLES WITH READ LOCK;

Leave the client from which you issued theFLUSH TABLESstatement running so that the read lock remains in effect. If you exit the client, the lock is released.

select t.login_id,

decode(m.company_type,'JapanSuppliers','正式日供','Free','免费','ImportJapanSuppliers',

decode(m.from_site,'intl1','导入日供','intl2','白金会员'))

from tbd_member_20080904 t, member m

where t.login_id = m.login_idmysql > SHOW MASTER STATUS;在另一个会话中导出数据shell> mysqldump --all-databases --lock-all-tables >dbdump.db

When choosing databases to include in the dump, remember that you will need to filter out databases on each slave that you do not want to include in the replication process.

6.将导出数据拷贝至slave库

7.导入slave库shell> mysql -uroot -p

8.在slave上设置其master选项CHANGE MASTER TOMASTER_HOST='jp_my3',MASTER_USER='repclub2',MASTER_PASSWORD='repclub2',MASTER_LOG_FILE='mysql-bin.000006',MASTER_LOG_POS=3132;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值