MySql数据库的主从配置
主服务器 192.168.7.182 Centos6.5 MYSQL5.6.10
从服务器 192.168.112.7 Centos6.5 MYSQL5.6.10
- 主服务器配置(192.168.7.182)
vi /etc/my.cnf
[mysqld]
server-id=1
log-bin=mysql-bin
binlog-do-db=hello 需要同步的数据库名(不用提前创建)保存重启mysql服务
service mysql restart
主服务器配置完毕
2. 查看主服务器信息
mysql> show master status\G
*************************** 1. row ***************************
File: mysql-bin.000002
Position: 120
Binlog_Do_DB: hello
Binlog_Ignore_DB:
Executed_Gtid_Set:
1 row in set (0.00 sec)
3. 从服务器配置(192.168.112.7)
vi /etc/my.cnf
加上
[mysqld]
server-id=2
log-bin=log保存重启mysql服务
service mysql restart
从服务器配置完毕
4. 配置完了就需要建立主从服务器之间的关系
mysql>change master to
master_host = '192.168.7.182',
master_user = 'root',
master_port=3306,
master_password='123456',
master_log_file = 'mysql-bin.000002', (和主服务器 File 参数对应)
master_log_pos=120; (和主服务器 Position 参数对应)
5. 查看从服务器状态
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.7.182
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 262
Relay_Log_File: liuchao-relay-bin.000003
Relay_Log_Pos: 425
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 262
Relay_Log_Space: 600
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: f242269d-cbaf-11e4-b866-000c29f4cbd9
Master_Info_File: /var/lib/mysql/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec)
6. 配置完了再重启一下mysql服务
service mysql restart
7.测试一下
在192.168.7.182(主)服务器上创建hello数据库,会发现192.168.112.7(从)服务器上也会出现在hello数据库
在192.168.7.182(主)服务器上对hello数据库的操作都会同步到192.168.112.7(从)服务器上
8.配置的时候注意Mysql的版本,不同的版本配置不同
MySql数据库的主从配置的更多相关文章
- MySQL数据库服务器 主从配置
A B 为两台 MySQL 服务器,均开启二进制日志,数据库版本 MySQL 5.5 一.服务器参数 [A 服务器 192.168.1.100] server-id = 1 binlog-do-d ...
- MySQL 数据库的主从配置
mysql主从配置.鄙人是在如下环境测试的: 主数据库所在的操作系统:win7 主数据库的版本:5.0 主数据库的ip地址:192.168.1.111 从数据库所在的操作系统:linux 从数据的版本 ...
- MySQL数据库的主从同步复制配置
一.主从同步机制原理 MYSQL主从同步是在MySQL主从复制(Master-Slave Replication)基础上实现的,通过设置在Master MySQL上的binlog(使其处于打开状态), ...
- mysql数据库的主从同步,实现读写分离 g
https://blog.csdn.net/qq_15092079/article/details/81672920 前言 1 分别在两台centos 7系统上安装mysql 5.7 2 master ...
- Mysql数据库的主从与主主
前言: 首先,我们得知道我们为什么要做数据库的主从与主主,而后,再讨论他们的优劣与特点:为什么要做主从呢?因为Mysql数据库没有增量备份的机制,当数据量太大的时候备份是个难以解决的问题.但是mysq ...
- mysql数据库的主从同步,实现读写分离
大型网站为了软解大量的并发访问,除了在网站实现分布式负载均衡,远远不够.到了数据业务层.数据访问层,如果还是传统的数据结构,或者只是单单靠一台服务器来处理如此多的数据库连接操作,数据库必然会崩溃,特别 ...
- Mysql数据库安装和配置
http://blog.csdn.net/pipisorry/article/details/46773507 Mysql数据库安装和配置.mysql语法.特殊符号及正则表达式的使用.MySQL备份与 ...
- SpringBoot-(8)-配置MySQL数据库链接,配置数据坚挺拦截,创建默认数据表
一,链接mysql数据库 # 数据源基本配置 spring.datasource.username=root spring.datasource.password=123456 spring.data ...
- 菜鸟的《Linux程序设计》学习——MySQL数据库安装、配置及基本操作
1. MySQL数据库: 在涉及到一些大型的Web系统或者嵌入式软件的开发时,都少不了用数据库来管理数据.在Windows操作系统下,使用过各种各样的数据库,如:sqlServer.Oracle.My ...
随机推荐
- wtform 表单示例
用户注册 from flask import Flask, render_template, request, redirect from wtforms import Form from wtfor ...
- 单线程爬虫VS多线程爬虫的效率对比
单线程爬虫: import re import requests import time url_EB = 'http://www.amazon.com/gp/search/other/ref=sr_ ...
- nginx访问css js 图片等静态资源,报404或无法定向访问到
配置完nginx,把php的项目放上去后,发现css,js和图片全部访问不到,一直重定向到根目录执行index.php,郁闷的在网上查了半天,原来不同后缀名的文件访问时都要在nginx.conf中声明 ...
- python学习【第四篇】python函数 (一)
一.函数的介绍 函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段. 函数能提高应用的模块性,和代码的重复利用率.你已经知道Python提供了许多内建函数,比如print().但你也可以 ...
- 网络免费API接口整理
转载自: https://www.cnblogs.com/doit8791/p/9351629.html 从网上看到一些免费API接口,在个人开发小程序等应用练手时可试用. 各类无次数限制的免费API ...
- MFC重绘原理的关键理解
// ====================Windows重绘消息与函数========================== 得到桌面窗口的句柄,然后再绘图HWND GetDesktopWindow ...
- SqlProfiler的替代品-ExpressProfiler
可以用来跟踪执行的sql语句.安装SqlServer之后SqlServerManagementStudio自带一个SqlProfiler,但是如果安装的SqlExpress,那就没有了. 项目的主页在 ...
- 让phpstorm 支持 vue文件并且语法高亮
1 安装 vue.js 插件 很遗憾,我的win版本没有支持的插件 2 修改文件类型 vue本质上还是html文件,包含了css html js,用html类型文件打开就可以 给html 文件添加 * ...
- Android 4.4 Kitkat 音频实现及简要分析
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/jingxia2008/article/details/26701899 在 Android 4.4 ...
- 0404-服务注册与发现-客户端负载均衡-两种自定义方式-Ribbon通过代码自定义配置、使用配置文件自定义Ribbon Client
一.官方文档解读 官方地址:https://cloud.spring.io/spring-cloud-static/Edgware.SR3/single/spring-cloud.html#_cust ...