栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 云计算 > 云平台

ElasticSearch+Kibana个人笔记

云平台 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ElasticSearch+Kibana个人笔记

1. Windows下安装ElasticSearch 8.2

ElasticSearch下载:https://www.elastic.co/cn/downloads/elasticsearch
选择Windows进行演示。

解压压缩包

ElasticSearch官方安装文档(Windows):https://www.elastic.co/guide/en/elasticsearch/reference/current/zip-windows.html

1.1. 使用CMD命令行安装 (对比1.2.选一个即可)

PowerShell语句: (# 是注释的意思)

# 推荐使用管理员运行 PowerShell
# 选择你的解压路径binelasticsearch.bat
# 例如:
cd E:elasticsearch-8.2.0binelasticsearch.bat
1.2. 鼠标操作安装 (对比1.1.选一个即可)

参考 1.1. 中的 powershell 路径,找到 elasticsearch.bat 文件。
右键管理员运行安装。

1.3. 安装成功样式

PowerShell 输出如下 (仅截取部分成功有关信息) :

...
[2022-05-14T22:20:38,584][INFO ][o.e.h.AbstractHttpServerTransport] [DESKTOP-JS17RFC] publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}, {[::1]:9200}
...
[2022-05-14T22:20:38,585][INFO ][o.e.n.Node               ] [DESKTOP-JS17RFC] started
...
...
# 下面是需要备份的内容
-> Elasticsearch security features have been automatically configured!
-> Authentication is enabled and cluster connections are encrypted.

->  Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
#############################
#  xXV10马GJaq赛pHcv克u_qg  # # 密码!后面要用
#############################
->  HTTP CA certificate SHA-256 fingerprint:
# HTTP 认证 
  7464f2f马赛克c10dc7e72e5ac78338cd2f4马赛克0895de852ff4马赛克62eef60ad304e

->  Configure Kibana to use this cluster:
* Run Kibana and click the configuration link in the terminal when Kibana starts.
* Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
# Kibana 连接 ElasticSearch 密钥 # 后面要用
  eyJ2ZXIiOiI4LjIuMCIsImFkciI6WyIxOTg马赛克guMC4xOjkyMDAiXSwiZmdyIjoiNzQ2NGYyZjg2ZGMxMGRjN2U马赛克U1YWM3ODMzOGNkMmY0MzliMDg5NWRlODUyZmY0ZDZiNj马赛克WY2MGFkMzA0ZSIsImtleSI6IlZzekp3b0FCU马赛克dU5KWnFfU1pWOnd6OE9WcmtPUzVlMHlMUVhmdTc0Q0EifQ==

->  Configure other nodes to join this cluster:
# 将多个节点加入到集群里面
* On this node: # 加入到当前节点
  - Create an enrollment token with `bin/elasticsearch-create-enrollment-token -s node`.
  - Uncomment the transport.host setting at the end of config/elasticsearch.yml.
  - Restart Elasticsearch.
* On other nodes: # 加入到其他节点
  - Start Elasticsearch with `bin/elasticsearch --enrollment-token `, using the enrollment token that you generated.
...

此时,浏览器访问:http://localhost:9200,出现下图即为启动成功。

默认用户名:elastic
密码:xXV10马GJaq赛pHcv克u_qg(1.3. PowerShell 打印的密码)

登陆成功页面如下:

{
    "name": "DESKTOP-JS17RFC",
    "cluster_name": "elasticsearch",
    "cluster_uuid": "_7e7P5WJRsmyAiAyZYaarg",
    "version": {
        "number": "8.2.0",
        "build_flavor": "default",
        "build_type": "zip",
        "build_hash": "b174af62e8dd9f4ac4d25875e9381ffe2b9282c5",
        "build_date": "2022-04-20T10:35:10.180408517Z",
        "build_snapshot": false,
        "lucene_version": "9.1.0",
        "minimum_wire_compatibility_version": "7.17.0",
        "minimum_index_compatibility_version": "7.0.0"
    },
    "tagline": "You Know, for Search"
}
2. Windows下安装 Kibana 8.2

Kibana 8.2 官方下载地址:https://www.elastic.co/cn/downloads/kibana

解压压缩包,我的路径:E:kibana-8.2.0
打开 PowerShell (管理员运行)

# 运行 kibana.bat 安装程序
PS E:kibana-8.2.0bin> .kibana.bat
#############################
但是我这里接下来报错了
[2022-05-14T23:42:13.999+08:00][ERROR][elasticsearch-service] Unable to retrieve version information from Elasticsearch nodes. security_exception: [security_exception] Reason: missing authentication credentials for REST request [/_nodes?filter_path=nodes.*.version%2Cnodes.*.http.publish_address%2Cnodes.*.ip]
#############################

这里我报错了,改用 Linux 安装。。。

