前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Elastic 8.0 二进制单机部署ELKF 四件套(欧拉系统)

Elastic 8.0 二进制单机部署ELKF 四件套(欧拉系统)

作者头像
Kevin song
发布2023-02-22 21:41:57
7310
发布2023-02-22 21:41:57
举报

Elasticsearch

Elasticsearch 是一个基于 Lucene 库的搜索引擎。它提供了一个分布式、支持多租户的全文搜索引擎,具有 HTTP Web 接口和无模式 JSON 文档。Elasticsearch 是用 Java 开发的,并在 Apache 许可证下作为开源软件发布。官方客户端在 Java、.NET(C#)、PHP、Python、Apache Groovy、Ruby 和许多其他语言中都是可用的。Elastic 8.0 版通过改进 Elasticsearch 的矢量搜索功能、对现代自然语言处理模型的原生支持、不断简化的数据上线过程,以及精简的安全防护体验,在速度、扩展幅度、相关性和简便性方面,迎来了一个全新的时代。

Elastic 8.0重要更新

(1)Rest API相比较7.x而言做了比较大的改动(比如彻底删除_type),为了降低用户的升级成本,8.x会暂时的兼容7.x的请求。

(2)默认开启安全配置(三层安全),并极大简化了开启安全需要的工作量,可以这么说:7.x开启安全需要10步复杂的步骤比如CA、证书签发、yml添加多个配置等等,8.x只需要一步即可)。

(3)存储空间优化:更新了倒排索引,对倒排文件使用新的编码集,对于keyword、match_only_text、text类型字段有效,有3.5%的空间优化提升,对于新建索引和segment自动生效。

(4)优化geo_point,geo_shape类型的索引(写入)效率:15%的提升。

(5)新特性:支持上传pyTorch模型,在ingest的时候使用。比如在写入电影评论的时候,如果我们想要知道这个评论的感情正负得分,可以使用对应的AI感情模型对评论进行运算,将结果一并保存在ES中。

(6)技术预览版KNN API发布,(K邻近算法),跟推荐系统、自然语言排名相关。之前的KNN是精确搜索,在大数据集合的情况会比较慢,新的KNN提供近似KNN搜索,以提高速度。

(7)对ES内置索引的保护加强了:elastic用户默认只能读,如果需要写权限的时候,需有allow_restrict_access权限。

系统优化

系统版本

代码语言:javascript
复制
cat  /etc/os-release 
NAME="openEuler"
VERSION="22.03 (LTS-SP1)"
ID="openEuler"
VERSION_ID="22.03"
PRETTY_NAME="openEuler 22.03 (LTS-SP1)"
ANSI_COLOR="0;31" 

关闭selinux

代码语言:javascript
复制
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
setenforce 0
getenforce

优化文件数限制及最大虚拟内存限制

代码语言:javascript
复制
#添加如下信息
vim /etc/security/limits.conf
*               soft      nofile          65536
*               hard      nofile          65536
*               soft      nproc           65536
*               hard      nproc           65536
*               hard      memlock         unlimited
*               soft      memlock         unlimited

#查看当前用户文件数限制
ulimit -n

vim /etc/sysctl.conf
vm.swappiness = 0
vm.max_map_count = 262144
net.core.somaxconn = 65535
fs.file-max = 655360

使用sysctl -p使系统配置生效

elasticsearch 部署

1,下载elasticsearch8.6.1软件包

https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.6.1-linux-x86_64.tar.gz

2,解压elasticsearch安装包

代码语言:javascript
复制
tar -zvxf elasticsearch-8.6.1-linux-x86_64.tar.gz
mv  elasticsearch-8.6.1  /usr/local/

3,创建elastic用户并修改文件夹属组及权限

代码语言:javascript
复制
groupadd elastic
useradd -g elastic elastic
chown  -R elastic:elastic /usr/local/elasticsearch-8.6.1

4,elasticsearch配置文件

vim /usr/local/elasticsearch-8.6.1/config/elasticsearch.yml

