MySQL 同一台服务器同步数据
声明:我配置出来的slave_io_running和slave_sql_running都是yes。但是数据并没有同步!
希望有遇到相同问题的朋友,能够告诉我一下解决方案?
首先,如何在同一个服务器安装两个MySQL
https://blog.csdn.net/hanjun0612/article/details/81236694
接着我们配置两个mysql同步数据
一 先看mysql1的my.ini
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
# 以下内容手动添加
[client]
port=3307
default-character-set=utf8
[mysqld]
#skip-grant-tables
#从库配置
server_id=1
#需要同步的表,不写则默认整个库同步
binlog-do-db=testdb
slave_parallel_type='logical_clock'
slave_parallel_workers=4
log_bin=mysql-bin
log_bin-index=mysql-bin.index
#端口
port=3306
character_set_server=utf8
#我的data和bin目录分成了连个,所以路径有些不一样,大家按照自己的来就行
#解压目录
basedir=C:\ProgramData\MySQL\MySQL Server 5.7
#解压目录下data目录
datadir=C:\ProgramData\MySQL\MySQL Server 5.7\data
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[WinMySQLAdmin]
C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe
二 在看mysql2的my.ini
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
# 以下内容手动添加
[client]
port=3307
default-character-set=utf8
[mysqld]
#从库配置
server_id=2
#这个是你需要覆盖的库
replicate-do-db=kps_common
relay-log-index=slave-relay-bin.index
relay-log=slave-relay-bin
#端口
port=3307
character_set_server=utf8
#我的data和bin目录分成了连个,所以路径有些不一样,大家按照自己的来就行
#解压目录
basedir=C:\ProgramData\MySQL1\MySQL Server 5.7
#解压目录下data目录
datadir=C:\ProgramData\MySQL1\MySQL Server 5.7\data
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[WinMySQLAdmin]
C:\Program Files\MySQL1\MySQL Server 5.7\bin\mysqld.exe
三 命令配置mysql1
接着,先配置mysql1
打开cmd,然后转到mysql1的bin目录
1 cd\
2 cd C:\Program Files\MySQL\MySQL Server 5.7\bin
3 输入 mysql -uroot -p
4 输入密码 登录成功
5 show master status;
第5步,完成后,出现下图:(图片是拷贝的,主要记住File和Position)
最后使用语句
PS:这里必须要填192.168.1.88的ip,而不是127.0.0.1。不然之后会Slave_IO_Running:Connecting
这个问题困扰了我2天,后来偶然的使用ip来赋值用户权限,才正确!
create user slave;
grant replication slave on *.* to 'slave'@'192.168.1.88'identified by '123';
flush privileges;
四 命令配置mysql2
同上面一样,先打开cmd,然后转到mysql2的bin目录
然后登陆。
接着运行
CHANGE MASTER TO
master_host = '192.168.1.88',
master_user = 'slave',
master_password = '123',
master_log_file = 'bin_log.000002',
master_log_pos = 631;
然后运行
start slave;
show slave status \G;
出现这个就正确了
参考:
https://blog.csdn.net/tribalelders/article/details/53894194
https://www.cnblogs.com/naruto123/p/8138708.html
MySQL 同一台服务器同步数据的更多相关文章
- 架设rsync服务器同步数据
什么是rsync rsync 是一个快速增量文件传输工具,它可以用于在同一主机备份内部的备分,我们还可以把它作为不同主机网络备份工具之用.本文主要讲述的是如何自架rsync服 务器,以实现文件传输.备 ...
- SqlServer2008 跨服务器同步数据
最近工作中需要跨服务器同步数据,在数据库DB1中的表T1插入数据,同时触发T1的触发器(这里暂不讨论触发器的效率问题),向另一台服务器DB2中的相同的一张表T2插入数据,查看了一些资料说, 需要打开D ...
- rsync+inotify实现多台服务器之间数据实时同步
配置环境 1.操作系统:CentOS6.5-X86_64 2.rsync客户端(rsync+inotify):192.168.200.82 3.rsync服务端:192.168.200.80,192. ...
- Centos7 rsync+inotify两台服务器同步文件(单向)
注:本篇介绍的是单向同步,即A文件同步到B,但B的文件不同步到A,双向同步的在下一篇文章中. rsync与inotify不再赘述,直接进入实战. 0.背景 两台服务器IP地址分别为: 源服务器:192 ...
- JOB+MERGE 跨服务器同步数据
为了解决单服务器压力,将库分服务器部署,但是原来用触发器实现的表数据同步就实现不了了. 因为总监老大不允许 开启分布式事务(MSDTC),我又不想为了一个几千行的基础数据做复制订阅. 于是乎决定用 J ...
- mysql 一台服务器中装两个mysql
个人经验: 服务器中已有mysql5.0 现要安装mysql5.5 下载安装包,安装后,mysql5.5中没有my.ini文件,就在我自己的电脑上复制了mysql5.5的my.ini文件进去. 1.在 ...
- mysql同一台服务器上不同数据库中个别表内容同步
>>>>>>soft_wsx>>>>>>--数据备份与还原>>同步备用服务器--1.完全备份主数据库--2.使用带S ...
- mysql 在linux服务器恢复数据表方法记录
在本地搭建测试环境录入的数据放到线上测试,备份了数据表为一个.sql文件, 在服务器上登录mysql执行 source (如:source exposition_exposition.sql) 文件路 ...
- 基于PySpark的网络服务异常检测系统 (四) Mysql与SparkSQL对接同步数据 kmeans算法计算预测异常
基于Django Restframework和Spark的异常检测系统,数据库为MySQL.Redis, 消息队列为Celery,分析服务为Spark SQL和Spark Mllib,使用kmeans ...
随机推荐
- 使用C#创建SQLite控制台应用程序
本文属于原创,转载请注明出处,谢谢! 一.开发环境 操作系统:Windows 10 X64 开发环境:VS2015 编程语言:C# .NET版本:.NET Framework 4.0 目标平台:X86 ...
- Windows10上使用Linux子系统(WSL)
Linux的Windows子系统让开发人员可以直接在Windows上运行Linux环境(包括大多数命令行工具,实用程序和应用程序),而无需建立在虚拟机的开销之上,整个系统共200多M,但包含了你能用到 ...
- K进制数
题目描述 考虑包含N位数字的K-进制数. 定义一个数有效, 如果其K-进制表示不包含两连续的0. 考虑包含N位数字的K-进制数. 定义一个数有效, 如果其K-进制表示不包含两连续的0. 例: 1010 ...
- matplotlib 入门之Image tutorial
文章目录 载入图像为ndarray 显示图像 调取各个维度 利用cmp 获得像素点的RGB的统计 通过clim来限定rgb 标度在下方 插值,马赛克,虚化 matplotlib教程学习笔记 impor ...
- Linux系统安装python3
Centos7系统安装python3 在安装前需要安装依赖环境包,先安装gcc 编译器,命令如下: yum -y install gcc gcc-c++ make 1.首先查看是否安装python,系 ...
- BeautifulSoup库
'''灵活又方便的网页解析库,处理高效,支持多种解析器.利用它不用编写正则表达式即可方便的实现网页信息的提取.''' BeautifulSoup库包含的一些解析库: 解析库 使用方法 优势 劣势 py ...
- 我们为什么要使用List和Set(List,Set详解)
1.集合概述 类图 集合和数组的区别? 集合基本方法 集合特有的遍历方式? public static void main(String[] args) { //创建集合对象 Collection c ...
- 使用Browser请求 和 在cli中运行程序的分析
在browser中请求后端的一个程序之后,立马将窗口关闭,服务器端的程序是否会挂起或者终止,还是继续执行? 如果是继续执行,那么执行完毕后,结果去了哪里?-->apache的工作流程 使用Bro ...
- shell脚本--CGI获取请求数据(GET / POST)
Case 1: 获取地址栏传递的参数(即通过GET方式) CGI的环境变量中有个QUERY_STRING,可以获取地址栏传递的参数,该参数可以是手动加上的,也可以是通过表单的get方式提交的,比如下面 ...
- Spring Mvc和Spring Boot读取Profile方式
spring boot java代码中获取spring.profiles.active - u013042707的专栏 - CSDN博客https://blog.csdn.net/u013042707 ...