elasticsearch在windows上的安装步骤

2021-07-12 10:27:52 浏览数 (1)

官网:https://www.elastic.co/cn/downloads/elasticsearch下载对应版本

(图片来自:https://www.elastic.co/cn/downloads/elasticsearch)

运行bin文件夹下的elasticsearch.bat批处理文件:

浏览器访问 localhost:9200,如下:

代码语言:javascript复制
{
  "name" : "WIN-****",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "i1HpgzPGSwe_TJlpOT3Orw",
  "version" : {
    "number" : "7.13.2",
    "build_flavor" : "default",
    "build_type" : "zip",
    "build_hash" : "4d960a0733be83dd2543ca018aa4ddc42e956800",
    "build_date" : "2021-06-10T21:01:55.251515791Z",
    "build_snapshot" : false,
    "lucene_version" : "8.8.2",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

至此,elasticsearch启动。

4.安装`elasticsearch-head`:https://github.com/mobz/elasticsearch-head

(图片来自:https://github.com/mobz/elasticsearch-head)

运行方法如下:

(图片来自:https://github.com/mobz/elasticsearch-head#readme)

执行命令 npm run start 如下:

启动后,用ip:9200连接服务器端部署的elasticsearch,发现连接不上

查看logs/elasticsearch.log文件,如下:

代码语言:javascript复制
java.net.UnknownHostException: 不知道这样的主机。(host1)
  at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) ~[?:?]
  at java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:932) ~[?:?]
  at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1517) ~[?:?]
  at java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:851) ~[?:?]
  at java.net.InetAddress.getAllByName0(InetAddress.java:1507) ~[?:?]
  at java.net.InetAddress.getAllByName(InetAddress.java:1366) ~[?:?]
  at java.net.InetAddress.getAllByName(InetAddress.java:1300) ~[?:?]
  at org.elasticsearch.transport.TcpTransport.parse(TcpTransport.java:546) ~[elasticsearch-7.13.2.jar:7.13.2]
  at org.elasticsearch.transport.TcpTransport.addressesFromString(TcpTransport.java:488) ~[elasticsearch-7.13.2.jar:7.13.2]
  at org.elasticsearch.transport.TransportService.addressesFromString(TransportService.java:962) ~[elasticsearch-7.13.2.jar:7.13.2]
  at org.elasticsearch.discovery.SeedHostsResolver.lambda$resolveHostsLists$0(SeedHostsResolver.java:133) ~[elasticsearch-7.13.2.jar:7.13.2]
  at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
  at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:673) ~[elasticsearch-7.13.2.jar:7.13.2]
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) [?:?]
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) [?:?]
  at java.lang.Thread.run(Thread.java:831) [?:?]

修改elasticsearch配置文件,如下:

代码语言:javascript复制
network.host: 192.168.*.*
discovery.seed_hosts: ["host1"]
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: "X-Requested-With, Content-Type, Content-Length, X-User"

修改hosts文件,如下:

修改host文件后,再次重新启动,又出现如下情况,提示如下内容后,中止了:

代码语言:javascript复制
recoverd indices into cluster_state

但是这并不影响运行。

接下来elasticsearch-head可能还提示“集群健康值显示 未连接”,再修改elasticsearch-head中的Gruntfile.js,如下:

到这一步elasticsearch基本的步骤就算完成。

0 人点赞