Docker中使用elasticsearch:7.6.2

宿主機上建立文件

# 建立/mydata/elasticsearch/config/、/mydata/elasticsearch/data
mkdir -p /mydata/elasticsearch/{config,data}

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

chmod -R 777 /mydata/elasticsearch/

啓動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.6.2

設置開機啓動elasticsearch

docker update elasticsearch --restart=always

啓動kibana

docker run --name kibana \
-e ELASTICSEARCH_HOSTS=http://192.168.33.200:9200 \
-p 5601:5601 -d kibana:7.6.2

測試

  • 查看elasticsearch版本信息
# 訪問本身虛擬機的9200端口,例如: http://192.168.33.200:9200/

{
  "name" : "22799138e953",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "x59rbg6aTzityKxaEIf1GA",
  "version" : {
    "number" : "7.6.2",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
    "build_date" : "2020-03-26T06:34:37.794943Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
  • 經過Kibana客戶端訪問elasticsearch

訪問本身虛擬機的5601端口,在瀏覽器中打開Kibana客戶端http://192.168.33.200:5601/app/kibana#/dev_tools/consolenode

image

相關文章
相關標籤/搜索