随笔 - 59,  文章 - 1,  评论 - 0,  阅读 - 24152

ElasticSearch 下载后可以将其注册为Windows服务,具体可以参考官方说明:https://www.elastic.co/guide/en/elasticsearch/reference/8.6/zip-windows.html#install-windows

1. 注册服务

切换到elasticsearch目录,执行elasticsearch-service.bat install

cd elasticsearch-7.17.7
./bin/elasticsearch-service.bat install

安装成功将打印如下日志:

Installing service : "elasticsearch-service-x64"
Using ES_JAVA_HOME (64-bit): "F:\server\elasticsearch-7.17.7\jdk"
-Des.networkaddress.cache.ttl=60;-Des.networkaddress.cache.negative.ttl=10;-XX:+AlwaysPreTouch;-Xss1m;-Djava.awt.headless=true;-Dfile.encoding=UTF-8;-Djna.nosys=true;-XX:-OmitStackTraceInFastThrow;-XX:+ShowCodeDetailsInExceptionMessages;-Dio.netty.noUnsafe=true;-Dio.netty.noKeySetOptimization=true;-Dio.netty.recycler.maxCapacityPerThread=0;-Dio.netty.allocator.numDirectArenas=0;-Dlog4j.shutdownHookEnabled=false;-Dlog4j2.disable.jmx=true;-Dlog4j2.formatMsgNoLookups=true;-Djava.locale.providers=SPI,COMPAT;--add-opens=java.base/java.io=ALL-UNNAMED;-Djava.security.manager=allow;-XX:+UseG1GC;-Djava.io.tmpdir=C:\Users\michong\AppData\Local\Temp\elasticsearch;-XX:+HeapDumpOnOutOfMemoryError;-XX:+ExitOnOutOfMemoryError;-XX:HeapDumpPath=data;-XX:ErrorFile=logs/hs_err_pid%p.log;-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m;-Xms8133m;-Xmx8133m;-XX:MaxDirectMemorySize=4265607168;-XX:G1HeapRegionSize=4m;-XX:InitiatingHeapOccupancyPercent=30;-XX:G1ReservePercent=15
The service 'elasticsearch-service-x64' has been installed.

默认分配的是8G内存,如果内存不够的话,可以通过调整config/jvm.options,重新安装ElasticSearch服务:

cd elasticsearch-7.17.7
./bin/elasticsearch-service.bat remove
./bin/elasticsearch-service.bat install

2. 启动服务

win+R运行services.msc,找到elasticsearch-service-x64,启动ElasticSearch服务,稍等片刻,访问 http://localhost:9200/

3. Head插件

在GitHub中下载ElasticSearch-Head,地址:https://github.com/mobz/elasticsearch-head/releases/tag/v5.0.0

解压,安装依赖(需要安装nodejs):

cd elasticsearch-7.17.7\elasticsearch-head-5.0.0
npm install --registry=https://registry.npm.taobao.org

运行(需要开启跨域支持,4.有具体的说明):

npm run start

4. 开启跨域

有关HTTP的配置可以查看这里的官方说明: https://www.elastic.co/guide/en/elasticsearch/reference/7.17/modules-network.html

在elasticsearch.yml新增如下配置:

http.cors.enabled: true
http.cors.allow-origin: /https?:\/\/localhost(:[0-9]+)?/

这里的http.cors.allow-origin也可以配置成*,修改配置后重启ElasticSearch服务。

5. 访问Head

用下面的方式启动Head插件后,可以通过 http://localhost:9100 访问。

npm run start

页面效果:

posted on   $$X$$  阅读(215)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)

点击右上角即可分享
微信分享提示