下载镜像

docker pull elasticsearch:7.2.0
docker pull kibana:7.2.0

安装 elasticsearch

创建目录

mkdir -pv /opt/elasticsearch/{config,data,plugins}

更新配置文件

sudo tee /opt/elasticsearch/config/elasticsearch.yml <<-'EOF'
http.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*" 
EOF

配置分词器

#在/opt/elasticsearch/plugins目录下下载ik插件 或者进入容器直接执行,本次直接在挂在目录之外配置,配置之后请删除压缩包

wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.2.0/elasticsearch-analysis-ik-7.2.0.zip

unzip elasticsearch-analysis-ik-7.2.0.zip -d ik

启动容器

[root@localhost elasticsearch]# docker run --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xmx1024m -Xmx1024m" -v /opt/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /opt/elasticsearch/data:/usr/share/elasticsearch/data -v /opt/elasticsearch/plugins:/usr/share/elasticsearch/plugins -d elasticsearch:7.2.0
c6e1e3fa61cd84f0123ce56453cf5350feda9edd7dc60434db3868f74a47059a
[root@localhost elasticsearch]# 

查看进程

[root@localhost config]# docker ps
CONTAINER ID   IMAGE                 COMMAND                  CREATED          STATUS          PORTS                                                                                  NAMES
c6e1e3fa61cd   elasticsearch:7.2.0   "/usr/local/bin/dock…"   13 minutes ago   Up 13 minutes   0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp   elasticsearch
[root@localhost config]# 

使用curl http://localhost:9200/ 查看对外服务

[root@localhost config]# curl http://localhost:9200/  
{
  "name" : "c6e1e3fa61cd",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "hwZBRInqQDyqSILw3kCN4Q",
  "version" : {
    "number" : "7.2.0",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "508c38a",
    "build_date" : "2019-06-20T15:54:18.811730Z",
    "build_snapshot" : false,
    "lucene_version" : "8.0.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
[root@localhost config]# 

更改容器配置

docker update --restart=always elasticsearch

安装kinaba

查看 elasticsearch ip地址

[root@localhost config]# docker inspect elasticsearch | grep IPAddress  
            "SecondaryIPAddresses": null,
            "IPAddress": "172.17.0.2",
                    "IPAddress": "172.17.0.2",
[root@localhost config]# 

安装kinaba

 docker run -di --name=kibana -e ELASTICSEARCH_URL=http://172.17.0.2:9200 --restart=always -p 5601:5601 kibana:7.2.0 
[root@localhost config]# docker run -di --name=kibana -e ELASTICSEARCH_URL=http://172.17.0.2:9200 --restart=always -p 5601:5601 kibana:7.2.0 
ea9ede48dc3c6201c30b9c9803dd7b9360c538f30caf1ef952360520d3be004a
[root@localhost config]# 

在这里插入图片描述

在这里插入图片描述
这个时候需要稍等一会儿,容器还在启动中,稍安勿躁
在这里插入图片描述

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