搞了2天终于搞好了

更新: 
  2017/2/15: 更改elasticsearch.yml中绑定ip, 可开启集群效果
//: supervisord.conf 加入 autostart=true, 开启景象自动启动
  2017/2/16: 更改elasticsearch.yml中ip嗅探, 真正实现热插拔集群
bug: 指定的物理机挂在目录仍然存在问题

需要: 一个能在linux下正常运行的 elasticsearch-2.4.0 版本, 直接copy进镜像, 安装好head, bigdesk, ik分词  器等, 在elasticsearch中有讲: http://www.cnblogs.com/wenbronk/p/6390462.html

Dockerfile

############################################
# version : wenbronk/jdk8u121/elasticsearch2.
# desc : 当前版本安装的escluster 2.4.0
############################################ FROM wenbronk/jdk8u121
MAINTAINER wenbronk "wenbronk@163.com" # 设置环境变量,所有操作都是非交互式的
ENV DEBIAN_FRONTEND noninteractive # 添加 supervisord 的配置文件,并复制配置文件到对应目录下面。(supervisord.conf文件和Dockerfile文件在同一路径)
COPY supervisord.conf /etc/supervisor/supervisord.conf RUN echo "export LC_ALL=C" # 设置 ES 的环境变量,若有其他的环境变量需要设置,也可以在这里添加。
ENV ES_HOME /var/tmp/elasticsearch-2.4.
ENV PATH $PATH:$PATH:$ES_HOME/bin # 创建elasticsearch的数据目录, 同时将权限给admin用户
RUN mkdir /escluster # 复制elasticsearch-2.4.0(本地能正常运行的es, 安装好ik插件) 到镜像中 /var/tmp
COPY elasticsearch-2.4. /var/tmp/elasticsearch-2.4.0 # 修改文件夹权限
# RUN chown -R admin:admin /var/tmp/elasticsearch-2.4.
# RUN chown -R admin:admin /escluster # 挂载/software/elasticsearch-2.4./config和/escluster目录
VOLUME ["/var/tmp/elasticsearch-2.4.0/config"]
VOLUME ["/escluster"] # 容器需要开放ES的9200和9300端口
EXPOSE
EXPOSE # 执行supervisord来同时执行多个命令,使用 supervisord 的可执行路径启动服务。
CMD ["/usr/bin/supervisord"]

supervisord.conf

[supervisord]
nodaemon=true [program:sshd]
command=/usr/sbin/sshd -D [program:elasticsearch]
command=/bin/bash -c "exec ${ES_HOME}/bin/elasticsearch -DFOREGROUND"
autostart=true

elasticsearch.yml 文件位于 ${ES_HOME}/config下

# ======================== 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: wenbronk-escluster
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
# node.name: wenbronk-esnode01
#
# 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: /escluster/data
path.data: /escluster/data
# #
# # Path to log files:
# #
path.logs: /escluster/logs
#
# Path to log files:
#
# path.logs: /escluster/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:
#
# 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: ["192.168.1.110", "[::1]"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / + ):
#
# discovery.zen.minimum_master_nodes:
#
# 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:
#
# 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:
#
# Require explicit names when deleting indices:
#
# action.destructive_requires_name: true index.analysis.analyzer.ik.type: ik

    

创建镜像:

docker build -t wenbronk/jdk8u121/escluster .

注: 因为es使用非root账户, docker默认使用root账户, 开启一直不成功, supervisord还没来及学, 所以暂时使用root开启es

vim ./bin/elasticsearch

插入

-Des.insecure.allow.root="true"

启动

docker run -d -p : -p : -p : -v /docker/escluster01:/esculster wenbronk/jdk8u121/escluster
docker run -d -p : -p : -p : -v /docker/escluster01:/esculster wenbronk/jdk8u121/escluster
docker run -d -p : -p : -p : -v /docker/escluster01:/esculster wenbronk/jdk8u121/escluster

可通过ip查看

http://www.wenbronk.com:9200/_plugin/head/

或者链接进容器查看

>dockers exec -it CONTAINER_ID /bin/bash
>container>/var/tmp/es/bin/elasticsearch -d

