docker 安装Es

2023-10-15 10:03:02 浏览数 (1)

1、下载镜像文件

docker pull elasticsearch:7.4.2     存储和检索数据 docker pull kibana:7.4.2       可视化检索数据

2、创建实例

1、ElasticSearch

mkdir -p /mydata/elasticsearch/config mkdir -p /mydata/elasticsearch/data

echo "http.host: 0.0.0.0" >> /mydata/elasticsearch/config/elasticsearch.yml

chmod -R 777 /mydata/elasticsearch 注释---->保证权限,可读可写

docker run --name elasticsearch -p 9200:9200 -p 9300:9300

-e "discovery.type=single-node"

-e ES_JAVA_OPTS="-Xms64m -Xmx512m"

-v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml

-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data

-v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins

-d elasticsearch:7.4.2

以后再外面装好插件重启即可; 特别注意: -e ES_JAVA_OPTS="-Xms64m -Xmx256m" 测试环境下,设置 ES 的初始内存和最大内存,否则导致过大启动不了 ES

测试:

浏览器发送请求

http://192.168.107.129:9200

得到响应:

代码语言:javascript复制
{
  "name" : "32bb46713f1b",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "YNbl29pHS3alTUfHXgMv7A",
  "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"
}
2、Kibana

docker run --name kibana -e ELASTICSEARCH_HOSTS=http://192.168.107.129:9200 -p 5601:5601 -d kibana:7.4.2

http://192.168.107.129:9200一定改为自己虚拟机的地址

测试:

访问 5601端口

0 人点赞