栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

一、初识elasticsearch

一、初识elasticsearch

1. 什么是elasticsearch?

Elasticsearch (以下简称es)是一个分布式、可扩展、实时、RESTful 风格的搜索与数据分析引擎,它的底层是开源库Apache Lucene。es针对每个字段都可以被索引与搜索,能胜任上百个服务节点的扩展,并支持 PB 级别的结构化或者非结构化数据。es的倒排索引就是底层Lucene的倒排索引。当前最新版本是7.16.2,本篇文章以版本7.6.2作为说明及演示。

1.1 什么是倒排索引?

官网解释:倒排索引 | Elasticsearch: 权威指南 | Elastic

索引一般分为正向索引和反向索引,正向索引顾名思义,就是通过key找value,反向索引就是通过value来找key。

2. 搭建elasticsearch集群及启动

官方下载地址:Past Releases of Elastic Stack Software | Elastic

可以在上面选择所需要的版本,es6.X、es7.X、es8.X版本之间差别较大,高版本的部分功能已不在支持低版本。

在这里我们下载Elasticsearch 7.6.2 linux系统的tar包,

服务器ip:192.168.1.1,192.168.1.2,192.168.1.3

2.1 服务器192.168.1.1添加elasticsearch用户名

useradd elasticsearch

pass xxx

2.2 将tar包上传服务器/home/elasticsearch/

切换到该用户下解压至目录,检查服务器是否安装jdk8以上版本,此处忽略jdk安装步骤

tar -zxvf /home/elasticsearch/elasticsearch-7.6.2.tar.gz

2.3 修改配置文件

cd /home/elasticsearch/elasticsearch-7.6.2/config/

vi elasticsearch.yaml

按照如下内容进行修改及增加

cluster.name: es
node.name: node-1
path.data: /home/elasticsearch/elasticsearch-7.6.2/data
path.logs: /home/elasticsearch/elasticsearch-7.6.2/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
transport.tcp.port: 9300
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["192.168.1.1:9300","192.168.1.2:9300","192.168.1.3:9300"]
discovery.zen.minimum_master_nodes: 2
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

# es7.X版本单节点部署需要加此配置项

#discovery.type: single-node

保存退出

cd /home/elasticsearch/elasticsearch-7.6.2

mkdir data

mkdir logs

2.4 修改jvm参数

vi jvm.options

-Xms1g

-Xmx1g

根据主机实际情况修改,如主机内存有4G可以给个1G,或者2G

2.5 同步其他服务器

按照2.1-2.4的步骤修改及配置192.168.1.2和192.168.1.3

2.6 elasticsearch安全认证配置

./bin/elasticsearch-certutil ca

This tool assists you in the generation of X.509 certificates and certificate
signing requests for use with SSL/TLS in the Elastic stack.

The 'ca' mode generates a new 'certificate authority'
This will create a new X.509 certificate and private key that can be used
to sign certificate when running in 'cert' mode.

Use the 'ca-dn' option if you wish to configure the 'distinguished name'
of the certificate authority

By default the 'ca' mode produces a single PKCS#12 output file which holds:
    * The CA certificate
    * The CA's private key

If you elect to generate PEM format certificates (the -pem option), then the output will
be a zip file containing individual files for the CA certificate and private key

Please enter the desired output file [elastic-stack-ca.p12]: 【不用管,直接回车】
Enter password for elastic-stack-ca.p12 : 【输入密码】

./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12

拷贝证书相关文件到其他ES节点,所有ES节点都需要拷贝

创建证书存放目录,与配置文件中的xpack.security.transport.ssl.keystore.path能对应上

2.7 启动服务

每台主机都操作

nohup /home/elasticsearch/elasticsearch-7.6.2/bin/elasticsearch &

查看是否启动成功

浏览器访问:http://192.168.1.1:9200

                     http://192.168.1.2:9200

                     http://192.168.1.3:9200

用户名:elastic

输入刚才设置的密码 

效果如下:

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/688239.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号