Elasticsearch + Kibana 简单安装使用
1.资料来源官网,参考:
https://www.elastic.co/cn/downloads/elasticsearch
https://www.elastic.co/cn/downloads/kibana
2.windows 下安装:
2.1 安装 elasticSearch
下载:
解压
2.2 修改配置文件,关闭用户密码校验:
# 配置X-Pack
# Enable security features
xpack.security.enabled: false
xpack.security.enrollment.enabled: true
# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
enabled: false
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: ["WIN-2386FUA5SHN"]
# Allow HTTP API connections from anywhere
# Connections are encrypted and require user authentication
http.host: 0.0.0.0
http.cors:
enabled: true
allow-origin: "*"
2.3
运行: bin\elasticsearch.bat
查看:http://localhost:9200
1.4 设置elasticsearch密码 默认为: user: elastic password: changeme
修改 ES/config/elasticsearch.yml 文件
xpack.security.enabled: true http.cors: enabled: true allow-origin: "*" allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
-
重启elasticsearch
elasticsearch 8.9.0
默认情况下,elastic
的用户已存在且已设置了密码,需要执行命令重置密码:cmd> elasticsearch-reset-password.bat -u elastic warning: ignoring JAVA_HOME=C:\Program Files\Java\jdk1.8.0_144; 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: qh1rG*****************
2.2 安装 kibana
配置hosts 文件,然后运行 bin\kibana.bat
;
浏览器: http://localhost:5601
配置连接elasticsearch 地址:
配置多地址登录:
3. Docker 安装
3.1 docker 安装本博客文章
3.2 拉取镜像
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.6.0
docker pull docker.elastic.co/kibana/kibana:7.6.0
3.3 创建容器
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.6.0
docker run --link YOUR_ELASTICSEARCH_CONTAINER_NAME_OR_ID:elasticsearch -p 5601:5601 {docker-repo}:{version}
备注:YOUR_ELASTICSEARCH_CONTAINER_NAME_OR_ID 为 elastic 容器的id:运行第一个命令后,执行:docker ps
最后是:
docker run --link 2bf16c4ad702:elasticsearch -p 5601:5601 docker.elastic.co/kibana/kibana:7.6.0
3.4 基于 docker-compose.yml
3.4.1 mkdir 创建一个目录,cd 到目录下面
3.4.2 创建文件 docker-compose.yml
version: '2.2'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
container_name: es01
environment:
- node.name=es01
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es02,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data01:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- elastic
es02:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
container_name: es02
environment:
- node.name=es02
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es01,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data02:/usr/share/elasticsearch/data
networks:
- elastic
es03:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
container_name: es03
environment:
- node.name=es03
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es01,es02
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data03:/usr/share/elasticsearch/data
networks:
- elastic
kibana:
image: docker.elastic.co/kibana/kibana:7.6.0
container_name: kibana
ports:
- 5601:5601
networks:
- elastic
environment:
- SERVER_NAME=kibana.localhost
- ELASTICSEARCH_HOSTS=http://es01:9200
- I18N_LOCALE=zh-CN
- ELASTICSEARCH_USERNAME=elastic
- ELASTICSEARCH_PASSWORD=mypasword
depends_on:
- es01
volumes:
data01:
driver: local
data02:
driver: local
data03:
driver: local
networks:
elastic:
driver: bridge
注:yml文件中,不要有退格,要用空格
elasticsearch启动后自动关闭:减少实例数和内存数目
elasticsearch启动时遇到的错误 max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
执行命令:
sysctl -w vm.max_map_count=262144
查看结果:
sysctl -a|grep vm.max_map_count
上述方法修改之后,如果重启虚拟机将失效,所以:
解决办法:
在 /etc/sysctl.conf文件最后添加一行
vm.max_map_count=262144
即可永久修改
在这个配置中,我们创建了三个Elasticsearch的node:es01及es02,es03。节点es01侦听localhost:9200,而es02通过Docker网络与es01对话。同时我们也创建了另外一个kibana的docker。我们可以在environment中配置它所需要的参数。
等我们创建好这个docker-compose.yml文件后,我们在当前的目录下,打入如下的命令:
docker-compose up
或者:
docker-compose up -d
这里的-d选项表示在detached模式下,运行容器在后台。
我们最终可以在浏览器中看见我们的Kibana被启动的样子
如同我们之前的设置一样, 它运行起来的Locale设置的是中文。我们也可以同时看到两个被启动的Elasticsearch的节点:
一旦docker启动后,我们可以通过docker的命令来执行一些命令,比如
docker exec es01 ls /usr/share/elasticsearch
我们可以通过如下的命令进入到docker进行安装等:
docker exec -it es01 /bin/bash
$ docker exec -it es01 /bin/bash
[root@ec4d19f59a7d elasticsearch]# ls
LICENSE.txt README.textile config jdk logs plugins
NOTICE.txt bin data lib modules
[root@ec4d19f59a7d elasticsearch]#
这里的es01是我们的Elasticsearch实例的名称。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
2018-02-25 Oracle Data Guard搭建 1.虚拟机安装linux