Skip to content

Commit 993488f

Browse files
committedDec 16, 2018
分布式系统
1 parent 14a4171 commit 993488f

File tree

4 files changed

+63
-9
lines changed

4 files changed

+63
-9
lines changed
 

‎README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
![整体流程](https://raw.githubusercontent.com/qiurunze123/imageall/master/miaosha.png)
2121

22-
> 软件环境 : 未来设计
22+
> 未来设计图 : 未来设计
2323
2424
![整体流程](https://raw.githubusercontent.com/qiurunze123/imageall/master/futuremiaosha.png)
2525

@@ -64,7 +64,8 @@
6464
| 022 |mysql主从复制思路及实操(未更新代码) |[解决思路](/docs/mysql-master-slave.md) |
6565
| 023 |如何进行分库分表 |[解决思路](/docs/mysql-master-slave.md) |
6666

67-
#### [分布式基础--未更新](/docs/redis-code.md)
67+
#### [分布式系统发展历程(已更新)](/docs/fenbushi.md)
68+
#### [分布式系统](/docs/redis-code.md)
6869
#### [mybatis源码解析--未更新](/docs/mybatis-code.md)
6970
#### [redis专题缓存的优势及如何进行集群--未更新](/docs/redis-code.md)
7071
#### [spring源码--未更新](/docs/redis-code.md)

‎docs/fenbushi.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
### 分布式系统
2+
3+
有问题或者宝贵意见联系我的QQ,非常希望你的加入!
4+
5+
> 分布式系统历程----1
6+
7+
![整体流程](https://raw.githubusercontent.com/qiurunze123/imageall/master/fenbushi1.png)
8+
9+
> 分布式系统历程----2
10+
11+
![整体流程](https://raw.githubusercontent.com/qiurunze123/imageall/master/fenbushi2.png)
12+
13+
> 分布式系统历程----3
14+
15+
![整体流程](https://raw.githubusercontent.com/qiurunze123/imageall/master/fenbushi3.png)
16+
17+
> 分布式系统历程----4
18+
19+
![整体流程](https://raw.githubusercontent.com/qiurunze123/imageall/master/fenbushi4.png)
20+
21+
> 分布式系统历程----5
22+
23+
![整体流程](https://raw.githubusercontent.com/qiurunze123/imageall/master/fenbushi5.png)
24+
25+
> 分布式系统历程----6
26+
27+
![整体流程](https://raw.githubusercontent.com/qiurunze123/imageall/master/fenbushi6.png)
28+
29+
> 分布式系统历程----7
30+
31+
![整体流程](https://raw.githubusercontent.com/qiurunze123/imageall/master/fenbushi7.png)
32+
33+

‎docs/mysql-master-slave.md

+25-5
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,15 @@
7171
mysql的配置文件: /etc/my.cnf
7272
mysql的日志文件: /var/log/mysql.log
7373

74-
140 为master
74+
140 为master
75+
7576
1. 创建一个用户’repl’,并且允许其他服务器可以通过该用户远程访问master,通过该用户去读取二进制数据,实现数据同步
76-
Create user repl identified by ‘repl; repl用户必须具有REPLICATION SLAVE权限,除此之外其他权限都不需要
77-
GRANT REPLICATION SLAVE ON *.* TO ‘repl’@’%’ IDENTIFIED BY ‘repl’ ;
77+
create user repl identified by ‘repl; repl用户必须具有replication slave权限,除此之外其他权限都不需要
78+
grant replication slave on *.* to ‘repl’@’%’ identified BY ‘repl’ ;
7879
2. 修改140 my.cnf配置文件,在[mysqld] 下添加如下配置
7980
log-bin=mysql-bin //启用二进制日志文件
8081
server-id=130 服务器唯一ID
81-
3. 重启数据库 systemctl restart mysqld
82+
3. 重启数据库 systemctl restart mysqld sudo /etc/init.d/mysql start
8283
4. 登录到数据库,通过show master status 查看master的状态信息
8384
142 为slave
8485
1. 修改142 my.cnf配置文件, 在[mysqld]下增加如下配置
@@ -88,7 +89,26 @@
8889
read_only=1
8990
2. 重启数据库: systemctl restart mysqld
9091
3. 连接到数据库客户端,通过如下命令建立同步连接
91-
change master to master_host=’192.168.11.140’, master_port=3306,master_user=’repl’,master_password=’repl’,master_log_file=’mysql-bin.000001’,master_log_pos=0;
92+
change master to master_log_file='mysql-bin 隆.000002',master_log_pos=154;
93+
error:
94+
ERROR 1794 (HY000): Slave is not configured or failed to initialize properly. You must at least set --server-id to enable either a master or a slave. Additional error messages can be found in the MySQL error log.
95+
最后通过如下的操作解决的问题,具体原因还尚未清楚
96+
CHANGE MASTER TO
97+
MASTER_HOST='39.107.245.253',
98+
MASTER_USER='repl',
99+
MASTER_PASSWORD='repl',
100+
MASTER_LOG_FILE='mysql-bin 隆.000001',
101+
MASTER_LOG_POS= 154;
102+
(1)登录数据库后,删除5张表,并重新导入脚本
103+
use mysql
104+
drop table slave_master_info;
105+
drop table slave_relay_log_info;
106+
drop table slave_worker_info;
107+
drop table innodb_index_stats;
108+
drop table innodb_table_stats;
109+
---------------------
110+
2.重启数据库
111+
change master to master_host='39.107.245.253', master_port=3306,master_user='repl',master_password='repl',master_log_file='mysql-bin 隆.000001',master_log_pos=154;
92112
红色部分从master的show master status可以找到对应的值,不能随便写。
93113
4. 执行 start slave
94114
5. show slave status\G;查看slave服务器状态,当如下两个线程状态为yes,表示主从复制配置成功

‎src/main/resources/application.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mybatis.config-locations=classpath:mybatis/config.xml
2020
#datasource
2121
spring.datasource.url=jdbc:mysql://39.107.245.253:3306/miaosha?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false
2222
spring.datasource.username=root
23-
spring.datasource.password=root
23+
spring.datasource.password=nihaoma
2424
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
2525
#druid
2626
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
@@ -49,7 +49,7 @@ spring.resources.static-locations=classpath:/static/
4949
redis.host=39.107.245.253
5050
redis.port=6379
5151
redis.timeout=100
52-
redis.password=123456
52+
redis.password=youxin11
5353
redis.poolMaxTotal=1000
5454
redis.poolMaxIdle=500
5555
redis.poolMaxWait=500

0 commit comments

Comments
 (0)
Please sign in to comment.