Elasticsearch 5.4.1 windows 10 测试服务搭建

来源:互联网 发布:淘宝手机海报尺寸2017 编辑:程序博客网 时间:2024/06/07 06:45

elasticsearch5.4.1 &Windows10

因为项目的需要所以去学习了近一周的elasticsearch5.4.1(以下简称es),我是自己在Windows10 自己跑了一个服务器。好了废话不多说直入主题!

、先去官网下载最新版es我下载的是5.4.1 地址[https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.1.zip]

、去配置elasticsearch-head-master(以下简称head)
这里有个坑就是新版的es不能在plugin里去直接安装head,需要自己去下载
下载地址[https://github.com/mobz/elasticsearch-head]clone到本地解压(注意别解压到es的文件夹里),现在的head是要靠grunt 来启动的 而grunt是依赖node.js这个时候就去下载最新版nodejs地址[https://nodejs.org/dist/v8.1.2/node-v8.1.2-x64.msi]
傻瓜式安装也不用去配置环境变量,他是全局安装的,这个时候win+r输入cmd进入cmd窗口然后进到安装的nodejs文件夹里(我都是以管理员去运行cmd可能存在权限问题)

C:\Windows\system32>cd ../C:\Windows>cd ../C:\>cd "Program Files"C:\Program Files>cd nodejsC:\Program Files\nodejs>npm install -g grunt-cli

只要安装grunt-cli ,-g全局安装,在进入elasticsearch-head-master文件夹,执行npm install 这里会报警告 因为被墙了 如果你有VPN那应该没有警告 这个时候去安装国内的镜像。

D:\>cd elasticsearch-head-masterD:\elasticsearch-head-master>npm install -g cnpm --registry=https://registry.npm.taobao.org

去elasticsearch-head-master文件夹修改Gruntfile.js
大概94行 加上hostname

connect: {            server: {                options: {                    port: 9100,                    hostname: '*',                    base: '.',                    keepalive: true                }            }        }

、修改elasticsearch.yml
直接进文件夹elastic5.4.1/config 用pad++打开elasticsearch.yml

# ======================== 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-applicationjoe## ------------------------------------ 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 -----------------------------------## Set the bind address to a specific IP (IPv4 or IPv6):#服务器的IPnetwork.host: 127.0.0.1 ## Set a custom port for HTTP:#端口http.port: 9200## For more information, consult the network module documentation.## --------------------------------- Discovery ----------------------------------## Pass an initial list of hosts to perform discovery when new node is started:# The default list of hosts is ["127.0.0.1", "[::1]"]##discovery.zen.ping.unicast.hosts: ["host1", "host2"]## Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):##discovery.zen.minimum_master_nodes: 3## For more information, consult the zen discovery module documentation.## ---------------------------------- Gateway -----------------------------------## Block initial recovery after a full cluster restart until N nodes are started:##gateway.recover_after_nodes: 3## For more information, consult the gateway module documentation.## ---------------------------------- Various -----------------------------------## Require explicit names when deleting indices:##action.destructive_requires_name: truehttp.cors.enabled: truehttp.cors.allow-origin: "*"

关键加上最后两句
http.cors.enabled: true
http.cors.allow-origin: “*”
别的都是修改
好了基本配置都已经完毕了。

、要明白head和elasticsearch他们是分开启动的

去cmd 切换至elasticsearch-head-master目录 关键点来了:网上多说在这里输入命令grunt server 去启动grunt 也就是运行head 这里要是你人品好 有概率启动的。为这一点博主真的是头疼了大半天 最后在head的API里发现 用*npm run start才能启动 官方文档还是强大啊,*

**D:\>cd elasticsearch-head-masterD:\elasticsearch-head-master>npm run start> elasticsearch-head@0.0.0 start D:\elasticsearch-head-master> grunt serverRunning "connect:server" (connect) taskWaiting forever...Started connect web server on http://localhost:9100**

启动之后就可以在浏览器输入http://localhost:9100
这里写图片描述
你就可以愉快的简单利用head去和es交互了
如果你grunt server的话 可能会说找不到grunt 很坑 当时博主 被坑了很久 因为真的有概率 能运行!博主也是个新手大家如果有什么问题 尽管留言提问,后面会给大家配置ik分词器,还会去写有关Java api的调用。谢谢阅读!
思于办公室桌前~

原创粉丝点击