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 ...
随机推荐
- 如何选择分布式事务形态(TCC,SAGA,2PC,补偿,基于消息最终一致性等等)
各种形态的分布式事务 分布式事务有多种主流形态,包括: 基于消息实现的分布式事务 基于补偿实现的分布式事务(gts/fescar自动补偿的形式) 基于TCC实现的分布式事务 基于SAGA实现的分布式事 ...
- git revert 还有这个坑?
最近也是终于开启了代码编写之旅,我只能默默地说一句,写代码的感觉,简直不能再爽! 不过也由于 git 的分支管理蛋疼懵逼很久,所以必须记录以及和大家分享一下本次坑爹的旅行. 写在前面 每个公司相比都有 ...
- python 跨域处理方式
因为浏览器的同源策略限制,不是同源的脚本不能操作其他源下面的资源,想操作另一个源下面的资源就属于跨域了,这里说的跨域是广义跨域,我们常说的代码中请求跨域,是狭义的跨域,即在脚本代码中向非同源域发送ht ...
- OO生存指.....抱歉无法生存
还记得前三次的设计策略:星期二之前实现功能,星期三找一下可能出现的小bug. 这三次以及变成了:星期二之前能跑出来就行. 总体来说设计策略是:先让几个线程能够顺利运行,再开始实现功能. 在接触到多线程 ...
- 2018 Multi-University Training Contest 2
题目链接:2018 Multi-University Training Contest 2 6318 Swaps and Inversions 题意:sum=x*逆序个数+交换次数*y,使sum最小 ...
- c++入门之 深入cin
cin 表示输入流,但是究其本质,又能认识到什么呢?先上代码: #include "iostream" };//c++11中使用{}进行重新命名 int main() { usin ...
- Graph Without Long Directed Paths CodeForces - 1144F (dfs染色)
You are given a connected undirected graph consisting of nn vertices and mm edges. There are no self ...
- 20分钟 看图手写的table
<html><body><table width="100%" border="1" cellspacing="0&qu ...
- JavaScript生成二维码图片
1.引入一个二维码工具的js文件,同时需要引入jquery文件 下面是jquery.qrcode.min.js文件内容: (function(r){r.fn.qrcode=function(h){va ...
- CMake--List用法
list(LENGTH <list><output variable>) list(GET <list> <elementindex> [<ele ...