mysql双机热备的配置步骤
设置双机热备:
首先要在两台机器上建立同步用户:
grant replication slave on *.* to 'repdcs'@'192.168.21.39' identified by '123456';
grant all privileges on *.* to 'repdcs'@'192.168.21.39 identified by '123456';
FLUSH PRIVILEGES;
grant replication slave on *.* to 'repdcs'@'192.168.21.106' identified by '123456';
grant all privileges on *.* to 'repdcs'@'192.168.21.106 identified by '123456';
FLUSH PRIVILEGES;
库1
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
port=3306
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
lower_case_table_names=1
default-character-set=utf8
default-storage-engine=innodb
max_connect_errors = 100000
innodb_buffer_pool_size= 8G
max_connections = 500
default-character-set=utf8
server-id=2
#log-bin=mysqlbin
innodb_flush_log_at_trx_commit=1
sync_binlog=1
init_connect='SET NAMES utf8'
log-bin=mysqlbin
master-host=192.168.21.39
master-user=repdcs
master-pass=123456
master-connect-retry=60
replicate-do-db=dcs
master-port=3306
slave-net-timeout=60
库2
[mysqld]
#datadir=/var/lib/mysql
datadir=/home/data/mysql
#socket=/var/lib/mysql/mysql.sock
socket=/home/data/mysql/mysql.sock
user=mysql
port=3306
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
default-character-set=utf8
init_connect = 'SET NAMES utf8'
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
server-id=1
log-bin=mysqlbin
innodb_flush_log_at_trx_commit=1
sync_binlog=1
init_connect='SET NAMES utf8'
log-bin=mysqlbin
master-host=192.168.21.106
master-user=repdcs
master-pass=123456
master-connect-retry=60
replicate-do-db=dcs
master-port=3306
slave-net-timeout=60
#replicate-do-db=dcs
back_log = 512
key_buffer_size = 8M
max_allowed_packet = 4M
sort_buffer_size = 6M
read_buffer_size = 4M
join_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 64
query_cache_size = 0M
tmp_table_size = 96M
max_connections = 500
table_cache= 1024
innodb_additional_mem_pool_size= 16M
innodb_log_buffer_size= 64M
read_rnd_buffer_size= 16M
innodb_buffer_pool_size= 1G
innodb_log_file_size = 256M
max_heap_table_size = 96M
innodb_data_file_path = ibdata1:200M:autoextend
default-storage-engine=innodb
max_connect_errors = 100000
long_query_time = 1
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
default-character-set=utf8
标红的话主要两台机器的不同部分。
重新启动假设出问题
show slave status \G
Last_Error: Error 'Can't create database 'dcs'; database exists' on query. Default database: 'dcs'. Query: 'cr
查询从库发现须要建立的数据库已经存在,所以能够跳过这个建库的命令.
使用set global sql_slave_skip_counter=1;
start slave sql_thread;
flush privileges
server-id=n //设置数据库id默认主server是1能够随便设置可是假设有多台从server则不能反复。
master-host=192.168.21.39 //主server的IP地址或者域名
master-port=3306 //主数据库的端口号
master-user=repdcs //同步数据库的用户
master-password=123456 //同步数据库的密码
master-connect-retry=60 //假设从server发现主server断掉,又一次连接的时间差
report-host=db-slave.mycompany.com //报告错误的server
然后重新启动两个机器的数据库,基本就没问题了,大致步骤给主从差点儿相同,能够參考我的博客 mysql主从的參数配置与步骤
mysql双机热备的配置步骤的更多相关文章
- mysql双机热备的实现
转:http://blog.csdn.net/qq394829044/article/details/53203645 Mysql数据库没有增量备份的机制,当数据量太大的时候备份是一个很大的问题.还好 ...
- (转)mysql双机热备的实现
mysql双机热备的实现 原文:http://www.zjian.me/web/php/mysql%E5%8F%8C%E6%9C%BA%E7%83%AD%E5%A4%87%E7%9A%84%E5%AE ...
- mysql 主从复制(mysql双机热备的实现)
转:http://blog.csdn.net/qq394829044/article/details/53203645 Mysql数据库没有增量备份的机制,当数据量太大的时候备份是一个很大的问题.还好 ...
- Mysql双机热备--预备知识
1.双机热备 对于双机热备这一概念,我搜索了很多资料,最后,还是按照大多数资料所讲分成广义与狭义两种意义来说. 从广义上讲,就是对于重要的服务,使用两台服务器,互相备份,共同执行同一服务.当一台服务器 ...
- MySQL双机热备环境搭建
一. 前期准备 准备两台服务器(电脑),接入到同一局域网中,能够使双方可以ping通: 安装MySQL数据库,具体安装方法网上很全面,但是安装的版本需保持一致: 服务器IP地址设置. l A服 ...
- CentOS系统MySQL双机热备配置
1 概述 在集成项目中需要应对不同环境下的安装配置,主流操作系统大致可以分为三种:Linux.Windows以及UNIX.其中Linux备受青睐的主要原因有两个: 首先,Linux作为自由软件有两个 ...
- Mysql双机热备配置(超详细多图版)
一.双击热备介绍 1.基本概念 双机热备特指基于高可用系统中的两台服务器的热备(或高可用),双机高可用按工作中的切换方式分为:主-备方式(Active-Standby方式)和双主机方式(Active- ...
- Centos7 Mysql 双机热备实现数据库高可用
mysql双主热备,也称主主互备,目的是mysql数据库高可用,只支持双机,原因是mysql的复制是一主多从,但一个从服务器只能有一个主服务器. 双机热备的条件是双机mysql版本必须一致. 服务器分 ...
- Mysql双机热备实现数据库高可用
mysql双主热备,也称主主互备,目的是mysql数据库高可用,只支持双机,原因是mysql的复制是一主多从,但一个从服务器只能有一个主服务器. 双机热备的条件是双机mysql版本必须一致. 服务器分 ...
随机推荐
- BZOJ 1621: [Usaco2008 Open]Roads Around The Farm分岔路口
题目 1621: [Usaco2008 Open]Roads Around The Farm分岔路口 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 56 ...
- POJ 3667 splay区间盘整运动
Hotel Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 12446 Accepted: 5363 Descriptio ...
- android中menu菜单的简单使用
我认为menu用起来简洁方便,特别是在一些大一点的程序中我们早就厌烦了一遍遍的加button,设置了菜单可谓是事半功倍,简单省事. <1>先声明定义下你的menu: private sta ...
- css中的定位
上一篇博客,我大概介绍了下浮动的使用及行为.其实在整个文档布局中,定位也对我们整个的页面排版有非常好的帮助,当然前提是使用得当. 一.定位分类: a.静态定位 position:static; ...
- 简单仿京东导航下拉菜单 javascript
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> ...
- 小猪猪逆袭成博士之C++基础篇(二) 常量、处理类型、自定义头文件
小猪猪逆袭成博士之C++基础篇(二) const .auto. decltype 上一章我们介绍了一些常用的类型和常见的问题,下面再介绍一些学习的时候不是特别常用但是在实际工程中很有用的一些东西. 一 ...
- PHP给图片加文字水印
<?php /*给图片加文字水印的方法*/ $dst_path = 'http://f4.topitme.com/4/15/11/1166351597fe111154l.jpg'; $dst = ...
- Altera FPGA中的pin简介
第一步要看的肯定是pin planner ,这个是黑金四代EP4CE15F17C8的视图 先就是发现他们pin有不同的颜色区域,分别对应不同的bank,应该是有的设计里面要求pin在同一个bank吧( ...
- 17.1.1.4 Obtaining the Replication Master Binary Log Coordinates 获取复制Master Binary Log的坐标:
17.1.1.4 Obtaining the Replication Master Binary Log Coordinates 获取复制Master Binary Log的坐标: 你需要master ...
- Hdu 1158 Employment Planning(DP)
Problem地址:http://acm.hdu.edu.cn/showproblem.php?pid=1158 一道dp题,或许是我对dp的理解的还不够,看了题解才做出来,要加油了. 只能先上代码了 ...