博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Build MySQL Replication Environment
阅读量:5113 次
发布时间:2019-06-13

本文共 2101 字,大约阅读时间需要 7 分钟。

The post demonstrates how to build replication environment with 2 new MySQL servers which are running on 64-bit Ubuntu 14.04 LTS machines.

  • Master: {MySQL: 5.7.5, IP Address: 192.168.0.100}
  • Slave  : {MySQL: 5.7.5, IP Address: 192.168.0.101}

 

Configure the Master

Backup MySQL configuration file.

cp /etc/mysql/my.cnf /etc/mysql/my.cnf.backup

Open my.cnf, set server-id and log-bin, and change bind-address.

server-id=1log-bin=/var/log/mysql/mysql-bin.logbind-address=192.168.0.100

Restart master MySQL server to apply these settings.

service mysql restart

Create Replication user.

mysql -u root -p --prompt='master>'master> create user repl_user@192.168.0.101;master> grant Replication Slave on *.* to repl_user@192.168.0.101 identified by 'password';

Lock the Master, note binary log name and position.

master> flush tables with read lock;master> show master status; # In this post, the binary log file name is mysql-bin.000001, the position is 439.

Create a data snapshot using mysqldump. (start another session and run the followoing command, and then copy the db.dump to the Slave)

mysqldump -u root -p --all-databases > db.dump

Release the read lock.

master> unlock tables;

 

Configure the Slave

Backup MySQL configuration file.

cp /etc/mysql/my.cnf /etc/mysql/my.cnf.backup

Open my.cnf, set server-id and change bind-address.

server-id=2bind-address=192.168.0.101

Restart slave MySQL server.

service mysql restart

Set the Master configuration.

mysql -u root -p --prompt='slave>'slave> change master to master_host='10.110.77.181', master_user='repl_user', master_password='OpsMgr2007R2', master_log_file='mysql-bin.000001', master_log_pos=439;slave> start slave;

 

Check if replication works

On the Master, create a database and a table and add a row.

master> create database test_replication;master> use test_replication;master> create table t1 (Id int not null primary key);master> insert into t1 values (777);

 

On the Slave, check if the replication works.

slave> show databases;slave> select * from test_replication.t1;

 

转载于:https://www.cnblogs.com/jeffreyf/p/build-mysql-replication-environment.html

你可能感兴趣的文章
Android开发学习之路--Notification之初体验
查看>>
3ds max学习笔记(十一)-- 修改器
查看>>
游戏UI规范
查看>>
ubuntu触摸板双指滑动,页面滚动方向
查看>>
flex box布局
查看>>
php-fpm配置文件
查看>>
撩课-Web大前端每天5道面试题-Day16
查看>>
Python学习 Week1
查看>>
【bzoj3207】花神的嘲讽计划Ⅰ Hash+STL-map+莫队算法
查看>>
使用 polyfills 的简易方法
查看>>
Maven之(五)Maven仓库
查看>>
低耦合的理解与作用
查看>>
Python基础语法
查看>>
web前端性能优化汇总
查看>>
laravel5.4中ajax删除数据
查看>>
Crash的数字表格 BZOJ 2154 / jzptab BZOJ 2693
查看>>
分析百度降权的几个主要原因
查看>>
A*B 高静度
查看>>
jmeter(十五)Jmeter默认报告优化
查看>>
HTML5与HTML4的区别(2)
查看>>