当前位置: 首页 > news >正文

Win10部署ElasticSearch、Logstash、Kibana

一、本地部署 ElasticSearch

1、下载 Elasticsearch 安装包

点此下载 Elasticsearch

2、解压到指定目录

3、win+R 输入 cmd,进入 Elasticsearch 安装目录运行 .bat 文件

4、浏览器输入 https://localhost:9200 ,并进行身份验证

在 Elasticsearch 的 bin 目录下运行下列命令获取密码。

elasticsearch-reset-password -u elastic

出现图中内容即安装成功。

5、添加IK分词器

ik分词器下载地址打开下载

将下载的压缩文件复制到plugins目录下ik解压缩

重启ES服务

CMD中运行下面命令进行测试是否安装成功

curl -X POST "localhost:9200/_analyze" -H "Content-Type: application/json" -d "{\"analyzer\": \"ik_max_word\", \"text\": \"我爱北京天安门\"}"

如下图是成功安装

二、部署Kibana 

1、下载 Kibana 安装包

点此下载 Kibana ,版本要与 Elasticsearch 版本一致

2、在 Kibana 安装路径下的 bin 目录,双击运行 .bat 文件

3、出现链接即安装成功,并在浏览器访问

4、首次登陆需获取 token 令牌,在 Elasticsearch 的 bin 目录下运行下列命令即可

elasticsearch-create-enrollment-token --scope kibana

5、登录的密码与 Elasticsearch 的登陆密码一致

若忘记可通过继续执行下列命令更改密码

elasticsearch-reset-password -u elastic

默认用户名为 elastic ,输入刚更改的密码即可登录工作界面

6、修改为中文界面

config目录下的kibana.yml文件

搜索到i18n.locale,将其改为

i18n.locale: "zh-CN"

重启即可

7、登陆后可在编辑个人资料中重新自定义密码

三、安装Logstash

1、下载链接:Past Releases of Elastic Stack Software | Elastic

四、SpringBoot整合ES7.1.12

1、项目结构

ElasticSearch/
├── .gitattributes                # Git 属性配置文件
├── .gitignore                    # Git 忽略文件配置
├── .mvn/                         # Maven 包装器目录
│   └── wrapper/
│       └── maven-wrapper.properties  # Maven 包装器属性
├── mvnw                          # Maven 包装器脚本 (Unix)
├── mvnw.cmd                      # Maven 包装器脚本 (Windows)
├── pom.xml                       # Maven 项目对象模型文件
└── src/                          # 源代码目录├── main/                     # 主要源代码│   ├── java/                 # Java 源代码│   │   └── com/│   │       └── elasticsearch/  # 基础包│   │           ├── ElasticSearchApplication.java  # 应用程序入口│   │           └── config/   # 配置类目录│   │               └── ElasticSearchClientConfig.java  # ES 客户端配置│   └── resources/            # 资源文件目录│       └── application.yml   # 应用程序配置文件└── test/                     # 测试源代码└── java/                 # Java 测试源代码└── com/└── elasticsearch/└── service/  # 服务测试目录(当前为空)

2、pom文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><!-- 项目模型版本(固定为4.0.0) --><modelVersion>4.0.0</modelVersion><!-- 继承 Spring Boot 官方父项目,用于依赖管理和默认配置 --><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.5.6</version><relativePath/> <!-- 不从本地查找父POM,直接从仓库下载 --></parent><!-- 项目基本信息 --><groupId>com</groupId><artifactId>ElasticSearch</artifactId><version>0.0.1-SNAPSHOT</version><name>ElasticSearch</name><description>基于 Spring Boot 的 Elasticsearch 操作示例项目</description><url/><licenses><license/></licenses><developers><developer/></developers><scm><connection/><developerConnection/><tag/><url/></scm><!-- 项目属性 --><properties><java.version>8</java.version> <!-- 使用 JDK 1.8 编译 --><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding></properties><!-- 项目依赖 --><dependencies><!-- Spring Boot 核心依赖 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!-- Spring Data Elasticsearch 支持(用于连接和操作 ES) --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-elasticsearch</artifactId></dependency><!-- Lombok:简化 Java Bean 写法(如 @Data、@Getter 等注解) --><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional> <!-- 仅编译期使用,不打包进最终 jar --></dependency><!-- Jackson:JSON 序列化与反序列化支持 --><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId></dependency><!-- Spring Boot 测试支持 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><!-- JUnit Jupiter API(JUnit 5) --><dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter-api</artifactId><scope>test</scope></dependency></dependencies><!-- 构建配置 --><build><plugins><!-- Maven 编译插件:配置 Java 8 编译及 Lombok 注解处理器 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>8</source><target>8</target><!-- 启用 Lombok 注解处理器 --><annotationProcessorPaths><path><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></path></annotationProcessorPaths></configuration></plugin><!-- Spring Boot Maven 插件:用于打包可执行 jar 文件 --><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><excludes><!-- 打包时排除 Lombok,避免重复包含 --><exclude><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></exclude></excludes></configuration></plugin></plugins></build></project>

3、配置类

application.yml文件
spring:application:name: ElasticSearchelasticsearch:rest:uris: http://localhost:9200

配置类

package com.elasticsearch.config;import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class ElasticSearchClientConfig {@Value("${spring.elasticsearch.rest.uris}")private String urls;@Beanpublic RestHighLevelClient restHighLevelClient() {RestHighLevelClient restHighLevelClient = new RestHighLevelClient(RestClient.builder(new HttpHost("localhost",9200, "http")));return restHighLevelClient;}
}

http://www.dtcms.com/a/348125.html

相关文章:

  • wpf之Grid控件
  • 图像均衡化详解:从直方图均衡到 CLAHE,让图片告别 “灰蒙蒙“
  • 征程 6X 常用工具介绍
  • 第16届蓝桥杯C++中高级选拔赛(STEMA)2024年12月22日真题
  • elasticsearch 7.x elasticsearch 使用scroll滚动查询中超时问题案例
  • 【C#】构造函数实用场景总结
  • PostgreSQL interval 转换为 int4 (整数)
  • Flink SQL执行SQL错误排查
  • 结构化智能编程:用树形向量存储重构AI代码理解范式
  • RAGFlow (二)小试牛刀:登陆页重构
  • 《链路状态路由协议OSPF》
  • 前端工程师面试题-vue
  • 记一次生产环境Hbase填坑之路、Hbase客户端登陆、kerberos认证、端口列表、Pod上手撕代码【Hbase最佳实践】
  • 【CV】OpenCV①——OpenCV常用模块
  • 使用 Fargate 在 AWS ECS 上运行 Spring Boot 应用程序
  • 【C#】【WinForm】ListView_列表视图控件
  • [每周一更]-(第157期):深入理解Go语言的垃圾回收机制:调优与监控
  • BERT(Bidirectional Encoder Representations from Transformers)模型详解
  • 2.7 提示词调优编码实战(二)
  • 2025年8月第3周AI资讯
  • 将C++资源管理测试框架整合到GitLab CI/CD的完整实践指南
  • Ansible自动化配置
  • 手写MyBatis第31弹-用工厂模式重构MyBatis的SqlSession创建过程
  • 小迪安全v2023学习笔记(七十一讲)—— Python安全反序列化反编译格式化字符串安全
  • 深入解析MyBatis中#{}和${}的区别与应用场景
  • Implementing Redis in C++ : E(AVL树详解)
  • spring源码之事务篇(事务管理器整个流程)
  • 笔记 | Anaconda卸载重装
  • Hyperledger Fabric官方中文教程-改进笔记(十五)-从通道中删除组织
  • 【机器学习】3 Generative models for discrete data