記ElasticSearch 8.X版本docker容器中安裝


最近想深入學習ES,想在它的基礎上定制日志收集中間件,所以特定把它記錄下來

創建ES配置文件 elasticsearch.yml,把文件放到 config目錄下

# 集群名稱
cluster.name: kite-es-cluster
# 節點名稱
node.name: kite-es-node-1
# 綁定host,0.0.0.0代表當前節點的ip
network.host: 0.0.0.0
# 是否支持跨域,默認為false
http.cors.enabled: true
# 當設置允許跨域,默認為*,表示支持所有域名,如果我們只是允許某些網站能訪問,那么可以使用正則表達式。比如只允許本地地址。 /https?:\/\/localhost(:[0-9]+)?/
http.cors.allow-origin: "*"
#初始化主節點
cluster.initial_master_nodes: ["kite-es-node-1"]  #本地只有一個節點,無法正常啟動,先注釋

 創建docker-compose.yml 容器編排文件

version: '3.9'

services:
 elasticsearch:
  image: elasticsearch:8.1.2
  restart: always  
  hostname: kite.elasticsearch
  container_name: kite.elasticsearch
  volumes:
   - ./data:/usr/share/elasticsearch/data
   - ./plugins:/usr/share/elasticsearch/plugins
   - ./config/elasticsearch.yml:/config/elasticsearch.yml
  environment:
   - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
   - discovery.type=single-node
  ports:
    - '9200:9200'     #java、集群通信端口
    - '9300:9300'     #http通信端口
  privileged: true    #環境變量

 上面代碼中紅色標識配置文件的掛在,網上搜了很多資料是:

./config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
但是ES8.X配置文件目錄實際上是在 /config/elasticsearch.yml
 

 

 進入docker-compose.yml所在目錄,打開命令行 執行docker-compose up -d 即可


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM