一、制作docker镜像:

Dockerfile文件:

FROM alpine:latest
MAINTAINER chengcuichao
RUN apk update && apk add openjdk8 shadow sudo
RUN wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.6/elasticsearch-2.4.6.tar.gz
RUN tar zxvf elasticsearch-2.4.6.tar.gz -C /usr/local/ && rm -f elasticsearch-2.4.6.tar.gz && /usr/local/elasticsearch-2.4.6/bin/plugin install mobz/elasticsearch-head
RUN useradd elastic && chown -R elastic:elastic /usr/local/elasticsearch-2.4.6

COPY ./run.sh  /root/
RUN chmod +x /root/run.sh

CMD /root/run.sh

run.sh文件:

#!/bin/sh
sed -i "s/node.name: node-1/node.name: $HOSTNAME/g" /usr/local/elasticsearch-2.4.6/config/elasticsearch.yml
sudo -H -u elastic sh /usr/local/elasticsearch-2.4.6/bin/elasticsearch

上传镜像:

docker build -t elastic:2.4
docker tag elastic:1 192.168.78.4/es/elasticsearch:2.4.6
docker push 192.168.78.4/es/elasticsearch:2.4.6

二、在kubernetes上创建:

创建配置文件:

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please see the documentation for further information on configuration options:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# Add custom attributes to the node:
#
# node.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
# path.data: /path/to/data
#
# Path to log files:
#
# path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------           
#                                                                                          
# Lock the memory on startup:                                                              
#                                                                                          
# bootstrap.memory_lock: true                                                              
#                                                                                          
# Make sure that the `ES_HEAP_SIZE` environment variable is set to about half the memory   
# available on the system and that the owner of the process is allowed to use this limit.  
#                                                                                          
# Elasticsearch performs poorly when the system is swapping the memory.                    
#                                                                                        
# ---------------------------------- Network -----------------------------------         
#                                                                                        
# Set the bind address to a specific IP (IPv4 or IPv6):                                          
#                                                                                                
network.host: 0.0.0.0                                                                  
#                                                                                                
# Set a custom port for HTTP:                                                                    
#                                                                                                
http.port: 9200                                                                                
#                                                                                                
# For more information, see the documentation at:                                                
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>          
#
# --------------------------------- Discovery ----------------------------------           
#                                                                                          
# Pass an initial list of hosts to perform discovery when new node is started:             
# The default list of hosts is ["127.0.0.1", "[::1]"]                                      
#                                                                                        
discovery.zen.ping.unicast.hosts: ["es-service"]                                   
#                                                                                        
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
#                                                                                                
discovery.zen.minimum_master_nodes: 2                                                          
#                                                                                                
# For more information, see the documentation at:                                                
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>        
#                                                                                                
# ---------------------------------- Gateway -----------------------------------                 
#                                                                                                
# Block initial recovery after a full cluster restart until N nodes are started:                 
#                                                                                                
# gateway.recover_after_nodes: 3                                                                 
#                                                                                                
# For more information, see the documentation at:                                                
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>          
#                                                                                                
# ---------------------------------- Various -----------------------------------                 
#                                                                                                
# Disable starting multiple nodes on a single system:                                            
#                                                                                                
# node.max_local_storage_nodes: 1                                                                
#                                                                                                
# Require explicit names when deleting indices:                                                  
#                                                                                                
# action.destructive_requires_name: true                                                         
elasticsearch.yml

相关文章:

  • 2022-02-26
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2021-05-30
  • 2021-09-16
  • 2021-06-12
  • 2021-09-27
猜你喜欢
  • 2021-05-25
  • 2022-12-23
  • 2021-11-04
  • 2021-12-07
  • 2021-06-24
  • 2022-02-18
  • 2022-01-18
相关资源
相似解决方案