欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

ElasticSearch+Kibana 8.1.0 安装和部署

最编程 2024-10-13 07:13:26
...

Windows环境

通过百度网盘分享的文件:ElasticSearch+Kibana
链接:https://pan.baidu.com/s/14Bf9AkRjf5igaa10e18OWA?pwd=1rmh 
提取码:1rmh

下载后解压

命令都在bin目录下用cmd执行

一、ElasticSearch

注意:8.1.0自带jdk17,比较老的版本没有自带的,需要配置jdk环境。

配置

1、根据自己的需要设置ElasticSearch运行内存,修改config目录下的jvm.options文件,添加:

-Xms512m
-Xmx512m

如果不设置内存,ES会占用大量内存。

然后打开elasticsearch.yml,修改配置bootstrap.memory_lock为true,即可完成对堆内存的大小限制为512M

2、设置集群安全认证

ES8.1.0自动启动了安全认证以及SSL加密传输,如果需要关闭,在elasticsearch.yml中添加如下配置,设置为false。

# Enable security features
xpack.security.enabled: false

xpack.security.enrollment.enabled: false

# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
  enabled: true
  keystore.path: certs/http.p12

# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12
# Create a new cluster with the current node only
# Additional nodes can still join the cluster later
cluster.initial_master_nodes: ["名称"]

# Allow HTTP API connections from localhost and local networks
# Connections are encrypted and require user authentication
http.host: [_local_, _site_]

# Allow other nodes to join the cluster from localhost and local networks
# Connections are encrypted and mutually authenticated
#transport.host: [_local_, _site_]
http.cors.enabled: true
http.cors.allow-origin: "*"

#----------------------- END SECURITY AUTO CONFIGURATION -------------------------

3、设置对外访问的IP和端口

network.host: localhost

http.port: 9200

4、设置用户名和密码

ES有默认的用户名elastic和密码,启动的时候控制台会显示

重置密码命令:elasticsearch-reset-password -u elastic

启动

bin目录下,双击elasticsearch.bat

然后访问elasticsearch.yml配置的ip和端口即可,如我的:http://127.0.0.1:9200/,出现这样的信息就成功了(有安全认证的话需要用户名和密码)。

其他:elasticsearch可以配置用户,比如配置一个kibana_user,用于对kibana的访问控制或者logstash_user,用于对logstash的访问控制,这些应用就需要配置elasticsearch设置的用户名和密码这些。

配置其他用户的命令:elasticsearch-users useradd my_kibana -p xxxxxx  -r kibana_user

查看对用户的操作的命令:elasticsearch-users

把elasticsearch安装成windows服务的命令:elasticsearch-service.bat install 

二、Kibana

配置

在config目录下的kibana.yml里添加如下配置:

server.port: 5601
server.host: localhost
server.name: mrx
elasticsearch.hosts: ['http://localhost:9200']
i18n.locale: zh-CN
elasticsearch.serviceAccountToken: AAEAAWVsYXN0aWMva2liYW5hL2Vucm9sbC1wcm9jZXNzLXRva2VuLTE3MjYyOTczMTc3MDk6QURiX0ZDRnZRRkdUWnFBSFptMUxLUQ
elasticsearch.ssl.certificateAuthorities: ['D:\kibana\kibana-8.1.0\data\ca_1726297318128.crt']
xpack.fleet.outputs: [{id: fleet-default-output, name: default, is_default: true, is_default_monitoring: true, type: elasticsearch, hosts: ['https://192.168.31.173:9200'], ca_trusted_fingerprint: 7e2d2a232d88ef7cbf16493ea720fa759f8ce293f105e139a3e20c39cc8601ab}]

我这里是直接把这些配置都添加在最下面,方便看。ip、端口、汉化、路径这些都根据自己的情况修改即可,外网访问改成外网ip即可。

其他:

ssl可按需开启或关闭。

kibana是可视化界面,要配置elasticsearch。

如果在elasticsearch中配置过kibana用户,那么kibana这边也需要配置。
elasticsearch.hosts :配置elasticsearch服务的节点,可以有多个节点

elasticsearch.username:用户名

elasticsearch.password:密码

elasticsearch.ssl.verificationMode设置为none

我这里只配置了hosts,用的是默认超级用户elastic,这里可以不用配置用户名和密码,登录页面的时候会让输入,然后会生成相关的信息,就是上面elasticsearch的serviceAccountToken那些。

启动

bin目录下,双击kibana.bat

访问 fhttp://127.0.0.1:5601/,输入用户名和密码

登陆后页面显示如下即成功