代码语言:javascript
复制
cluster.name: my-application
node.name: node-1
path.data: /path/to/data
path.logs: /path/to/logs
bootstrap.memory_lock: false
network.host: 0.0.0.0
http.port: 9200
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
  enabled: false
  keystore.path: certs/http.p12
xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12
cluster.initial_master_nodes: ["192.168.8.50"]

5,配置文件参数说明

代码语言:javascript
复制
cluster.name: my-application #集群名称
node.name: node-1 #节点名称
node.roles: [master,data] # 注意集群至少有两个具有选举master资格的节点
path.data: /path/to/data # 数据存储位置
path.logs: /path/to/logs  #日志存储位置
network.host: 0.0.0.0     #允许连接IP
http.port: 9200               # 网页访问端口
http.cors.enabled: true
http.cors.allow-origin: “*”

6,重置elastic用户密码

代码语言:javascript
复制
/usr/local/elasticsearch-8.6.1/bin/elasticsearch-reset-password  -u elastic
This tool will reset the password of the [elastic] user to an autogenerated value.
The password will be printed in the console.
Please confirm that you would like to continue [y/N]y

Password for the [elastic] user successfully reset.
New value: SKwj2Mj3IiRZGv2NlbR7

7,重置kibana用户密码

代码语言:javascript
复制
#随机生成密码
 /usr/local/elasticsearch-8.6.1/bin/elasticsearch-reset-password  -u kibana
#自定义密码
 /usr/local/elasticsearch-8.6.1/bin/elasticsearch-reset-password  -u kibana -i

8,systemctl 服务管理

vim /usr/lib/systemd/system/elasticsearch.service

代码语言:javascript
复制
[Unit]
Description=elasticsearch
After=network.target
[Service]
Type=simple
User=elastic
Group=elastic
LimitNOFILE=65535
LimitNPROC=65535
Restart=no
ExecStart=/usr/local/elasticsearch-8.6.1/bin/elasticsearch
PrivateTmp=true
[Install]
WantedBy=multi-user.target

9,启动开机启动

代码语言:javascript
复制
systemctl  enable   elasticsearch &&  systemctl   start  elasticsearch

Kibana部署

1,下载kibana软件包

https://artifacts.elastic.co/downloads/kibana/kibana-8.6.1-linux-x86_64.tar.gz

2,解压kibana安装包

代码语言:javascript
复制
tar -zvxf kibana-8.6.1-linux-x86_64.tar.gz
mv  kibana-8.6.1  /usr/local/kibana

3,创建kibana用户并修改文件夹属组及权限

代码语言:javascript
复制
groupadd kibana
useradd -g kibana kiban
chown  -R kibana:kibana /usr/local/kibana

4,kibana配置文件

egrep -v "*#|^$" /usr/local/kibana/config/kibana.yml

代码语言:javascript
复制
server.port: 5601
server.host: "0.0.0.0"
server.name: "127.0.0.1"
elasticsearch.hosts: ["http://192.168.8.50:9200"]
elasticsearch.username: "kibana"
elasticsearch.password: "vKW60ZG+LmHrH97rlOTf"
i18n.locale: "zh-CN"

5,systemctl 服务管理

vim /usr/lib/systemd/system/kibana.service

代码语言:javascript
复制
[Unit]
Description=Kibana

[Service]
Type=simple
User=kibana
Group=kibana
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
# Prefixing the path with '-' makes it try to load, but if the file doesn't
# exist, it continues onward.
EnvironmentFile=-/usr/local/kibana/config
EnvironmentFile=-/etc/sysconfig/kibana
ExecStart=/usr/local/kibana/bin/kibana 
Restart=always
WorkingDirectory=/

[Install]
WantedBy=multi-user.target

6,启动开机启动

代码语言:javascript
复制
systemctl  enable   kibana  &&  systemctl   start   kibana

logsatsh部署

1,下载logsatsh软件包

https://artifacts.elastic.co/downloads/logstash/logstash-8.6.1-linux-x86_64.tar.gz

2,解压logstash安装包

代码语言:javascript
复制
tar -zvxf logstash-8.6.1-linux-x86_64.tar.gz
mv  logstash-8.6.1  /usr/local/

