docker 安裝 elasticsearch5.6 head kibana

安裝Elasticsearch

安裝

可以直接修改config目錄下的 elasticsearch.yml 文件,然後啓動es

network.host: 0.0.0.0

http.cors.enabled: true 
http.cors.allow-origin: "*"
node.master: true
node.data: true

docker run -it --name elasticsearch -d -p 9200:9200 -p 9300:9300 -v /home/docker/config/es:/usr/share/elasticsearch/config -v /home/docker/data/es:/usr/share/elasticsearch/data elasticsearch:5.6.11
其中啓動失敗。es默認啓動分配地址內存2G,而導致失敗信息:
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /tmp/hs_err_pid1.log
解決:vi config/jvm.options
-Xms512m
-Xmx512m
docker run -it --name elasticsearch -d -p 9200:9200 -p 9300:9300 -v $PWD/congfig/jvm.options:/usr/share/elasticsearch/config/jvm.options elasticsearch:5.6.11

 驗證

> curl http://localhost:9200
{
    "name": "OwHPNzY",
    "cluster_name": "elasticsearch",
    "cluster_uuid": "WeiDMjJARv2DHMcCrQgS6g",
    "version": {
    "number": "5.6.4",
    "build_hash": "8bbedf5",
    "build_date": "2017-10-31T18:55:38.105Z",
    "build_snapshot": false,
    "lucene_version": "6.6.1"
},
    "tagline": "You Know, for Search"
}

安裝Kibana

安裝

docker run -it -d -e ELASTICSEARCH_URL=http://127.0.0.1:9200 --name kibana -p 5601:5601 kibana:5.6.11

注意:es 的 URL要寫容器內部的ip,查看容器內部的ip命令:

docker inspect --format '{{ .NetworkSettings.IPAddress }}' <container-ID> 
或 
docker inspect <container id> 

驗證

訪問 http://localhost:5601

image

 

安裝Elasticsearch-head

v5.x以後不支持plugin需要獨立部署

安裝

docker pull mobz/elasticsearch-head:5

docker run -d -p 9100:9100 docker.io/mobz/elasticsearch-head:5 

驗證

訪問 http://localhost:9100/

image

直接配置elasticsearch服務有跨域問題,所以加了nginx代理

nginx 服務配置

server {
        listen       9201;
        server_name  localhost;
    location / {
        add_header Access-Control-Allow-Origin *;
                add_header Access-Control-Allow-Headers Origin,X-Requested-With,Content-Type,Accept;
                add_header Access-Control-Allow-Methods GET,POST,PUT,PATCH,OPTIONS,DELETE;
            add_header Cache-Control no-store;
        proxy_pass http://127.0.0.1:9200;
    }
}

安裝中文分詞器

#進入容器內 docker attach 容器Id
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章