最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

mysql双机热备的配置步骤_MySQL

来源:动视网 责编:小采 时间:2020-11-09 19:41:18
文档

mysql双机热备的配置步骤_MySQL

mysql双机热备的配置步骤_MySQL:设置双机热备: 首先要在两台机器上建立同步用户: grant replication slave on *.* to 'repdcs'@'192.168.21.39' identified by '123456'; grant all privileges on *.* to 'repdcs'@'192.168.21.39 iden
推荐度:
导读mysql双机热备的配置步骤_MySQL:设置双机热备: 首先要在两台机器上建立同步用户: grant replication slave on *.* to 'repdcs'@'192.168.21.39' identified by '123456'; grant all privileges on *.* to 'repdcs'@'192.168.21.39 iden


设置双机热备:

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

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默认主服务器是1可以随便设置但是如果有多台从服务器则不能重复。
master-host=192.168.21.39 //主服务器的IP地址或者域名
master-port=3306 //主数据库的端口号
master-user=repdcs //同步数据库的用户
master-password=123456 //同步数据库的密码
master-connect-retry=60 //如果从服务器发现主服务器断掉,重新连接的时间差

report-host=db-slave.mycompany.com //报告错误的服务器

然后重启两个机器的数据库,基本就没问题了,大致步骤给主从差不多,可以参考我的博客 mysql主从的参数配置与步骤

文档

mysql双机热备的配置步骤_MySQL

mysql双机热备的配置步骤_MySQL:设置双机热备: 首先要在两台机器上建立同步用户: grant replication slave on *.* to 'repdcs'@'192.168.21.39' identified by '123456'; grant all privileges on *.* to 'repdcs'@'192.168.21.39 iden
推荐度:
标签: 步骤 过程 教程
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top