1. 跨域

 elasticsearch-head连接es时会提示连接失败,有可能就是没有开启跨域

http.cors.enabled 是否支持跨域,默认为false
http.cors.allow-origin 当设置允许跨域,默认为*,表示支持所有域名,如果我们只是允许某些网站能访问,那么可以使用正则表达式。比如只允许本地地址。 /https?:\/\/localhost(:[0-9]+)?/
http.cors.max-age 浏览器发送一个“预检”OPTIONS请求,以确定CORS设置。最大年龄定义多久的结果应该缓存。默认为1728000(20天)
http.cors.allow-methods 允许跨域的请求方式,默认OPTIONS,HEAD,GET,POST,PUT,DELETE
http.cors.allow-headers 跨域允许设置的头信息,默认为X-Requested-With,Content-Type,Content-Length
http.cors.allow-credentials 是否返回设置的跨域Access-Control-Allow-Credentials头,如果设置为true,那么会返回给客户端。
  1. x-pack

x-pack监控作用 

功能

图形展示     xpack.graph.enabled       只使用于kibana组件
报表统计     pack.reporting.enabled   只使用于kibana组件
报警通知     xpack.watcher.enabled   只适用于elasticsearch组件
安全认证     xpack.security.enabled   适用于elk的三个组件
监控跟踪     xpack.monitoring.enabled    适用于elk的三个组件
设备资源分配   xpack.ml.enabled      适用于elasticsearch和kibana组件

  1. #设置 #描述
  2. xpack.graph.enabled #设置为false以禁用X-Pack图形功能。
  3. xpack.ml.enabled #设置为false以禁用X-Pack机器学习功能。
  4. xpack.monitoring.enabled #设置为false以禁用X-Pack监视功能。
  5. xpack.reporting.enabled #设置为false以禁用X-Pack报告功能。
  6. xpack.security.enabled #设置为false以禁用X-Pack安全功能。
  7. xpack.watcher.enabled #设置为false以禁用Watche
    http.cors.enabled 是否支持跨域,默认为false
    http.cors.allow-origin 当设置允许跨域,默认为*,表示支持所有域名,如果我们只是允许某些网站能访问,那么可以使用正则表达式。比如只允许本地地址。 /https?:\/\/localhost(:[0-9]+)?/
    http.cors.max-age 浏览器发送一个“预检”OPTIONS请求,以确定CORS设置。最大年龄定义多久的结果应该缓存。默认为172800020天)
    http.cors.allow-methods 允许跨域的请求方式,默认OPTIONS,HEAD,GET,POST,PUT,DELETE
    http.cors.allow-headers 跨域允许设置的头信息,默认为X-Requested-With,Content-Type,Content-Length
    http.cors.allow-credentials 是否返回设置的跨域Access-Control-Allow-Credentials头,如果设置为true,那么会返回给客户端

node.master: false 这样这个节点就不会成为master节点

监视 数据集合

这些xpack.monitoring.collection设置控制如何从Elasticsearch节点收集数据

xpack.monitoring.collection.enabled: true 启用

xpack.monitoring.collection.interval: 30s  间隔时间、

https://segmentfault.com/a/1190000016824141?utm_source=tag-newest

https://www.elastic.co/guide/en/elasticsearch/reference/6.3/monitoring-settings.html

开启ssl

xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

开启跨越

http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

开启监控

xpack.monitoring.enabled: true
xpack.monitoring.collection.enabled: true
xpack.monitoring.collection.interval: 30s

  1. # 配置X-Pack
  2. http.cors.enabled: true
  3. http.cors.allow-origin: "*"
  4. http.cors.allow-headers: Authorization,X-Requested-With,Content-Type,Content-Length
  5. xpack.security.enabled: true
  6. xpack.security.transport.ssl.enabled: true
  1. ES插件

官网下载安装包

https://www.elastic.co/cn/

然后安装jdk  node.js环境

https://www.cnblogs.com/wudequn/p/11147869.html

https://www.cnblogs.com/wudequn/p/11072561.html

官方文档

https://www.elastic.co/cn/blog/security-for-elasticsearch-is-now-free

