一個IT宅男

原创:elasticsearch + kibana 8.11.3安装教程

项目地址: https://github.com/elastic/elasticsearch

最新版下载:https://www.lvruan.com/app/555181

docker compose

/home/clc/docker/volume 下面
终极配置文件:

version: "3.1"

services:
  elasticsearch:
    user: "1000:1000"
    container_name: elasticsearch-8.11.3
    image: docker.elastic.co/elasticsearch/elasticsearch:8.11.3
    privileged: true
    ulimits:
      memlock:
        soft: -1
        hard: -1
    environment:
      - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
      - "http.host=0.0.0.0"
      - "node.name=elastic01"
      - "cluster.name=cluster_elasticsearch"
      - "discovery.type=single-node"
    ports:
      - "9200:9200"
    volumes:
      - ./elasticsearch/config:/usr/share/elasticsearch/config
      - ./elasticsearch/data:/usr/share/elasticsearch/data
      - ./elasticsearch/plugins:/usr/share/elasticsearch/plugins
      - ./elasticsearch/logs:/usr/share/elasticsearch/logs

  kibana:
    container_name: kibana-8.11.3
    image: docker.elastic.co/kibana/kibana:8.11.3
    ports:
      - "5601:5601"
    volumes:
      - ./kibana/config:/usr/share/kibana/config
      - ./kibana/logs:/usr/share/kibana/logs

初始化配置文件是:

version: "3.1"

services:
  elasticsearch:
    user: "1000:1000"
    container_name: elasticsearch-8.11.3
    image: docker.elastic.co/elasticsearch/elasticsearch:8.11.3
    privileged: true
    ulimits:
      memlock:
        soft: -1
        hard: -1
    environment:
      - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
      - "http.host=0.0.0.0"
      - "node.name=elastic01"
      - "cluster.name=cluster_elasticsearch"
      - "discovery.type=single-node"
    ports:
      - "9200:9200"


  kibana:
    container_name: kibana-8.11.3
    image: docker.elastic.co/kibana/kibana:8.11.3
    ports:
      - "5601:5601"

这里是没挂载卷的,设置完密码,拷贝相关目录过去自己的目录后,才挂载

全新安装

docker-compose up -d
这个时候,data和config在容器里

拷贝容器里的data和config出来挂载

docker cp -a elasticsearch-8.11.3:/usr/share/elasticsearch/config/ /home/clc/docker/volume/elasticsearch
docker cp -a elasticsearch-8.11.3:/usr/share/elasticsearch/data/ /home/clc/docker/volume/elasticsearch
docker cp -a elasticsearch-8.11.3:/usr/share/elasticsearch/plugins/ /home/clc/docker/volume/elasticsearch
docker cp -a elasticsearch-8.11.3:/usr/share/elasticsearch/logs/ /home/clc/docker/volume/elasticsearch
docker cp -a kibana-8.11.3:/usr/share/kibana/config/ /home/clc/docker/volume/kibana
docker cp -a kibana-8.11.3:/usr/share/kibana/logs/ /home/clc/docker/volume/kibana

给写入权限

sudo chmod -R 755 elasticsearch/data
sudo chmod -R 755 elasticsearch/config
sudo chmod -R 755 elasticsearch/plugins
sudo chmod -R 755 elasticsearch/logs
sudo chmod -R 755 elasticsearch/logs
sudo chmod -R 755 kibana/logs
sudo chmod -R 755 kibana/config
sudo chown -R 1000:1000 elasticsearch/data
sudo chown -R 1000:1000 elasticsearch/config
sudo chown -R 1000:1000 elasticsearch/plugins
sudo chown -R 1000:1000 elasticsearch/logs
sudo chown -R 1000:1000 kibana/logs
sudo chown -R 1000:1000 kibana/config

否则报错,无法启动

config下的配置文件



# 集群节点名称

node.name: "elastic01"

# 设置集群名称为elasticsearch

cluster.name: "cluster_elasticsearch"

# 网络访问限制

network.host: 0.0.0.0

# 以单一节点模式启动

discovery.type: single-node

# 是否支持跨域

http.cors.enabled: true

# 表示支持所有域名

http.cors.allow-origin: "*"

# 内存交换的选项,官网建议为true

bootstrap.memory_lock: true

# 修改安全配置 关闭 证书校验

xpack.security.http.ssl:

  enabled: false

xpack.security.transport.ssl:

  enabled: false

docker-compose up -d
或者 docker compose restart elasticsearch

增加个用户给权限

docker exec -it elasticsearch-8.11.3 bash 进入容器

cd bin
新建用户:elasticsearch-users useradd lvruan 密码设为:pass
给权限:elasticsearch-users roles -a superuser lvruan
elasticsearch-users roles -a kibana_system lvruan

更新容器

docker-compose up -d

配置kibana

# Default Kibana configuration for docker target

i18n.locale: zh-CN

server.host: "0.0.0.0"

# 添加下面这行来设置 server.publicBaseUrl
server.publicBaseUrl: "https://es.lvruan.com"

server.shutdownTimeout: "5s"

elasticsearch.hosts: [ "http://elasticsearch:9200" ]

monitoring.ui.container.elasticsearch.enabled: true

#此处为新生成的kibana账号和密码

elasticsearch.username: "lvruan"

elasticsearch.password: "pass"

docker-compose up -d

开始进入

http://172.20.206.201:9200/
http://172.20.206.201:5601/

赞(2)
未經允許不得轉載:Lincai Chen's Blog » 原创:elasticsearch + kibana 8.11.3安装教程

評論 1