欢迎光临
我们一直在努力

win11下本地部署单节点Elasticsearch9.0+开发

环境准备

确保系统满足以下条件:

  • Windows 11 64位系统
  • JDK 17或更高版本(Elasticsearch 9.x依赖JDK 17+)
  • 至少4GB可用内存(推荐8GB以上)

验证JDK版本:

java -version

若未安装JDK,可从Oracle官网或Adoptium下载。


下载Elasticsearch

从官方下载页获取ZIP包(选择Windows版本)。解压到无空格和特殊字符的路径(如C:\\elasticsearch-9.x.x)。


配置Elasticsearch

编辑config/elasticsearch.yml文件,调整关键参数:

cluster.name: my-elasticsearch
node.name: single-node
network.host: 0.0.0.0
discovery.type: single-node
xpack.security.enabled: false # 开发环境可关闭安全认证

内存调整(可选): 修改config/jvm.options,根据机器配置调整堆大小:

-Xms2g
-Xmx2g


启动Elasticsearch

通过PowerShell进入解压目录,运行:

.\\bin\\elasticsearch.bat

若成功启动,日志会显示started字样,默认端口9200。访问http://localhost:9200验证服务状态。


安装IK分词器(可选)

适用于中文分词:

  • 下载与版本匹配的IK插件(如elasticsearch-analysis-ik)。
  • 解压到plugins/ik目录。
  • 重启Elasticsearch生效。

  • 常见问题解决

    端口冲突: 修改elasticsearch.yml中的http.port或关闭占用端口的程序。

    启动报错:

    • 检查JDK版本是否符合要求。
    • 确保系统环境变量JAVA_HOME指向JDK 17+路径。

    内存不足: 调整jvm.options中的-Xms和-Xmx为更低值(如1g)。


    开发工具集成

    • Kibana:下载对应版本,解压后运行kibana.bat,访问http://localhost:5601。
    • Postman:直接调用REST API(如GET /_cluster/health)。

    数据操作示例

    创建索引并插入文档:

    PUT /test_index
    {
    "mappings": {
    "properties": {
    "title": { "type": "text" },
    "count": { "type": "integer" }
    }
    }
    }

    POST /test_index/_doc/1
    {
    "title": "Elasticsearch入门",
    "count": 100
    }

    赞(0)
    未经允许不得转载:171主机测评 » win11下本地部署单节点Elasticsearch9.0+开发
    分享到: 更多 (0)

    评论 抢沙发

    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址