3. 重置 ElasticSearch 密码

打开 PowerShell (管理员)

# 一定要到 elasticsearch 根目录
PS E:elasticsearch-8.2.0> bin/elasticsearch-reset-password -u elastic
warning: ignoring JAVA_HOME=E:Javajdk1.8.0_281; using bundled JDK
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: aF9F马赛克XvOT67ll+wdBY # 新生成的密码
2. Linux下 Docker 安装 ElasticSearch

采用 :Vagrant + VirtualBox

2.1. 切换管理员
[vagrant@10 ~]$ su root
Password:vagrant
2.2. 拉取 ElasticSearch 镜像
// 这里建议指定版本号,否则下载的是 5.6.12 老版本,不知道为啥不下最新的。。
[root@10 conf]# docker pull elasticsearch:7.4.2

查看,成功:

[root@10 conf]# docker images
REPOSITORY      TAG       IMAGE ID       CREATED        SIZE
elasticsearch   7.4.2     b1179d41a7b4   2 years ago    855MB
2.3. 配置挂载等等
# 创建目录:用来将 docker 外的 config 挂在到内部,可以通过修改 docker 外部的 config 来更改内部设置
[root@10 conf]# mkdir -p /mydata/elasticsearch/config

# 创建目录:用来将 docker 内部的 data 文件挂在到 docker 外部
[root@10 conf]# mkdir -p /mydata/elasticsearch/data

# 在 yml 里写入,"http.host: 0.0.0.0" 代表任何主机都可以访问 elasticsearch
[root@10 elasticsearch]# echo "http.host: 0.0.0.0" >> /mydata/elasticsearch/config/elasticsearch.yml

# 检查是否写入成功,到 config 文件夹内
[root@10 config]# cat elasticsearch.yml
http.host: 0.0.0.0

# 将目录  /mydata/elasticsearch/ 下的所有文件的权限设置为:所有用户可读可写可修改。
chmod -R 777 /mydata/elasticsearch/
2.4. 启动 ElasticSearch
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 
-e  "discovery.type=single-node" 
-e ES_JAVA_OPTS="-Xms64m -Xmx512m" 
-v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml 
-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data 
-v  /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins 
-d elasticsearch:7.4.2
2.5. 设置开机自启动 ElasticSearch
[root@10 elasticsearch]# docker update elasticsearch --restart=always
2.6. 测试 ElasticSearch

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

192.168.56.10 替换成你的虚拟机地址

// 访问成功,显示如下:
{
    "name": "7019fd74fcd3",
    "cluster_name": "elasticsearch",
    "cluster_uuid": "9VgJmq05SI-12-Mr_nsg1Q",
    "version": {
        "number": "7.4.2",
        "build_flavor": "default",
        "build_type": "docker",
        "build_hash": "2f90bbf7b93631e52bafb59b3b049cb44ec25e96",
        "build_date": "2019-10-28T20:40:44.881551Z",
        "build_snapshot": false,
        "lucene_version": "8.2.0",
        "minimum_wire_compatibility_version": "6.8.0",
        "minimum_index_compatibility_version": "6.0.0-beta1"
    },
    "tagline": "You Know, for Search"
}

浏览器访问:http://192.168.56.10:9200/_cat/nodes

192.168.56.10 替换成你的虚拟机地址

// 显示如下:
127.0.0.1 14 99 98 2.83 1.13 0.70 dilm * 7019fd74fcd3
3. Linux下 Docker 安装 Kibana 3.1. 拉取 Kibana
# 版本要与 elasticsearch 一致,由于 elasticsearch 指定了 7.4.2 版本
[root@10 conf]# docker pull kibana:7.4.2

# 查看,成功了:
[root@10 conf]# docker images
REPOSITORY      TAG       IMAGE ID       CREATED        SIZE
kibana          7.4.2     230d3ded1abc   2 years ago    1.1GB
elasticsearch   7.4.2     b1179d41a7b4   2 years ago    855MB
3.2. 启动 Kibana
// @ -> 你的虚拟机地址
// # -> 你的kibana版本,如果没有指定就是 latest
// [root@10 elasticsearch]# docker run --name kibana -e ELASTICSEARCH_HOSTS=http://@ -p 5601:5601 -d kibana:#
// 例如:
[root@10 elasticsearch]# docker run --name kibana -e ELASTICSEARCH_HOSTS=http://192.168.56.10 -p 5601:5601 -d kibana:7.4.2
3.3. 设置开机启动 Kibana
[root@10 elasticsearch]# docker update kibana  --restart=always
3.4. 测试 Kibana

浏览器访问http://192.168.56.10:5601/app/kibana

192.168.56.10 替换成你的虚拟机地址

// 可以访问就成功了
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/895941.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

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

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