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 }}'  
或 
docker inspect  

验证

访问 http://localhost:5601

docker 安装 elasticsearch5.6 head kibana_第1张图片

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/

docker 安装 elasticsearch5.6 head kibana_第2张图片

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

 

你可能感兴趣的:(Golang)