docker 创建elasticsearch集群镜像的更多相关文章

  1. Docker部署Elasticsearch集群

    http://blog.sina.com.cn/s/blog_8ea8e9d50102wwik.html Docker部署Elasticsearch集群 参考文档: https://hub.docke ...

  2. Elasticsearch使用系列-Docker搭建Elasticsearch集群

    Elasticsearch使用系列-ES简介和环境搭建 Elasticsearch使用系列-ES增删查改基本操作+ik分词 Elasticsearch使用系列-基本查询和聚合查询+sql插件 Elas ...

  3. 基于docker搭建elasticsearch集群

    es集群的搭建 - 基于单机搭建elasticsearch集群见官网 https://www.elastic.co/guide/en/elasticsearch/reference/current/d ...

  4. Centos8 Docker部署ElasticSearch集群

    ELK部署 部署ElasticSearch集群 1.拉取镜像及批量生成配置文件 # 拉取镜像 [root@VM-24-9-centos ~]# docker pull elasticsearch:7. ...

  5. 利用 docker 部署 elasticsearch 集群(单节点多实例)

    文章目录 1.环境介绍 2.拉取 `elasticserach` 镜像 3.创建 `elasticsearch` 数据目录 4.创建 `elasticsearch` 配置文件 5.配置JVM线程数量限 ...

  6. docker创建ceph集群

    背景 Ceph官方现在提供两类镜像来创建集群,一种是常规的,每一种Ceph组件是单独的一个镜像,如ceph/daemon.ceph/radosgw.ceph/mon.ceph/osd等:另外一种是最新 ...

  7. 使用Docker搭建Elasticsearch集群环境

    本篇文章首发于头条号单机如何搭建Elasticsearch集群?使用容器技术快速构建集群环境,欢迎关注头条号和微信公众号"大数据技术和人工智能"(微信搜索bigdata_ai_te ...

  8. docker创建Redis集群

    开始工作: yum install wegt ##安装下载工具 yum install net-tools ##安装网络工具 yum install tree ##安装tree命令(方便查看集群配置文 ...

  9. 基于docker创建Cassandra集群

    一.概述 简介 Cassandra是一个开源分布式NoSQL数据库系统. 它最初由Facebook开发,用于储存收件箱等简单格式数据,集GoogleBigTable的数据模型与Amazon Dynam ...

随机推荐

  1. hdu1251 && hud 1247 (字典树)

    hdu1251 题目 这道题,主要是在主函数的输入输出上犹豫了. #include<stdio.h> #include<cstring> #include<iostrea ...

  2. hdu 4268 贪心+set lower_bound用法

    http://acm.hdu.edu.cn/showproblem.php?pid=4268 A想用手里的牌尽量多地覆盖掉B手中的牌.. 牌有h和w 问A手中的牌最多能覆盖B多少张牌 iterator ...

  3. vc6.0 PK vs2010

    从VC++6.0不足看VisualC++2010新特性 说起VC,有人想到维生素C(维C),有人想到风险投资(venture capital), 程序员们尤其是做底层开发的程序员或老程序员们第一感觉肯 ...

  4. Redis键迁移

    Redis键迁移   在使用Redis的过程中,很多时候我们会遇到需要进行键迁移的问题,需要将指定Redis中的指定数据迁移到其他Redis当中,键迁移有三种方法,我们来进行一一介绍. 一.move ...

  5. 解决 Eclipse Indigo 3.7、ADT 中文字体偏小,完美 Consolas 微软雅黑混合字体!

    Eclipse是著名的跨平台的自由集成开发环境(IDE).6月22日Eclipse 3.7 正式发布,代号是 Indigo . 在 Windows 7 下初始后化,发现界面变化不大,但中文字体却面目全 ...

  6. Java反射reflection与注解annotation的应用(自动测试机)

    一.关于自动测试机 1.什么是自动测试机? 对类中的指定方法进行批量测试的工具 2.自动测试机有什么用? a.避免了冗长的测试代码 当类中的成员方法很多时,对应的测试代码可能会很长,使用测试能够让测试 ...

  7. C# 标准事件模式

    .NET框架为事件定义了一个标准模式,它的目的是保持框架和用户代码之间的一致性. 标准事件的模式核心是SystemEventArgs——预定义的没有成员的框架类(不同于静态Empty属性) Event ...

  8. GitHub设置使用SSH Key,用TortoiseGit进行Clone仓库

    GitHub设置使用SSH Key的好处就是可以使用SSH连接,并且提交代码的时候可以不用输入密码,免密提交. 生成SSH Key 这里我们使用PuTTYgen来生成公钥(Public Key),私钥 ...

  9. In file included from adlist.c:34:0: zmalloc.h:50:31: 致命错误:jemalloc/jemalloc.h:没有那个文件或目录

    问题: In file included from adlist.c:34:0:zmalloc.h:50:31: 致命错误:jemalloc/jemalloc.h:没有那个文件或目录 解决: make ...

  10. 如使用Typescript撸Vue(Vue2 + TS +TSX+CSS module)

    Vue对TS的支持一致不太好,连Vue作者尤大也自嘲真香压错了宝.期待Vue3.0会用TS重构且会有较大改进.不过目前有一些第三方的库可以曲线优化对TS的支持.主要就介绍下过下面两个库来写Vue. 总 ...