惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
I
InfoQ
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
Y
Y Combinator Blog
博客园_首页
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
T
The Blog of Author Tim Ferriss
C
Check Point Blog
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Engineering at Meta
Engineering at Meta
B
Blog
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
F
Fortinet All Blogs
月光博客
月光博客
GbyAI
GbyAI

博客园 - 天纯蓝

go错误总结(27条) GO语言最主的特性 解决“Comparison method violates its general contract!” maven buid 导出项目依赖的jar包问题 [数据库]漫谈ElasticSearch关于ES性能调优几件必须知道的事(转) MongoDB 聚合管道(Aggregation Pipeline) mongodb分布式查询 MongoDB JAVA API Filters mongodb.conf配置文件详解 mongodb安装配置 Elasticsearch-2.3.x填坑之路 CentOS VMware 下SSH配置方法详解 15个nosql数据库 MySql 优化 Elasticsearch 相关名词理解 Elasticsearch集群中处理大型日志流的几个常用概念 ES配置文件参考与参数详解 Java连接Elasticsearch集群 Linux下Tomcat的启动、关闭、杀死进程
Centos7 Mysql5.7主从服务器配置
天纯蓝 · 2017-11-02 · via 博客园 - 天纯蓝

在两台Linux机器上安装MySQL

一、Master主服务器配置
1.编辑my.cnf(命令查找文件位置:find / -name my.cnf)
vi /etc/mysql/my.cnf

在[mysqld]中添加:

server-id = 100
innodb_flush_log_at_trx_commit = 1
sync_binlog = 1
log_bin = master-bin
log_bin_index = master-bin.index
binlog_do_db = my_data
binlog_ignore_db = mysql

备注:server-id 服务器唯一标识,log_bin 启动MySQL二进制日志,binlog_do_db 指定记录二进制日志的数据库,binlog_ignore_db 指定不记录二进制日志的数据库。

2.登录主服务器MySQL创建从服务器用到的账户和权限:

GRANT REPLICATION SLAVE ON *.* TO 'backup'@'%' IDENTIFIED BY '密码'

3.重启MySQL
systemctl restart mysqld.service

4.释放锁
mysql> UNLOCK TABLES;

5.登录MySQL状态下,查看主服务器状态:
mysql> show master status;
+-------------------+----------+----------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-------------------+----------+----------------+------------------+-------------------+
| master-bin.000001 | 2261 | my_data | mysql | |
+-------------------+----------+----------------+------------------+-------------------+

二、Slave从服务器配置
1.编辑my.cnf(命令查找文件位置:find / -name my.cnf)
vi /etc/mysql/my.cnf

在[mysqld]中添加:

server-id = 101
relay_log = slave-relay-bin
relay_log_index = slave-relay-bin.index

2.重启MySQL
systemctl restart mysqld.service


3.登录Slave从服务器,连接Master主服务器
mysql> change master to master_host='主服务器IP',master_port=3306,master_user='backup',master_password='密码',master_log_file='master-bin.000001',master_log_pos=154;

4.执下面命令,根据具体的错误来判定,一般用于主键冲突或者更新失败错误,进行手动跳过。
mysql> stop slave sql_thread;set global sql_slave_skip_counter=1;start slave sql_thread;

5.登录MySQL状态下,启动Slave数据同步。
start slave;

6.登录MySQL状态下,查看Slave信息:
show slave status\G;

Slave_IO_Running和Slave_SQL_Running都为yes才表示同步成功。
Slave_IO_Running: Yes
Slave_SQL_Running: Yes