3,创建logstash服务

以root身份执行logstash命令创建服务

代码语言:javascript
复制
/usr/local/logstash-8.6.1/bin/system-install

4,修改/etc/systemd/system/logstash.service 文件

代码语言:javascript
复制
[Unit]
Description=logstash

[Service]
Type=simple
User=root
Group=root
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
# Prefixing the path with '-' makes it try to load, but if the file doesn't
# exist, it continues onward.
EnvironmentFile=-/etc/default/logstash
EnvironmentFile=-/etc/sysconfig/logstash
#ExecStart=/usr/local/logstash-8.6.1/bin/logstash "--path.settings" "/etc/logstash"
ExecStart=/usr/local/logstash-8.6.1/bin/logstash " --path.settings" "/usr/local/logstash-8.6.1/config" "--path.config" "/usr/local/logstash-8.6.1/logstash.d"
Restart=always
WorkingDirectory=/
Nice=19
LimitNOFILE=16384

# When stopping, how long to wait before giving up and sending SIGKILL?
# Keep in mind that SIGKILL on a process can cause data loss.
TimeoutStopSec=infinity

[Install]
WantedBy=multi-user.target

6,启动开机启动

代码语言:javascript
复制
systemctl start logstash  && systemctl enable logstash

7,logstash配置文件

vim /usr/local/logstash-8.6.1/logstash.d/syslog.conf

代码语言:javascript
复制
input {
     beats {
      port => "5044"
    }
}
filter {
  if "secure" in [tags]{
    mutate {
       add_field => {"testname" => "songhongpeng"}
     }
  }
}

output{
#stdout{codec => rubydebug}
 if "secure" in [tags]{
elasticsearch{
    index => "secure-%{+YYYY.MM.dd}"
    hosts => ["127.0.0.1:9200"]
    user => "elastic"
    password => "SKwj2Mj3IiRZGv2NlbR7"
    }
  }
}

filebeat部署

1,rpm 安装filebeat

代码语言:javascript
复制
rpm -ivh filebeat-8.6.1-x86_64.rpm

2,filebeat配置文件

egrep -v "*#|^$" /etc/filebeat/filebeat.yml

代码语言:javascript
复制
filebeat.inputs:
- type: filestream
  enabled: true
  paths:
    - /var/log/secure
  tags: ["secure"]
filebeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false
setup.template.settings:
  index.number_of_shards: 1
setup.kibana:
output.logstash:
  hosts: ["localhost:5044"]

3,启动开机启动

代码语言:javascript
复制
systemctl    restart  filebeat && systemctl     enable   filebeat

4,kibana 访问

http://ip:5601/

elastic API查看集群状态

代码语言:javascript
复制
#查看集群节点
curl -u elastic:SKwj2Mj3IiRZGv2NlbR7  http://192.168.8.50:9200/_cat/nodes?v
#查看集群健康状态
curl -u elastic:SKwj2Mj3IiRZGv2NlbR7  http://192.168.8.50:9200/_cluster/health
#查看集群索引
curl -u elastic:SKwj2Mj3IiRZGv2NlbR7  http://192.168.8.50:9200/_cat/indices
#删除索引
curl -u elastic:SKwj2Mj3IiRZGv2NlbR7 -XDELETE http://192.168.8.50:9200/heartbeat-2023-01
本文参与?腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2023-01-31,如有侵权请联系?cloudcommunity@tencent.com 删除

本文分享自 开源搬运工宋师傅 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与?腾讯云自媒体分享计划? ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
Elasticsearch Service
腾讯云 Elasticsearch Service(ES)是云端全托管海量数据检索分析服务,拥有高性能自研内核,集成X-Pack。ES 支持通过自治索引、存算分离、集群巡检等特性轻松管理集群,也支持免运维、自动弹性、按需使用的 Serverless 模式。使用 ES 您可以高效构建信息检索、日志分析、运维监控等服务,它独特的向量检索还可助您构建基于语义、图像的AI深度应用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
http://www.vxiaotou.com