diff --git a/_sidebar.md b/_sidebar.md index a3e55d9d0182407ed140917b2f4117627ceeec88..31446f52f57bdea76e43243493fd06b4ebe0acfb 100644 --- a/_sidebar.md +++ b/_sidebar.md @@ -30,7 +30,7 @@ - [MySQL](doc/mysql.md) - [Neo4j](doc/neo4j.md) - [Redis](doc/redis.md) - - [ElasticSearch](doc/elasticsearch.md) + - [ElasticSearch](blog/elasticsearch/index.md) - 其他 - [其他](doc/index.md) diff --git a/blog/elasticsearch/aggregation.md b/blog/elasticsearch/aggregation.md new file mode 100644 index 0000000000000000000000000000000000000000..37c8670026726fdacfde8153ce0dd25eefcb4f00 --- /dev/null +++ b/blog/elasticsearch/aggregation.md @@ -0,0 +1,21 @@ +# 聚合查询 aggregation + +1. 分桶聚合 Bucket agregations + +2. 指标聚合 Metrics + +- avg 平均值 +- max 最大值 +- min 最小值 +- sum 求和 +- cardinality 基数去重 +- value count 计数 +- stats 统计聚合 +- top hits 聚合 + +3. 管道聚合 Pipeline +- 对聚合的结果二次聚合 +- 分类:父级和兄弟级 +- 语法 buckets_path + +https://www.bilibili.com/video/BV1LY4y167n5?p=39&spm_id_from=pageDriver \ No newline at end of file diff --git a/blog/elasticsearch/index.md b/blog/elasticsearch/index.md new file mode 100644 index 0000000000000000000000000000000000000000..7a69fd2161c2b060e94ea9d38d6815f6b530c647 --- /dev/null +++ b/blog/elasticsearch/index.md @@ -0,0 +1,42 @@ +# Elasticsearch + +ElasticSearch官网: [https://www.elastic.co/](https://www.elastic.co/) + + +## 文档 + +- Elasticsearch7.6中文文档 https://www.kancloud.cn/yiyanan/elasticsearch_7_6/1668540 +- Elasticsearch7.6中文文档 https://learnku.com/docs/elasticsearch73/7.3 + +- [Elasticsearch: 权威指南(Elasticsearch 2.x 版本)](https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.html) + +- [Elasticsearch-PHP](https://www.elastic.co/guide/cn/elasticsearch/php/current/index.html) + +- [ELASTIC 搜索开发实战-阅读地址](https://elastic-search-in-action.medcl.com/) +- [ELASTIC 搜索开发实战-github](https://github.com/medcl/book-elastic-search-in-action) + +https://github.com/medcl + + +## 课程介绍 + +课程地址: [【马士兵教育】2022版Elasticsearch教程入门到精通](https://www.bilibili.com/video/BV1LY4y167n5) + +PB级数据,近实时搜索 + +DB-Engines数据库排名:[https://db-engines.com/en/ranking](https://db-engines.com/en/ranking) + +Elastic Stack +- ElasticSearch 基于json的分布式搜索和分析引擎 +- Logstash 动态数据收集管道,生态丰富 +- Kibana 提供数据的可视化界面 +- Beats 轻量级的数据采集器 + +课程中使用的版本 7.10 + +## 目录 + +[Elasticsearch 环境安装](blog/elasticsearch/install.md) + +[聚合查询 aggregation](blog/elasticsearch/aggregation.md) + diff --git a/blog/elasticsearch/install.md b/blog/elasticsearch/install.md new file mode 100644 index 0000000000000000000000000000000000000000..1c3ad9cf44bf93ae87763fb7d51d9afb49869fea --- /dev/null +++ b/blog/elasticsearch/install.md @@ -0,0 +1,186 @@ +# 环境安装 + +课程中使用的版本 7.10(本例使用7.14) + +- 安装Java环境 +- 安装ElasticSearch +- 安装Kibana +- 安装ElasticSearch-Head插件 + +## 1、安装Java环境 + +兼容性查看 +[https://www.elastic.co/cn/support/matrix](https://www.elastic.co/cn/support/matrix) + +- JDK兼容性:JDK 1.8 +- 操作系统兼容性:CentOS7 +- Elastic技术栈兼容性 + + +### 1.1、Linux安装JDK + +```bash +# 搜索jdk +yum search jdk + +# 安装 +yum install -y java-1.8.0-openjdk.x86_64 + +# 验证 +java -version +openjdk version "1.8.0_332" +OpenJDK Runtime Environment (build 1.8.0_332-b09) +OpenJDK 64-Bit Server VM (build 25.332-b09, mixed mode) +``` + +### 1.2、MacOS安装JDK + +```bash +$ java -version +java version "1.8.0_251" +Java(TM) SE Runtime Environment (build 1.8.0_251-b08) +Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode) +``` + +## 2、安装ElasticSearch + +### 2.1、下载地址 + +- 官网下载:[https://www.elastic.co/cn/downloads/past-releases#elasticsearch](https://www.elastic.co/cn/downloads/past-releases#elasticsearch) + +- elasticsearch中文社区:[https://elasticsearch.cn/download/](https://elasticsearch.cn/download/) + +- 华为云镜像:[https://repo.huaweicloud.com/elasticsearch/](https://repo.huaweicloud.com/elasticsearch/) + +### 2.2、下载解压 + +```bash +# elasticsearch +wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.4-linux-x86_64.tar.gz + +# kibana +wget https://artifacts.elastic.co/downloads/kibana/kibana-7.17.4-linux-x86_64.tar.gz + +# 解压 +tar -xvf elasticsearch-7.17.4-linux-x86_64.tar.gz +``` + +### 2.3、目录结构 + +|目录名称 | 描述 +|- | - +| bin | 可执行脚本文件 +| config | 配置文件 +|lib | 依赖库 +| data | 默认的数据存放目录,`生产环境必须修改` +|logs| 默认的日志文件存放目录,`生产环境必须修改` +| modules | 包含所有模块 +| plugins| 插件目录 +| jdk/jdk.app | version > 7.0,自带的java环境 + +### 2.4、启动单节点服务 + +```bash +# 进入到命令所在目录 +cd elasticsearch-7.14.0\bin + +# 启动 +./elasticsearch + +# 后台启动 +./elasticsearch -d +``` + +| - | windows | Linux | MacOS +| - | - | - | - | +| 命令行 | ./elasticsearch.bash | ./elasticsearch | ./elasticsearch +| 图形界面 | 双击 elasticsearch.bash | - | 双击 elasticsearch +| shell | start elasticsearch.bash | - | open elasticsearch + +启动验证:http://localhost:9200 + +### 2.5、启动多个节点 + +1、本机单个项目启动多个节点 + +```bash +# 启动第一个节点 http://localhost:9200/ +./elasticsearch -E path.data=data1 -E path.logs=log1 -E node.name=node1 -E cluster.name=mycluster + +# 启动第二个节点 http://127.0.0.1:9201/ +./elasticsearch -E path.data=data2 -E path.logs=log2 -E node.name=node2 -E cluster.name=mycluster +``` + +2、本机多个项目启动多个节点 + +MacOS +```bash +open node1/bin/elasticsearch +open node2/bin/elasticsearch +open node3/bin/elasticsearch +``` + +windows +```bash +start D:\node1\bin\elasticsearch.bat +start D:\node2\bin\elasticsearch.bat +start D:\node3\bin\elasticsearch.bat +``` + +## 3、安装Kibana +## 4、安装ElasticSearch-Head插件 + +## 5、不同编程语言的客户端 + +https://www.elastic.co/guide/en/elasticsearch/client/index.html + +```bash +# php > 7.1 +composer require "elasticsearch/elasticsearch" "~7.0" +``` + +文档: +https://www.elastic.co/guide/en/elasticsearch/client/php-api/7.17/index.html + + +## 配置Nginx代理转发 + +```bash +# kibana.conf +server { + listen 8002; + server_name localhost; + + location / { + # 设置 auth + auth_basic "login auth"; + auth_basic_user_file /usr/local/nginx/.htpasswd; + + proxy_pass http://127.0.0.1:5601; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} + +``` + +```bash +# elasticsearch.conf +server { + listen 8001; + server_name localhost; + + location / { + # 设置 auth + auth_basic "login auth"; + auth_basic_user_file /usr/local/nginx/.htpasswd; + + proxy_pass http://127.0.0.1:9200; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} +``` + +https://www.bilibili.com/video/BV1LY4y167n5?p=3&spm_id_from=pageDriver + diff --git a/blog/php-mysql/index.md b/blog/php-mysql/index.md index 7d704ecfa121863f5e0e74046dc8bf45e49a782b..bc2d905f22e6d8355af6081ef6f2e752c931233a 100644 --- a/blog/php-mysql/index.md +++ b/blog/php-mysql/index.md @@ -44,13 +44,13 @@ 21. [连接查询 join](blog/php-mysql/sql-join.md) -[子查询 sub query](blog/php-mysql/sql-subquery.md) +22. [子查询 sub query](blog/php-mysql/sql-subquery.md) -[数据库备份与还原](blog/php-mysql/sql-bak.md) +23. [数据库备份与还原](blog/php-mysql/sql-bak.md) -[用户权限管理](blog/php-mysql/sql-power.md) +24. [用户权限管理](blog/php-mysql/sql-power.md) -[外键 foreing key](blog/php-mysql/sql-foreing-key.md) +25. [外键 foreing key](blog/php-mysql/sql-foreing-key.md) [视图 view](blog/php-mysql/sql-view.md) diff --git a/doc/elasticsearch.md b/doc/elasticsearch.md deleted file mode 100644 index 57696dacd2c842269a2469e9eb819e315363da42..0000000000000000000000000000000000000000 --- a/doc/elasticsearch.md +++ /dev/null @@ -1,96 +0,0 @@ - -elasticsearch下载地址 - -- 官网下载:[https://www.elastic.co/cn/downloads/past-releases#elasticsearch](https://www.elastic.co/cn/downloads/past-releases#elasticsearch) - -- elasticsearch中文社区:[https://elasticsearch.cn/download/](https://elasticsearch.cn/download/) - -- 华为云镜像:[https://repo.huaweicloud.com/elasticsearch/](https://repo.huaweicloud.com/elasticsearch/) - -下载解压安装 - -```bash -# elasticsearch -wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.4-linux-x86_64.tar.gz - -# kibana -wget https://artifacts.elastic.co/downloads/kibana/kibana-7.17.4-linux-x86_64.tar.gz - -# 解压 -tar -xvf elasticsearch-7.17.4-linux-x86_64.tar.gz - -# 运行 -cd elasticsearch-7.17.4/bin -./elasticsearch -``` - -安装JDK -```bash -# 搜索jdk -yum search jdk - -# 安装 -yum install -y java-1.8.0-openjdk.x86_64 - -# 验证 -java -version -openjdk version "1.8.0_332" -OpenJDK Runtime Environment (build 1.8.0_332-b09) -OpenJDK 64-Bit Server VM (build 25.332-b09, mixed mode) -``` - -不同编程语言的客户端 -https://www.elastic.co/guide/en/elasticsearch/client/index.html - -```bash -# php > 7.1 -composer require "elasticsearch/elasticsearch" "~7.0" -``` - -文档: -https://www.elastic.co/guide/en/elasticsearch/client/php-api/7.17/index.html - - -配置Nginx代理转发 - -```bash -# kibana.conf -server { - listen 8002; - server_name localhost; - - location / { - # 设置 auth - auth_basic "login auth"; - auth_basic_user_file /usr/local/nginx/.htpasswd; - - proxy_pass http://127.0.0.1:5601; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } -} - -``` - -```bash -# elasticsearch.conf -server { - listen 8001; - server_name localhost; - - location / { - # 设置 auth - auth_basic "login auth"; - auth_basic_user_file /usr/local/nginx/.htpasswd; - - proxy_pass http://127.0.0.1:9200; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } -} -``` - -Elasticsearch7.6中文文档 - -- https://www.kancloud.cn/yiyanan/elasticsearch_7_6/1668540 -- https://learnku.com/docs/elasticsearch73/7.3 \ No newline at end of file diff --git a/doc/mysql.md b/doc/mysql.md index 37761e6e76a039d67603d45a96b5fa267bcc72a7..59b3e69697311cbf159f43b61f507ba6df418498 100644 --- a/doc/mysql.md +++ b/doc/mysql.md @@ -1,6 +1,8 @@ # MySQL +[笔记:PHP 零基础入门到精通教程(P2 mysql 数据库 5 天)](/blog/php-mysql/index.md) + [MySQL进阶笔记](blog/mysq-advance/index.md)