mysql主从-ms
一、环境准备
1、准备两台安装有mysql的linux服务器
2、安装的mysql版本最好相同
3、配置两台服务器的主机名和IP地址,主机名:master和slave,IP地址:192.168.0.20和192.168.0.19
4、确保两台服务器中mysql的数据一致,如果不一致,通过备份master的数据库,导入到slave中。
二、配置主从
master服务器
1、配置同步授权用户slave,密码:12345
命令:
root@rshine-virtual-machine:~#
root@rshine-virtual-machine:~# mysql -uroot -padmin@1234
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 88
Server version: 5.5.62-0ubuntu0.14.04.1-log (Ubuntu) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> grant replication slave on *.* to slave@'192.168.0.19' identified by "12345";

2、修改mysql配置文件/etc/mysql/my.cnf



3、重启mysql
命令:
/etc/init.d/mysql restart
4、查看master的状态信息
命令:

slave服务器
1、修改mysql配置文件/etc/mysql/my.cnf

2、重启mysql
命令 :
/etc/init.d/mysql restart
3、配置主mysql信息,包括同步账号和密码,IP地址、端口号、以及二进制日志文件名。
命令:

4、查看slave状态
命令:

三、测试主从效果
1、查看主从服务器mysql数据是否一致


从上述结果看,master和slave的数据库数据一致。
2、在master中插入一条数据,查看slave中会不会同步这条数据



3、查看slave的数据


由此可得,slave同步了master插入的一条数据。实现了主从同步。
mysql主从-ms的更多相关文章
- 2-18,19 搭建MySQL主从服务器并并通过mysql-proxy实现读写分离
MySQL主从服务器 实现方式: MySQL REPLICATION Replication可以实现将数据从一台数据库服务器(master)复制到一台或多台数据库服务器(slave) 默认情况下这种 ...
- 如何实现 MySQL 的读写分离?MySQL 主从复制原理的是啥?如何解决 MySQL 主从同步的延时问题?
如何实现 MySQL 的读写分离? 其实很简单,就是基于主从复制架构,简单来说,就搞一个主库,挂多个从库,然后我们就单单只是写主库,然后主库会自动把数据给同步到从库上去. MySQL 主从复制原理的是 ...
- Atlas实现mysql主从分离
可以接受失败,无法接受放弃!加油! 一.介绍Atlas及架构图 Atlas源代码用C语言编写,它对于Web Server相当于是DB,相对于DB相当于是Client,如果把Atlas的逻辑放到Web ...
- zabbix监控mysql主从同步和延迟
https://blog.csdn.net/natmazz/article/details/90581490 https://www.cnblogs.com/01-single/p/10602610. ...
- Mysql主从分离介绍及实现
参考: http://www.cnblogs.com/panxuejun/p/5887118.html https://www.cnblogs.com/alvin_xp/p/4162249.html ...
- 基于MySql主从分离的代码层实现
前言 该文是基于上篇<MySQL主从分离的实现>的代码层实现,所以本文配置的主数据库和从数据库的数据源都是在上篇博文中已经介绍了的. 动态选择数据源的配置 由于我们在写数据的时候需 ...
- 在 CentOS7 上部署 MySQL 主从
在 CentOS7 上部署 MySQL 主从 通过 SecureCRT 连接至 MySQL 主服务器: 找到 my.cnf 文件所在的目录: mysql --help | grep my.cnf 一般 ...
- 高性能Mysql主从架构的复制原理及配置详解
温习<高性能MySQL>的复制篇. 1 复制概述 Mysql内建的复制功能是构建大型,高性能应用程序的基础.将Mysql的数据分布到多个系统上去,这种分布的机制,是通过将Mysql的某一台 ...
- MySQL主从同步
脚本 [root@test scripts]# cat ss.sh #!/bin/bash . /etc/init.d/functions MYUSER=root MYPASS=c565f972 SO ...
随机推荐
- 123456123456#1#---###3%%%----com.zzj.SuperPuperID668---前拼show后广--嘻哈水管工-111111
com.zzj.SuperPuperID668---前拼show后广--嘻哈水管工-1111111111111
- Coder 健康 知识
- [LeetCode] 131. Palindrome Partitioning 回文分割
Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...
- [LeetCode] 362. Design Hit Counter 设计点击计数器
Design a hit counter which counts the number of hits received in the past 5 minutes. Each function a ...
- [LeetCode] 741. Cherry Pickup 捡樱桃
In a N x N grid representing a field of cherries, each cell is one of three possible integers. 0 mea ...
- 【Flume学习之二】Flume 使用场景
环境 apache-flume-1.6.0 一.多agent连接 1.node101配置 option2 # Name the components on this agent a1.sources ...
- .Net Core 定时任务TimeJob
转载自:https://blog.csdn.net/u013711462/article/details/53449799 定时任务 Pomelo.AspNetCore.TimedJob Pomelo ...
- javascript循环遍历数组输出key value
javascript循环遍历数组输出key value用$.each方法肯定不行的 所以采用如下方法<pre> markers = []; markers[2]=3; markers[3] ...
- 在 Visual Studio 中部署 ASP.NET Core 应用
另一篇:在 Docker 中手工部署 ASP.NET Core 应用 操作步骤 1. 安装 Docker For Windows(安装之前 Windows 需要 开启 Hyper-V 虚拟机功能 ) ...
- Charles手机代理设置
Charles工具 手机 方法/步骤 1.打开Charles 点击Proxy,选择proxy settings,输入端口8888 打开电脑,在cmd中输入ipconfig,查看本地 ...