# 1.拉取镜像
代码语言:javascript复制[root@node3 ~]# docker pull docker.elastic.co/elasticsearch/elasticsearch:6.3.1
6.3.1: Pulling from elasticsearch/elasticsearch
7dc0dca2b151: Pull complete
d781ed11f72a: Pull complete
1750e875cdfc: Pull complete
c41f251a2369: Pull complete
75f1d1b20ebc: Pull complete
7a5561323db1: Pull complete
ee76915fb2ed: Pull complete
6df425d0ed88: Pull complete
Digest: sha256:178051b116c91ae525369f3468aec167fb2c1cd90456e86c717cb1d135b8595e
Status: Downloaded newer image for docker.elastic.co/elasticsearch/elasticsearch:6.3.1
docker.elastic.co/elasticsearch/elasticsearch:6.3.1
[root@node3 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.elastic.co/elasticsearch/elasticsearch 6.3.1 fa7212eab151 2 years ago 783MB
# 2.启动
代码语言:javascript复制[root@node3 ~]# docker run -d --name es -p 9200:9200 -p 9300:9300 -e “discovery.type=single-node” docker.elastic.co/elasticsearch/elasticsearch:6.3.1
a436ba90636773dbcf59e85f54610b282014bfffd3caec1e1fb0968ff1d66a68
[root@node3 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a436ba906367 docker.elastic.co/elasticsearch/elasticsearch:6.3.1 "/usr/local/bin/dock…" 8 seconds ago Up 7 seconds 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp es
# 3.验证
代码语言:javascript复制[root@node3 ~]# curl 127.0.0.1:9200
{
"name" : "AXxySGg",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "rqnpui2TQb2GDkR-QtIIpg",
"version" : {
"number" : "6.3.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "eb782d0",
"build_date" : "2018-06-29T21:59:26.107521Z",
"build_snapshot" : false,
"lucene_version" : "7.3.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
[root@node3 ~]#
- 至此,已经完成了elasticsearch单节点的搭建,单节点的es一般用于联调或者测试环境,生产环境需要搭建集群化的elasticsearch,以保证服务的高可用。
注意:这里的cluster_name
为docker-cluster