Skip to content

Commit

Permalink
重新优化文档排版
Browse files Browse the repository at this point in the history
  • Loading branch information
bajins committed Aug 2, 2019
1 parent dffc2d7 commit 7f4db20
Show file tree
Hide file tree
Showing 25 changed files with 383 additions and 451 deletions.
File renamed without changes.
49 changes: 25 additions & 24 deletions JAVA/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
# Java

# 目录
* [前端框架](##前端框架)
* [后端框架](##后端框架)
* [延迟队列](##延迟队列)
* [工具](##工具)
* [地区数据](##地区数据)
* [API](##API)
* [Java面试题](##Java面试题)
## 目录
* [前端框架](#前端框架)
* [后端框架](#后端框架)
* [延迟队列](#延迟队列)
* [工具](#工具)
* [地区数据](#地区数据)
* [Java面试题](#Java面试题)

*****************************************************************************

### [JavaFX开发](/JAVA/JavaFX.md)
## windows环境变量

```batch
JAVA_HOME
C:\Program Files\Java\jre1.8.0_171
CATALINA_HOME
D:\apache-tomcat-8.5.30
### log文件夹为aop切面日志拦截
CLASSPATH
.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\lib;
### [Java笔记](/JAVA//Java笔记.md)
Path
;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;%MAVEN_HOME%\bin;%CATALINA_HOME%\bin;
```

### [JavaFX开发](/JAVA/JavaFX.md)

### [项目收集](/JAVA/%E9%A1%B9%E7%9B%AE%E6%94%B6%E9%9B%86.md)
### [Java笔记](/JAVA/Java笔记.md)

### [windows环境变量配置](/JAVA/windows%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F.md)
### [项目收集](/JAVA/项目收集.md)

### [Tomcat优化](/JAVA/Tomcat优化.md)

Expand All @@ -44,9 +55,6 @@
[f2ex.cn 各种前端资源](http://f2ex.cn/)


### Android
[专出网络框架的square](https://github.com/square)

## 后端框架
[dubbo](https://github.com/apache/incubator-dubbo)

Expand All @@ -67,7 +75,7 @@

[从GBK到UTF8的某些路径中的文件编码转换](https://github.com/downgoon/gbk2utf8)

[JVM监控](/JAVA/JVM.md##监控工具)
[JVM监控](/JAVA/JVM.md#监控工具)

## 地区数据
[district](https://github.com/eduosi/district)
Expand All @@ -79,13 +87,6 @@
[china_regions](https://github.com/wecatch/china_regions)


## [API](/API)
[By jokermonn](https://github.com/jokermonn/-Api)

[koa重写了one一个api](https://github.com/pengchujin/oneisall_api)

[unsplash api](https://unsplash.com/developers)

## Java面试题

[https://github.com/Snailclimb/JavaGuide](https://github.com/Snailclimb/JavaGuide)
Expand Down
24 changes: 0 additions & 24 deletions JAVA/windows环境变量.md

This file was deleted.

2 changes: 1 addition & 1 deletion JavaScript/NodeJs.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NodeJs

## 安装NodeJs
### CentOs7
### CentOS7
```bash
# 到https://github.com/nodesource/distributions#installation-instructions-1
# 复制更新软件源命令,并执行
Expand Down
60 changes: 30 additions & 30 deletions MySQL/MySQL主从同步.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# MySQL主从同步

## 配置主服务器
### [mysqld]节点下按需添加
### `[mysqld]`节点下按需添加

```bash
[mysqld]
# 设置server_id,一般设置为IP,注意要唯一
Expand All @@ -23,16 +24,17 @@ expire_logs_days=5
slave_skip_errors=1062
```
### 创建数据同步用户
#### 这里主要是要授予用户REPLICATION SLAVE权限和REPLICATION CLIENT权限
> 这里主要是要授予用户REPLICATION SLAVE权限和REPLICATION CLIENT权限
```sql
CREATE USER IF NOT EXISTS 'slave'@'%' IDENTIFIED BY '密码';
GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'slave'@'%';
FLUSH PRIVILEGES;
```
## 配置从服务器

### [mysqld]节点下按需添加
#### 从库中的server-id 值一定不要跟主库的一样
### `[mysqld]`节点下按需添加
> 从库中的`server-id`值一定不要跟主库的一样
```sql
[mysqld]
# 设置server_id,一般设置为IP,注意要唯一
Expand Down Expand Up @@ -64,24 +66,30 @@ read_only=1
SHOW MASTER STATUS;
```
#### 查询出来如下
File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
|---------------|---------------|---------------|---------------|---------------|
mysql-bin.000025 | 154 | ichangg_im
| mysql-bin.000025 | 154 | ichangg_im |

### 进入从服务器MySQL执行以下命令
```sql
CHANGE MASTER TO MASTER_HOST='主服务器IP',MASTER_PORT=3306,MASTER_USER='主服务器同步用户名',MASTER_PASSWORD='密码',MASTER_LOG_FILE='主MySQL二进制文件名',MASTER_LOG_POS=Position字段中数据,MASTER_CONNECT_RETRY=30;
```
#### 上面执行的命令的解释:
```diff
+ MASTER_HOST='192.168.1.100' #Master的IP地址
+ MASTER_USER='slave' #用于同步数据的用户(在Master中授权的用户)
+ MASTER_PASSWORD='123456' #同步数据用户的密码
+ MASTER_PORT=3306 #Master数据库服务的端口
+ MASTER_LOG_FILE='edu-mysql-bin.000001' #指定Slave从哪个日志文件开始读复制数据(Master上执行命令的结果的File字段)
+ MASTER_LOG_POS=429 #从哪个POSITION号开始读(Master上执行命令的结果的Position字段)
+ MASTER_CONNECT_RETRY=30 #当建立主从连接时,如果连接建立失败,间隔多久后重试。单位为秒,默认设置为60秒,同步延迟调优参数。
```

> `MASTER_HOST='192.168.1.100'` #Master的IP地址
>
> `MASTER_USER='slave'` #用于同步数据的用户(在Master中授权的用户)
>
> `MASTER_PASSWORD='123456'` #同步数据用户的密码
>
> `MASTER_PORT=3306` #Master数据库服务的端口
>
> `MASTER_LOG_FILE='edu-mysql-bin.000001'` #指定Slave从哪个日志文件开始读复制数据(Master上执行命令的结果的File字段)
>
> `MASTER_LOG_POS=429` #从哪个POSITION号开始读(Master上执行命令的结果的Position字段)
>
> `MASTER_CONNECT_RETRY=30` #当建立主从连接时,如果连接建立失败,间隔多久后重试。单位为秒,默认设置为60秒,同步延迟调优参数。
### 查看主从同步状态
```sql
show slave status;
Expand All @@ -92,10 +100,9 @@ show slave status;
START SLAVE;
```
### 如果出现以下错误
```diff
- ERROR 1872 (HY000): Slave failed to initialize relay log info structure from the repository
```
#### 看样子是找不到中继日志的仓库,但是查看变量relay log的位置是设置了的
> `ERROR 1872 (HY000): Slave failed to initialize relay log info structure from the repository`
#### 看样子是找不到中继日志的仓库,但是查看变量`relay log`的位置是设置了的
```sql
show variables like 'relay%';
```
Expand All @@ -120,10 +127,10 @@ START SLAVE;
SHOW SLAVE STATUS\G
```
#### 如果有以下错误
```diff
- Error 'Operation CREATE USER failed for 'slave'@'%'' on query. Default database: ''. Query:
- 'CREATE USER 'slave'@'%' IDENTIFIED WITH 'mysql_native_password' AS '*040A65A51A0B047A826CDE05448536015D471E15''
```
> `Error 'Operation CREATE USER failed for 'slave'@'%'' on query. Default database: ''. Query: `
>> `'CREATE USER 'slave'@'%' IDENTIFIED WITH 'mysql_native_password' AS '*040A65A51A0B047A826CDE05448536015D471E15''`

#### 先执行以下命令
```sql
STOP SLAVE;
Expand All @@ -138,10 +145,3 @@ START SLAVE;
```








# [返回顶部](#readme)
11 changes: 7 additions & 4 deletions MySQL/MySQL事件.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ CREATE EVENT [IFNOT EXISTS] event_name
[COMMENT 'comment']
DO sql_statement;
```
```diff
+[ON COMPLETION [NOT] PRESERVE] 可以设置这个事件是执行一次还是持久执行,默认为 NOT PRESERVE
+[ENABLE | DISABLE] 可是设置该事件创建后状态是否开启或关闭,默认为ENABLE
+[COMMENT 'comment'] 可以给该事件加上注释

> `[ON COMPLETION [NOT] PRESERVE]` 可以设置这个事件是执行一次还是持久执行,默认为`NOT PRESERVE`
>
> `[ENABLE | DISABLE]` 可是设置该事件创建后状态是否开启或关闭,默认为`ENABLE`
>
> `[COMMENT 'comment']` 可以给该事件加上注释
```
## 修改事件(ALTER EVENT)
```sql
Expand Down
2 changes: 1 addition & 1 deletion MySQL/MySQL存储过程.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 存储过程
# MySQL存储过程

## 创建存储过程
```sql
Expand Down
30 changes: 30 additions & 0 deletions MySQL/MySQL常用语句.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# MySQL常用语句

## 随机取值
> 先根据rand()和id获取一遍随机数,再跟原表关联,最后取出值,因为是随机取,所以你的id值越平均,数据量越大,最后limit之前获取的id值就会越接近整表数据量的一半,limit取到的结果也越接近。
```sql
SELECT * FROM `table1` AS t1 JOIN (SELECT ROUND(RAND() * (SELECT MAX(id) FROM `table1`)) AS id) AS t2 WHERE t1.id >= t2.id ORDER BY t1.id ASC LIMIT 1
```
### 最大减去最小值乘以随机值获取随机数
```sql
SELECT * FROM USER WHERE id >= ( ( SELECT MAX( id ) FROM USER ) - ( SELECT MIN( id ) FROM USER ) ) * RAND( ) + ( SELECT MIN( id ) FROM USER ) LIMIT 1
```
> `order by rand()`效率极低,采用JOIN的语法比直接在WHERE中使用函数效率还要高很多
## 随机插入
### 连续有限队列随机取
```sql
update table1 set a = (floor(rand() * 4) + 3) where b = 84;
```
### 非连续有限队列随机取
```sql
update table1 set a = elt(floor(rand() * 4) + 1, 5, 7, 11, 13) where b = 84;
```

## 查询分组中某字段最大值
> 因为`group by`后取的一条数据默认是按照主键id排序后的第一条,所以对表先排序,然后再分组
```sql
SELECT 别名.* FROM (SELECT * FROM 表名 ORDER BY 字段 DESC) AS 别名 GROUP BY 别名.字段;
```
71 changes: 71 additions & 0 deletions MySQL/MySQL常见问题.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# MySQL常见问题

## GROUP_CONCAT
#### 使用`GROUP_CONCAT`出现:

> Row 147 was cut by GROUP_CONCAT()
#### 由于MySQL的`GROUP_CONCAT`有默认大小值,先查询一下:
```sql
SHOW VARIABLES LIKE 'group_concat_max_len';
#或者
SELECT @@global.group_concat_max_len;
```
#### 默认值为1024
| Variable_name | Value |
|-------------|------------|
| group_concat_max_len | 1024 |

#### 修改默认值大小
##### 在MySQL配置文件中添加配置:
```bash
#-1为最大值或根据实际需求设置长度
group_concat_max_len = -1
```

#### 如果是生产环境下,不能擅自重启MySQL服务,则可以通过语句设置`group_concat`的作用范围:
```sql
SET GLOBAL group_concat_max_len=-1;
SET SESSION group_concat_max_len=-1;
```
## 自定义函数
### 执行自定义函数报错:
> `This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and
binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)`


#### 查看是否开启`log_bin_trust_function_creators`
```sql
SHOW VARIABLES LIKE 'log_bin_trust_function_creators';
#或者
SELECT @@global.log_bin_trust_function_creators;
```
#### 默认关闭
| Variable_name | Value |
|------------------|-----------------|
|log_bin_trust_function_creators | OFF|

#### 开启:
##### 在MySQL配置文件中`[mysqld]`节点下加上:
```bash
log_bin_trust_function_creators=1
```
#### 如果是生产环境下,不能擅自重启MySQL服务,则可以通过语句开启,重启后无效:
```sql
SET GLOBAL log_bin_trust_function_creators = 1;
#或者
SET GLOBAL log_bin_trust_function_creators=TRUE;
```


## 表名未忽略大小写
```bash
vim /etc/my.cnf
```
### `[mysqld]`模块中添加:
```bash
lower_case_table_names = 1
```
### 保存并重启mysql


File renamed without changes.
Loading

0 comments on commit 7f4db20

Please sign in to comment.