1.安装docker
docker安装详情请参照此文档docker安装
2. 拉取Elasticsearch镜像
docker安装成功后,使用如下命令拉取Elasticsearch镜像
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.6.1
等待镜像拉取成功后,启动docker实例
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.6.1
此启动方式为单节点启动,如果需要在集群中启动需要在配置文件中做相应的配置
假设我们需要搭建由两个节点组成的elasticsearch集群,两个节点的ip分别为: 节点1(es01)192.168.160.43和节点2(es02)192.168.160.63, 分别在两个节点服务器上新建elasticsearch.yml 文件,
es01配置如下:
#cluster.name: "docker-cluster"
network.host: 192.168.160.43
network.bind_host: 0.0.0.0
network.publish_host: 192.168.160.43
# minimum_master_nodes need to be explicitly set when bound on a public IP
# set to 1 to allow single node clusters
# Details: https://github.com/elastic/elasticsearch/pull/17288
#discovery.zen.minimum_master_nodes: 1
#集群名
cluster.name: es-cluster
#节点名
node.name: es01
#设置对外服务的http端口,默认为9200
http.port: 9200
#设置节点之间交互的tcp端口,默认是9300
transport.tcp.port: 9300
#是否允许跨域REST请求
http.cors.enabled: true
#允许 REST