https://www.elastic.co/guide/cn/index.html

https://discuss.elastic.co

https://github.com/elastic

一、IK分词

https://github.com/medcl/elasticsearch-analysis-ik/releases

下载后,加压,文件夹重命名  ik,放在plugins目录下。重启es

查看es安装的插件 http://192.168.31.102:9200/_cat/plugins

  1. 安装ES 7.1.*

 一、修改配置文件

配置文档

https://www.elastic.co/guide/en/elasticsearch/reference/7.x/important-settings.html

https://www.cnblogs.com/wudequn/p/12933855.html

https://www.cnblogs.com/wudequn/p/12944822.html

  1. network.host: 0.0.0.0
  2. http.port: 9200
  3. discovery.seed_hosts: ["node1"] 集群发现:配置该节点会与哪些候选地址进行通信,hostname,ip ,ip+port
  4. cluster.initial_master_nodes: ["node-1"] master节点:手动指定可以成为 mater 的所有节点的 name 或者 ip,这些配置将会在第一次选举中进行计算
    这几个要一起配置,不然报错(可以看错误日志)

主节点配置

  1. # 配置X-Pack
  2. http.cors.enabled: true
  3. http.cors.allow-origin: "*"
  4. http.cors.allow-headers: Authorization,X-Requested-With,Content-Type,Content-Length
  5. xpack.security.enabled: true
  6. xpack.security.transport.ssl.enabled: true
  7.  
  8. 子节点配置

打开另一个新的ES节点的目录 我的是下图中的 node,这是master的一个副本,只是文件夹名不一样(子节点不用设置密码了,主节点设置了)

修改node的config/elasticsearch.yml
除了和master相同的安全配置之外,还要添加
node.master: false 这样这个节点就不会成为master节点

  1. xpack.security.enabled: true
  2. xpack.security.transport.ssl.enabled: true
  3. xpack.security.transport.ssl.verification_mode: certificate
  4. xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
  5. xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
  6. #此节点不会成为主节点
  7. node.master: false

二、安装证书

在bin下执行 elasticsearch-certutil cert -out config/elastic-certificates.p12 -pass ""

三、安装ES服务

(安装方法1)控制台启动ES  或者通过下面的服务启动ES

(安装方法2)或者安装ES服务

elasticsearch-service.bat后面还可以执行这些命令 
install: 安装Elasticsearch服务 
remove: 删除已安装的Elasticsearch服务(如果启动则停止服务) 
start: 启动Elasticsearch服务(如果已安装) 
stop: 停止服务(如果启动) 
manager:启动GUI来管理已安装的服务

或者通过nssm

四、生成密码

bin下执行elasticsearch-setup-passwords auto

密码将随机生成并打印到控制台 按下 y 确认

密码手动生成(推荐)

elasticsearch-setup-passwords interactive

这个命令可以是手动设置密码

用户等等

  • elastic 账号:拥有 superuser 角色,是内置的超级用户。
  • kibana 账号:拥有 kibana_system 角色,用户 kibana 用来连接 elasticsearch 并与之通信。Kibana 服务器以该用户身份提交请求以访问集群监视 API 和 .kibana 索引。不能访问 index。
  • logstash_system 账号:拥有 logstash_system 角色。用户 Logstash 在 Elasticsearch 中存储监控信息时使用

修改密码

  1. curl -H "Content-Type:application/json" -XPOST -u elastic 'http://127.0.0.1:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'
  2.  
  3. curl -XPUT -u elastic 'http://localhost:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "yourpasswd" }'

五、测试

打开时候需要输入账号密码  就是前面自动生成的账号密码。

如果服务没有起来就查看错误日志。

六、安装es-head

alsticsearch只是后端提供各种API,那么怎么直观的使用它呢?Elasticsearch-head将是一款专门针对于Elasticsearch的客户端工具(客户端最好使用kibana)

Elasticsearch-head安装包,下载地址:https://github.com/mobz/elasticsearch-head

修改es-head目录下面的Gruntfile.js文件,添加hostname:’*'

1、首先要安装node.js:安装教程

