1、准备环境,安装docker
2、拉取镜像,这里使用的是7.4.2
docker pull elasticsearch :7.4.2
3、查看下载好的镜像
docker images
4、创建挂载目录:
mkdir -p /mydata/elasticsearch/config
mkdir -p /mydata/elasticsearch/data
mkdir -p /mydata/elasticsearch/plugins
修改挂载目录的权限 :chmod -R 777 /mydata/elasticsearch
echo “http.host: 0.0.0.0” >> /mydata/elasticsearch/config/elasticsearch.yml
将http.host: 0.0.0.0写入到elasticsearch.yml文件中,如果没有,创建文件
5、启动elasticsearch
docker run --name elasticsearch
-p 9200:9200 -p 9300:9300
-e "discovery.type=single-node"
-e "ES_JAVA_OPTS=-Xms64m -Xmx128m"
-v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearche.yml
-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data
-v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins
-d elasticsearch:7.4.2
--name 容器名
-p 映射端口号
-e 设置属性
-v 挂载目录
-d 指定启动版本
7、通过ip:9200访问
{
"name": "3d807e6bcf99",
"cluster_name": "docker-cluster",
"cluster_uuid": "mRvL3IpTTpqASepMLmDZtA",
"version": {
"number": "7.4.2",
"build_flavor": "default",
"build_type": "docker",
"build_hash": "2f90bbf7b93631e52bafb59b3b049cb44ec25e96",
"build_date": "2019-10-28T20:40:44.881551Z",
"build_snapshot": false,
"lucene_version": "8.2.0",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}
看到返回数据说明安装成功
二、使用docker安装kibana
1、git pull kibana:7.4.2 注意这里kibana的版本号一定要和elasticSearch的版本号一致
2、docker run --name kibaba -e ELASTICSEARCH_HOSTS=http://ip:port -p 5601:5601 -d kibana:7.4.2
3、http://47.108.140.201:5601/ 访问
至此安装完成