Elasticserach7.17.5 docker 安装调试过程

第一步 docker pull elasticsearch:7.17.5

在宿主机常见目录和文件,然后启动时关联

yml文件配置

cluster.name: "docker-cluster"
network.host: 0.0.0.0
#network.host: 192.168.0.5
#http.port: 9200
#添加配置 
http.cors.enabled: true
http.cors.allow-origin: "*"
#http.cors.allow-headers: Authorization
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE 
http.cors.allow-headers: "X-Requested-With,X-Auth-Token,Content-Type, Content-Length, Authorization" 
discovery.zen.minimum_master_nodes: 1
#开启安全选项
xpack.security.enabled: true

#配置单节点模式
discovery.type: single-node

启动命令:

docker run --restart=always -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -e "discovery.type=single-node" -v /Users/。。。/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /Users/。。。/elasticsearch/data:/usr/share/elasticsearch/data -v /Users/。。。/elasticsearch/plugins:/usr/share/elasticsearch/plugins --name es_7 -d elasticsearch:7.17.5

设置elastic密码

./bin/elasticsearch-setup-passwords interactive

安装分词器

./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.5/elasticsearch-analysis-ik-7.17.5.zip

安装kibana

docker pull kibana:7.17.5

 增加配置文件

mkdir -p /data/elk7/kibana/config/
vi /data/elk7/kibana/config/kibana.yml
#
# ** THIS IS AN AUTO-GENERATED FILE **
#
 
# Default Kibana configuration for docker target
server.name: kibana
server.host: "0"
elasticsearch.hosts: ["http://172.17.0.2:9200"] //这里的ip时elastic的ip
xpack.monitoring.ui.container.elasticsearch.enabled: true
 
#使用初始用户kibana
elasticsearch.username: "kibana"
elasticsearch.password: "123456"
#汉化
i18n.locale: "zh-CN"

启动命令

docker run -d --name=kibana7 --restart=always -p 5601:5601 -v /Users/。。。/elasticsearch/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml kibana:7.17.5

elasticsearch-head 安装

//https://github.com/mobz/elasticsearch-head

docker run -p 9100:9100 mobz/elasticsearch-head:5

解决406问题
进入_site目录,修改vendor.js文件。如果提示vim不存在,
安装vim:apt-get update && apt-get install vim
再编辑

cd _site
vim vendor.js
# 6886行上下 /contentType: "application/x-www-form-urlencoded 改成 
contentType: "application/json;charset=UTF-8" 
# 7574行上下 var inspectData = s.contentType ==`= "application/x-www-form-urlencoded" &&` 改成 
var inspectData = s.contentType === "application/json;charset=UTF-8" &&
# 保存退出

你可能感兴趣的:(docker,elasticsearch,容器)