2、cmd执行 npm install -g grunt-cli 安装grunt ,安装完成后执行grunt -version查看是否安装成功,会显示安装的版本号

3、在es-head目录下cmd执行  grunt server 或者npm run start 运行head插件

如果设置了es安全

则登录

http://localhost:9100/?auth_user=elastic&auth_password=caKBawShu0Pm7BsjSFbd

  1. 集群搭建

1、主节点

  1. # 集群名称
  2. cluster.name: "es_cluster"
  3.  
  4. # 节点名称,这儿我直接取名为 master
  5. node.name: master
  6. # 是否可以成为master节点
  7. node.master: true
  8. # 是否允许该节点存储数据,默认开启
  9. node.data: true
  10.  
  11. # 网络绑定,这里我绑定 0.0.0.0,支持外网访问
  12. network.host: 0.0.0.0
  13.  
  14. # 设置对外服务的http端口,默认为9200
  15. http.port:
  16.  
  17. # 支持跨域访问
  18. http.cors.enabled: true
  19. http.cors.allow-origin: "*"
  20.  
  21. # 设置节点间交互的tcp端口,默认是9300
  22. transport.tcp.port:
  23.  
  24. # 手动指定可以成为 mater 的所有节点的 name 或者 ip,这些配置将会在第一次选举中进行计算
  25. cluster.initial_master_nodes: ["127.0.0.1"]

2、从节点1

  1. # 集群名称,处于同一个集群所有节点,该名称必须相同
  2. cluster.name: "es_cluster"
  3.  
  4. # 节点名称,这儿我直接取名为 slave1
  5. node.name: slave1
  6. # 是否可以成为master节点
  7. node.master: false
  8. # 是否允许该节点存储数据,默认开启
  9. node.data: true
  10.  
  11. # 网络绑定,这里我绑定 0.0.0.0,支持外网访问
  12. network.host: 0.0.0.0
  13.  
  14. # 设置对外服务的http端口,默认为9200,这里我们修改为 ,不然会有端口冲突
  15. http.port:
  16.  
  17. # 支持跨域访问
  18. http.cors.enabled: true
  19. http.cors.allow-origin: "*"
  20.  
  21. # 集群发现 主节点中配过这个
  22. discovery.seed_hosts: ["127.0.0.1:9300"]

3、从节点2

  1. # 集群名称,处于同一个集群所有节点,该名称必须相同
  2. cluster.name: "es_cluster"
  3.  
  4. # 节点名称,这儿我直接取名为 slave2
  5. node.name: slave2
  6. # 是否可以成为master节点
  7. node.master: false
  8. # 是否允许该节点存储数据,默认开启
  9. node.data: true
  10.  
  11. # 网络绑定,这里我绑定 0.0.0.0,支持外网访问
  12. network.host: 0.0.0.0
  13.  
  14. # 设置对外服务的http端口,默认为9200,这里我们修改为 ,不然会有端口冲突
  15. http.port:
  16.  
  17. # 支持跨域访问
  18. http.cors.enabled: true
  19. http.cors.allow-origin: "*"
  20.  
  21. # 集群发现
  22. discovery.seed_hosts: ["127.0.0.1:9300"]

  1. 学习视频

https://www.elastic.co/cn/webinars/getting-started-elasticsearch?elektra=home&storm=sub1

https://blog.csdn.net/MicoMecy/article/details/90642163

https://www.jianshu.com/p/5e65e04b4b64

