介绍在docker中的配置,单机安装es
docker 安装..过
安装官方的镜像地址
docker pull docker.elastic.co/elasticsearch/elasticsearch:6.2.3
运行,自带了三个容器,单机的可以删的剩一个
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.2.3 集群的所有节点都安装 这里如果要更改配置的时候,难免要重启服务,这样操作的办法就是重新建一个镜像,systemctl是没法用的,如果想systemctl restart xxx 错误提示 Failed to get D-Bus connection: Operation not permitted # 在创建docker容器时添加--privileged docker run --privileged -ti -e "container=docker" -v /sys/fs/cgroup:/sys/fs/cgroup centos /usr/sbin/init
配置,假设容器id d999
docker exec -it d999 bash
config 下,相关的配置文件主要有两个
es的配置文件
- vi elasticsearch.yml
1 | cluster.name: "docker-cluster" |
有一个中文版的es,版本旧了些,但是可以了解下 elasticsearch.yml 能做到什么控制.
jvm的配置文件
- vi jvm.options
指定内存大小,默认是1G1
2
3
4
5
6## You should always set the min and max JVM heap
## size to the same value. For example, to set
## the heap to 4 GB, set:
##
## -Xms4g
## -Xmx4g
插件安装和卸载
安装一个ik插件,分词用
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.3/elasticsearch-analysis-ik-6.2.3.zip ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.3/elasticsearch-analysis-ik-6.2.3.zip 据说也可以放到plugin 解压, 就好了 docker inspect -f '{{.Id}}' f8744 docker cp elasticsearch/ xxxxxxxxxxxxxxx:/usr/share/elasticsearch/plugins/ik
-
安装
./bin/elasticsearch-plugin install x-pack
卸载
第一步:停止Elasticsearch。 第二步:从Elasticsearch 删除X-Pack: bin/elasticsearch-plugin remove x-pack 第三步:重新启动Elasticsearch。 第四步:从Kibana中删除X-Pack: bin/kibana-plugin remove x-pack 第五步:重新启动Kibana。 第六步:从Logstash中删除X-Pack:bin/logstash-plugin remove x-pack 第七步:重新启动Logstash。
这三件事个改完后,可以重新建一个镜像
docker commit d999 es:1.0.0
安装elasticsearch-head,这个不是插件安装,当然也可以插件安装…也可以新建一个docker
这个是一个nodejs 的东西,到目录下,npm i ,然后npm run start 就可以了,如果需要docker,会生成一个dockerfile,就在目录下,
docker build -t eshead .
docker run -d -p 9100:9100 eshead
虽然在build 的时候有一堆错误,但是居然还能跑起来...
访问地址 open http://localhost:9200/_plugin/head/
如果使用x-pack,可能需要这个样子 http://localhost:9100/?auth_user=elastic&auth_password=changeme
运行用的是grunt ,在node_modules/grunt/bin下运行 ./grunt server 就可以了
./node_modules/grunt/bin/grunt server