Elasticsearch_1 搭建

介绍

Elasticsearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java语言开发的,并作为Apache许可条款下的开放源码发布,是一种流行的企业级搜索引擎。Elasticsearch用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。官方客户端在Java、.NET(C#)、PHP、Python、Apache Groovy、Ruby和许多其他语言中都是可用的。根据DB-Engines的排名显示,Elasticsearch是最受欢迎的企业搜索引擎,其次是Apache Solr,也是基于Lucene。

正向索引

我爱我的祖国,我爱编程

我 爱 爱我 祖国 我的祖国 编程 爱编程 我爱编程

反向索引

我 html1,html2
爱 html1,html2
祖国 html1

KIBANA 可视化界面

用于查看 ELASTICSEARCH

LOGSTASH 集中转化和存储数据

将其他数据导入 LOGSTASH
LOGSTASH 导入 ES

input 数据收集
filter 数据加工 过滤 改写
output 数据输出


搭建es

下载 ES

https://www.elastic.co/cn/downloads/?elektra=home&storm=hero

创建es用户组及es用户:
groupadd es
useradd es -g es
passwd es

更改es文件夹及内部文件的所属用户及组为es:es(在elasticsearch根目录执行此命令)
chown -R es:es elasticsearch

简单优化下 linux

vim /etc/sysctl.conf

fs.file-max=655360
vm.max_map_count=262144

vim /etc/security/limits.conf

* soft nproc 20480
* hand nproc 20480
* soft nofile 65536
* hard nofile 65536
* sort memlock unlimited
* hard memlock unlimited

简单优化下 jvm

vim config/jvm.options
-Xms 4g
-Xmx 4g
最大堆 最小堆

配置es

elasticsearch.yml

#集群名
cluster.name: my-elasticsearch 
#节点名
node.name: node3                                                                  #数据存放位置 可以不配 默认在运行目录data下
path.data: [/var/elastic/data]                                                    #数据存放位置 可以不配 默认在运行目录log下
path.logs: [/var/elastic/logs]

bootstrap.system_call_filter: false
bootstrap.memory_lock: false                                                     #本机ip
network.host: 10.0.0.56
#http端口
http.host: 10.0.0.56:9100
#数据传输端口
transport.bind_host: 192.168.1.3:9300                                           #集群ip地址 各个集群配置都是一样的
discovery.seed_hosts: ["10.0.0.56:9300","10.0.0.56:9301","10.0.0.56:9302"]
#集群启动 这个参数对于集群的可靠性来说,是非常重要的。这个设置可以预防脑裂问题,也就是一个集群中存在两个master。 master候选节点数量 / 2 + 1
discovery.zen.minimum_master_nodes: 2
#提供集群中符合主机要求的节点的列表 服务发现种子主机
cluster.initial_master_nodes: ["node1","node2","node3"]                          #能否成为master
node.master: true                                                               #是否存放数据
node.data: true                                                                 #跨域是否开启
http.cors.enabled : true                                                         #跨域允许那些域名
http.cors.allow-origin : "*"                                                     #最大初始化长度
http.max_initial_line_length: 12kb                                               #跨域是否支持操作session
http.cors.allow-credentials: true                                               #跨域允许的头部
http.cors.allow-headers: WWW-Authenticate,X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
#开启 xpack 功能,如果要禁止使用密码,请将以下内容注释,直接启动不需要设置密码
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

xpack 生成证书

集群版 只需要生成一次 再拷贝到其他es即可

开启xpack 需要 生成证书 直接回车别输入密码
bin/elasticsearch-certutil ca
bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12

移到目录下
mv elastic-certificates.p12 config/
mv elastic-stack-ca.p12 config/

/开启xpack 需要生成keystore /
/
bin/elasticsearch-keystore create
/

设置独立的密码
bin/elasticsearch-setup-passwords interactive 手动定义密码

es 初始化时的用户

Enter password for [elastic]: 
Reenter password for [elastic]: 
Enter password for [apm_system]: 
Reenter password for [apm_system]: 
Enter password for [kibana]: 
Reenter password for [kibana]: 
Enter password for [logstash_system]: 
Reenter password for [logstash_system]: 
Enter password for [beats_system]: 
Reenter password for [beats_system]: 
Enter password for [remote_monitoring_user]: 
Reenter password for [remote_monitoring_user]: 

启动elasticsearch

./bin/elasticsearch -q
./bin/elasticsearch #前台运行

其他节点

修改ip 数据端口

搭建集群 要将其他节点的data目录清空 等主节点同步

kibana可视化

kibana

server.port: 5601
server.host: "10.0.0.56"
elasticsearch.hosts: ["10.0.0.56:9300","10.0.0.56:9301","10.0.0.56:9302"]
elasticsearch.username: "elastic"
elasticsearch.password: "123456"
i18n.locale: "zh-CN"

启动

sudo nohup ./bin/kibana --allow-root

查看集群

http://ip/_cat/health?v
http://ip/_cat/nodes

posted @ 2021-03-30 10:02  gidos  阅读(92)  评论(0编辑  收藏  举报