设置双机热备:

首先要在两台机器上建立同步用户:

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双机热备的配置步骤的更多相关文章

  1. mysql双机热备的实现

    转:http://blog.csdn.net/qq394829044/article/details/53203645 Mysql数据库没有增量备份的机制,当数据量太大的时候备份是一个很大的问题.还好 ...

  2. (转)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 ...

  3. mysql 主从复制(mysql双机热备的实现)

    转:http://blog.csdn.net/qq394829044/article/details/53203645 Mysql数据库没有增量备份的机制,当数据量太大的时候备份是一个很大的问题.还好 ...

  4. Mysql双机热备--预备知识

    1.双机热备 对于双机热备这一概念,我搜索了很多资料,最后,还是按照大多数资料所讲分成广义与狭义两种意义来说. 从广义上讲,就是对于重要的服务,使用两台服务器,互相备份,共同执行同一服务.当一台服务器 ...

  5. MySQL双机热备环境搭建

    一.    前期准备 准备两台服务器(电脑),接入到同一局域网中,能够使双方可以ping通: 安装MySQL数据库,具体安装方法网上很全面,但是安装的版本需保持一致: 服务器IP地址设置. l  A服 ...

  6. CentOS系统MySQL双机热备配置

    1  概述 在集成项目中需要应对不同环境下的安装配置,主流操作系统大致可以分为三种:Linux.Windows以及UNIX.其中Linux备受青睐的主要原因有两个: 首先,Linux作为自由软件有两个 ...

  7. Mysql双机热备配置(超详细多图版)

    一.双击热备介绍 1.基本概念 双机热备特指基于高可用系统中的两台服务器的热备(或高可用),双机高可用按工作中的切换方式分为:主-备方式(Active-Standby方式)和双主机方式(Active- ...

  8. Centos7 Mysql 双机热备实现数据库高可用

    mysql双主热备,也称主主互备,目的是mysql数据库高可用,只支持双机,原因是mysql的复制是一主多从,但一个从服务器只能有一个主服务器. 双机热备的条件是双机mysql版本必须一致. 服务器分 ...

  9. Mysql双机热备实现数据库高可用

    mysql双主热备,也称主主互备,目的是mysql数据库高可用,只支持双机,原因是mysql的复制是一主多从,但一个从服务器只能有一个主服务器. 双机热备的条件是双机mysql版本必须一致. 服务器分 ...

随机推荐

  1. 结构体struct和联合体union以及enum枚举体5的区别

    下面来自wikipedia: In computer science, a union is a value that may have any of several representations ...

  2. document.getElementsByClassName在ie8及其以下浏览器的兼容性问题

    原生js方法“document.getElementsByClassName”在ie8及其以下浏览器中,不能使用. 修改:加入兼容性判断,在需要用到该方法的位置修改为getClassNames方法. ...

  3. Windows Azure 社区新闻综述(#76 版)

    欢迎查看最新版本的每周综述,其中包含有关云计算和 Windows Azure 的社区推动新闻.内容和对话.以下是本周的亮点. 文章.视频和博客文章 ·   更新 Windows Azure 中的 SQ ...

  4. git pull 出错 fatal: Could not read from remote repository.Please make sure you have the correct access rights.and the repository exists.

    Warning: Permanently added the RSA host key for IP address '192.30.252.131' to the list of known hos ...

  5. 数据结构——链表(linkedlist)

    基本分类: 1.单向链表 2.带尾指针的单向链表 3.双向循环链表 以下分类进行说明 1.单向链表 基本元素:*front //头节点 *next //下一节点 声明:node<T>*p; ...

  6. Objective-C 类,实例成员,静态变量,对象方法,类方法(静态方法),对象,

    Objective-C 类,实例成员,静态变量,对象方法,类方法(静态方法),对象, 一.类 在ios中,类的声明和实现时分离的,也就是说不能写在同一个文件中,声明放在 .h文件中,实现放在 .m 文 ...

  7. 给EditText中的图片加监听

    package com.example.helloword; import android.app.Activity; import android.content.Context; import a ...

  8. 最全的LBS手机定位技术说明

    随着手机技术的发展定位方式也发生了非常大的变化.获取手机位置有非常多种方式. 第一种:CELL-ID定位原理 通过移动网络获取设备当前所在的Cell信息来获取设备当前位置.当设备位置更新设备会向当前服 ...

  9. ZOJ 3331 Process the Tasks 双塔Dp

    用dp[i][j]表示当前安排好了前i个任务,且机器A和机器B完成当前分配到的所有任务的时间差为j(这里j可正可负,实现的时候需要加个offset)时,完成这些任务的最早时间.然后根据j的正负,分别考 ...

  10. 一致性算法--Paxos

    分布式一致性算法--Paxos Paxos算法是莱斯利·兰伯特(Leslie Lamport)1990年提出的一种基于消息传递的一致性算法.Paxos算法解决的问题是一个分布式系统如何就某个值(决议) ...