Elasticsearch配置安装的更多相关文章

  1. Elasticsearch环境安装配置

    安装Elasticsearch的步骤如下 - 第1步 - 查看安装在计算机上的java的最低版本,它要求java 7或以上或最新的版本.可以通过执行以下操作进行检查 - 在Windows操作系统(OS ...

  2. ElasticSearch搜索引擎安装配置拼音插件pinyin

    近几篇ElasticSearch系列: 1.阿里云服务器Linux系统安装配置ElasticSearch搜索引擎 2.Linux系统中ElasticSearch搜索引擎安装配置Head插件 3.Ela ...

  3. ElasticSearch搜索引擎安装配置中文分词器IK插件

    近几篇ElasticSearch系列: 1.阿里云服务器Linux系统安装配置ElasticSearch搜索引擎 2.Linux系统中ElasticSearch搜索引擎安装配置Head插件 3.Ela ...

  4. Linux系统中ElasticSearch搜索引擎安装配置Head插件

    近几篇ElasticSearch系列: 1.阿里云服务器Linux系统安装配置ElasticSearch搜索引擎 2.Linux系统中ElasticSearch搜索引擎安装配置Head插件 3.Ela ...

  5. elasticsearch kibana 安装 配置

    二.Elasticsearch  配置信息 2.1  因为 Elasticsearch 可以执行脚本文件,为了安全性,默认不允许通过 root 用户启动服务.我们需要新创建用户名和用户组启动服务 2. ...

  6. Elasticsearch单机安装_集群搭建_索引基本操作_Head插件安装与基本操作_ik分词器配置_logstash实现数据同步_教程

    一.Elasticsearch单机安装 1.将es安装包传到服务器上 这是安装包 这里我是用的是WinSCP上传工具,上传到/home/plugins文件下. 进入Xshell,验证一下是否上传成功. ...

  7. 如何在Elasticsearch中安装中文分词器(IK+pinyin)

    如果直接使用Elasticsearch的朋友在处理中文内容的搜索时,肯定会遇到很尴尬的问题--中文词语被分成了一个一个的汉字,当用Kibana作图的时候,按照term来分组,结果一个汉字被分成了一组. ...

  8. Elasticsearch配置详解、文档元数据

    目录 返回目录:http://www.cnblogs.com/hanyinglong/p/5464604.html 1.Elasticsearch配置文件详解 a. 在上面博客中,我们已经安装并且成功 ...

  9. Linux初学 - Elasticsearch环境安装

    下载 https://www.elastic.co/downloads/elasticsearch 安装 rpm -ivh 也可以双击rpm包安装 修改elastaticsearch host配置 修 ...

随机推荐

  1. Python字符串转十六进制进制互转

    def str_to_hex(s): return ' '.join([hex(ord(c)).replace('0x', '') for c in s]) def hex_to_str(s): ) ...

  2. C++2.0新特性(一)——<特性认知、__cplusplus宏开启、Variadic Templates 、左右值区分>

    一.新特性介绍 2.0新特性包含了C++11和C++14的部分 1.2 启用测试c++11功能 C++ 标准特定版本的支持,/Zc:__cplusplus 编译器选项启用 __cplusplus 预处 ...

  3. web容量规划

    容量和性能   容量规划是基于当前性能判断系统需要什么及什么时候需要,它既是资本支出合理化证明过程也是一个技术变更;   性能调优是优化已存在的系统性能;   一般服务的升级步骤是:性能调优 -> ...

  4. <c:choose>

    备注一下属性 DIV没有VALUE属性     <c:choose> <c:when test="${yggModel.type=='0'}">食品< ...

  5. Nginx介绍和使用

    Nginx介绍和使用 一.介绍 Nginx是一个十分轻量级并且高性能HTTP和反向代理服务器,同样也是一个IMAP/POP3/SMTP代理服务器. 二.特性 HTTP服务器 反向代理服务器 简单的负载 ...

  6. vue后台管理系统兼容问题

    1.兼容 兼容问题主要是指ie9以下的ie浏览器. 2.兼容问题原因 (1)低版本ie不支持编译后的es5 (2)低版本ie不支持Promise 3.解决方法 (1)引入es6-promise &am ...

  7. SQLite与MySQL区别

    原文链接:https://blog.csdn.net/zbw1185/article/details/47975965简单来说,SQLITE功能简约,小型化,追求最大磁盘效率:MYSQL功能全面,综合 ...

  8. 【转】自动化框架中引入ExtentReport美化报告

    本文链接:https://blog.csdn.net/qq_30353203/article/details/82023922一.先引入三个依赖包 <dependency> <gro ...

  9. SpringBoot整合Quartz和H2的例子

    话不多说,直接上代码: pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xml ...

  10. colock

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...