软件架构师工具大全🔧

docker安装ES & Kibana

2018-02-01  本文已影响124人  孙成酱子说

安装Elasticsearch

安装

docker run -it --name elasticsearch -d -p 9200:9200 -p 9300:9300 -p 5601:5601 elasticsearch

官方的镜像的网络设置是允许外部访问的即network.host=0.0.0.0

如果要制定es配置可用通过-E{param=value}指定,或者通过-v "$PWD/config":/usr/share/elasticsearch/config 映射配置文件地址

-p 5601:5601 是kibana的端口地址 (我这里kibana的container共用elasticsearch的网络,所以这样设置)

验证

> 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 --network=container:elasticsearch kibana

--network 指定容器共享elasticsearch容器的网络栈 (使用了--network 就不能使用-p 来暴露端口)

验证

访问 http://localhost:5601

image

安装Elasticsearch-head

v5.x以后不支持plugin需要独立部署

安装

git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
npm run start

验证

访问 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;
    }
}

安装中文分词器

./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.0.0/elasticsearch-analysis-ik-6.0.0.zip
上一篇 下一篇

猜你喜欢

热点阅读