docker 安装并运行 elasticsearch(单机版)
1.拉取指定版本的 ElasticSearch:操作命令docker pull elasticsearch:5.2.0操作示例:PS C:\WINDOWS\system32> docker pull elasticsearch:5.2.05.2.0: Pulling from library/elasticsearch5040bd298390: Pull complet...
·
1.拉取指定版本的 ElasticSearch:
- 操作命令
docker pull elasticsearch:6.5.0
- 操作示例:
PS C:\WINDOWS\system32> docker pull elasticsearch:6.5.0
6.5.0: Pulling from library/elasticsearch
5040bd298390: Pull complete
fce5728aad85: Pull complete
c42794440453: Pull complete
0c0da797ba48: Pull complete
7c9b17433752: Pull complete
d4d33418bd6d: Pull complete
0e10cce36e52: Pull complete
09dd4de551b0: Pull complete
dd2fffb2567d: Pull complete
ccf025f80d4d: Pull complete
672b9297eb8f: Pull complete
38c763fc303a: Pull complete
85a55935bd1a: Pull complete
96cfc0c6d54d: Pull complete
Digest: sha256:8f4c23871494b6baacbaf0c9f6ee48db1b5c62de33f9c4c14b2e17f1922e56ee
Status: Downloaded newer image for elasticsearch:6.5.0
PS C:\WINDOWS\system32>
2.查看已拉取的 ElasticSearch:
- 操作命令
docker image ls elasticsearch
- 操作示例:
PS C:\WINDOWS\system32> docker image ls elasticsearch
REPOSITORY TAG IMAGE ID CREATED SIZE
elasticsearch 6.5.0 c9c606d302fb 2 years ago 351MB
PS C:\WINDOWS\system32>
3.创建ElasticSearch配置文件,数据目录,日志目录:
- 操作命令:
mkdir -p D:/SoftWare/data/DockerDataInfo/ElasticSearch6.5.0/config/
mkdir -p D:/SoftWare/data/DockerDataInfo/ElasticSearch6.5.0/data/
mkdir -p D:/SoftWare/data/DockerDataInfo/ElasticSearch6.5.0/logs/
- 操作示例:
PS C:\Users\54lxb\Desktop> mkdir -p D:/SoftWare/data/DockerDataInfo/ElasticSearch6.5.0/config/
目录: D:\SoftWare\data\DockerDataInfo\ElasticSearch6.5.0
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2019/8/6 10:19 config
PS C:\Users\54lxb\Desktop> mkdir -p D:/SoftWare/data/DockerDataInfo/ElasticSearch6.5.0/data/
目录: D:\SoftWare\data\DockerDataInfo\ElasticSearch6.5.0
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2019/8/6 10:20 data
PS C:\Users\54lxb\Desktop> mkdir -p D:/SoftWare/data/DockerDataInfo/ElasticSearch6.5.0/logs/
目录: D:\SoftWare\data\DockerDataInfo\ElasticSearch6.5.0
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2019/8/6 10:21 logs
PS C:\Users\54lxb\Desktop>
用文件管理器打开
D:/SoftWare/data/DockerDataInfo/ElasticSearch6.5.0/config/
目录,新建文件名为elasticsearch.xml
的文件,然后打开文件,将下面的内容复制到刚才新建的文件中并并保存;
# ======================== 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 consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: elasticSearch-6.5.0
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.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 heap size 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, consult the network module documentation.
#
# --------------------------------- 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: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes:
#
# For more information, consult the zen discovery module documentation.
discovery.zen.minimum_master_nodes: 1
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
4.运行 ElasticSearch:
- 操作命令
docker run --restart=always -d --name elasticsearch6.5.0 -v D:/SoftWare/data/DockerDataInfo/ElasticSearch6.5.0/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v D:/SoftWare/data/DockerDataInfo/ElasticSearch6.5.0/data:/usr/share/elasticsearch/data -v D:/SoftWare/data/DockerDataInfo/ElasticSearch6.5.0/logs:/usr/share/elasticsearch/logs -p 9200:9200 -e "discovery.type=single-node" elasticsearch:6.5.0
- 操作示例:
PS C:\WINDOWS\system32> docker run --restart=always -d --name elasticsearch6.5.0 -v D:/SoftWare/data/DockerDataInfo/ElasticSearch6.5.0/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v D:/SoftWare/data/DockerDataInfo/ElasticSearch6.5.0/data:/usr/share/elasticsearch/data -v D:/SoftWare/data/DockerDataInfo/ElasticSearch6.5.0/logs:/usr/share/elasticsearch/logs -p 9200:9200 -e "discovery.type=single-node" elasticsearch:6.5.0
1e0f242864f3c89ea1aaea8c3c336d76c9dd8b811020107fb9bfe1db63dd556d
PS C:\WINDOWS\system32>
5.验证 ElasticSearch 是否启动成功:
- 查看容器运行状态:
PS C:\WINDOWS\system32> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1e0f242864f3 elasticsearch:6.5.0 "/docker-entrypoint.…" 8 seconds ago Up 4 seconds 0.0.0.0:9200->9200/tcp, 9300/tcp elasticsearch6.5.0
PS C:\WINDOWS\system32>
通过以上信息,我们可以很清楚的了解到,ElasticSearch已经启动成功了!
- 直接访问:
http://localhost:9200/
,如果显示结果和下面的差不多,那就证明运行成功了;
{
"name": "D5_rqfS",
"cluster_name": "elasticSearch-6.5.0",
"cluster_uuid": "gLji9I8GRa6TOl5kfmO8uA",
"version": {
"number": "6.5.0",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "816e6f6",
"build_date": "2018-11-09T18:58:36.352602Z",
"build_snapshot": false,
"lucene_version": "7.5.0",
"minimum_wire_compatibility_version": "5.6.0",
"minimum_index_compatibility_version": "5.0.0"
},
"tagline": "You Know, for Search"
}
更多推荐
已为社区贡献2条内容
所有评论(0)