前言
最近也是在写关于一个数据分析的项目,感觉只使用mysql和JavaList操作解决不了想要的数据问题,所以也是入手学习了elasticsearch,安装与配置过程中也是有一些需要注意的点,这里分享给大家。
我们需要下载一共四个东西,这里由于ElasticSearch的ik分词器只有8.2.0版本,所以我们都以windows版,8.2.0版本为例。
elasticsearch-8.2.0-windows-x86_64.zip
elasticsearch-head-master可视化工具
kibana-8.2.0-windows-x86_64.zip
elasticsearch-analysis-ik-8.2.0.zip
下面我们先介绍elasticsearch的安装教程,之后的教程放到后面的文章中。
一、下载与安装
我们只需要点击上面的官网链接,选择自己所需要的版本下载即可。
下载好之后就是一个zip的压缩文件,我们选择好安装目录之后直接解压即可,开箱即用。
解压后的目录如下:
安装Java(7.X以上的版本可以忽略,此文为8.4.3,所以不需要单独安装了,jdk目录里已经集成了)
我们直接进入bin目录下,找到elasticsearch.bat批处理文件,点击直接运行即可。(右键管理员吧)
运行后,控制台输出日志,下面就是我们elasticsearch的账号密码。
elaasticsearch的默认访问路径是localhost:9200,我们打开浏览器直接访问即可。如果访问不了也没关系,我们可以先修改配置文件之后再进行访问。
注意:8.4.3我测试的无法直接打开默认网址,需要先进行配置(原因是:ES8
默认开启了ssl
认证,导致无法访问9200
端口,elasticsearch.yml配置文件添加【xpack.security.enabled: false】即可)(https://zhuanlan.zhihu.com/p/504694531)
Elasticsearch在Windows下开启了安全认证,虽然started成功,但访问http://localhost:9200/失败(https://blog.csdn.net/zhangphil/article/details/124476717)
received plaintext traffic on an encrypted channel, closing connection Netty4TcpChannel
首先需要联网,程序启动会安装java的一些东西,有的文档提示安装失败也可以使用,这里没测试,还是联网吧
# ======================== Elasticsearch Configuration ========================= # # NOTE: Elasticsearch comes with reasonable defaults for most settings. # Before you set out to tweak and tune the configuration, make sure you # understand what are you trying to accomplish and the consequences. # # The primary way of configuring a node is via this file. This template lists # the most important settings you may want to configure for a production cluster. # # Please consult the documentation for further information on configuration options: # https://www.elastic.co/guide/en/elasticsearch/reference/index.html # # ---------------------------------- Cluster ----------------------------------- # # Use a descriptive name for your cluster: # #cluster.name: my-application # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # node.name: node-1 # # Add custom attributes to the node: # #node.attr.rack: r1 # # ----------------------------------- Paths ------------------------------------ # # Path to directory where to store the data (separate multiple locations by comma): # #path.data: /path/to/data # # Path to log files: # #path.logs: /path/to/logs # # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # #bootstrap.memory_lock: true # # Make sure that the heap size is set to about half the memory available # on the system and that the owner of the process is allowed to use this # limit. # # Elasticsearch performs poorly when the system is swapping the memory. # # ---------------------------------- Network ----------------------------------- # # By default Elasticsearch is only accessible on localhost. Set a different # address here to expose this node on the network: # network.host: 0.0.0.0 # xpack.security.enabled: false # By default Elasticsearch listens for HTTP traffic on the first free port it # finds starting at 9200. Set a specific HTTP port here: # #http.port: 9200 # # For more information, consult the network module documentation. # # --------------------------------- Discovery ---------------------------------- # # Pass an initial list of hosts to perform discovery when this node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # #discovery.seed_hosts: ["host1", "host2"] # # Bootstrap the cluster using an initial set of master-eligible nodes: # cluster.initial_master_nodes: ["node-1"] # # For more information, consult the discovery and cluster formation module documentation. # # --------------------------------- Readiness ---------------------------------- # # Enable an unauthenticated TCP readiness endpoint on localhost # #readiness.port: 9399 # # ---------------------------------- Various ----------------------------------- # # Allow wildcard deletion of indices: # #action.destructive_requires_name: false
红颜色部分是我后加的,注意开启远程访问需要设置【network.host: 0.0.0.0】写成IP地址我这里直接报错退出,错误代码
received plaintext traffic on an encrypted channel, closing connection Netty4TcpChannel
二、修改配置
1.修改elasticsearch.yml配置
# 换个集群的名字,免得跟别人的集群混在一起 cluster.name: el-m # 换个节点名字 node.name: el_node_m1 # 修改一下ES的监听地址,这样别的机器也可以访问,设置IP地址好像不行 network.host: 0.0.0.0 #设置对外服务的http端口,默认为9200 http.port: 9200 #设置索引数据的存储路径 path.data: F:/elasticsearch-8.2.0/data #换成自己的路径 #设置日志文件的存储路径 path.logs: F:/elasticsearch-8.2.0/logs #换成自己的路径 # 关闭http访问限制 xpack.security.enabled: false # 增加新的参数,head插件可以访问es,跨域访问一定要配置 http.cors.enabled: true http.cors.allow-origin: "*" #----------------------- BEGIN SECURITY AUTO CONFIGURATION ----------------------- # Enable security features #xpack.security.enabled: false xpack.security.enrollment.enabled: true # Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents xpack.security.http.ssl: enabled: false keystore.path: certs/http.p12 # Enable encryption and mutual authentication between cluster nodes xpack.security.transport.ssl: enabled: true verification_mode: certificate keystore.path: certs/transport.p12 truststore.path: certs/transport.p12 # Create a new cluster with the current node only # Additional nodes can still join the cluster later cluster.initial_master_nodes: ["el_node_m1"] #注意,这个要与node.name填写一致 #----------------------- END SECURITY AUTO CONFIGURATION -------------------------
2.重新启动服务
重新使用cmd进入elasticsearch目录进行启动。
启动后我的控制台是这样:
然后访问浏览器http://localhost:9200
出现这个就是安装和启动成功了。
还有可能的一个报错
Native controller process has stopped - no new native processes can be started
解决方法:
修改config文件夹下的elasticsearch.yml文件:
node.name: node-1
cluster.initial_master_nodes: ["node-1"]
修改之后保存,再次启动elasticsearch,就成功启动elasticsearch了。
还是配置的问题,前面交代过了。
原文链接:https://blog.csdn.net/z318913/article/details/125325662
也推荐阅读:windows环境基于Elasticsearch8.4.0的Head工具下载、安装、使用
windows环境基于Elasticsearch8.4.0的IK中文分词器的安装、部署、使用
大概意思就是不要用设置命令,直接用重置命令
./elasticsearch-reset-password
默认应该是第一次启动的时候会有默认的密码,但是我的没有看到,log中也没有
改配置了就无法启动,稍后研究
可以看这个文章:龙叔学ES:Elasticsearch XPACK安全认证
好像需要配置证书啥的
照这操作重置密码成功,接下来还是更改配置文件
#配置开启跨域 http.cors.enabled: true #配置允许任何域名访问 http.cors.allow-origin: "*" #设置密码后的访问配置 http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
重启ES
访问es-head的url要变动
- 原来是http://IP:9100
- 现在因为加密了,所以要做身份验证,格式:http://IP:9100/?auth_user=用户名&auth_password=密码
通过该url访问es-head,然后注正常填写es的地址即可
按链接文字一步步走就行,密码处全部回车就行,成功!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?