Docker安装ElasticSearch7.8.0

Docker安装ElasticSearch7.8.0

  • 1:docker可能会拉取不了es,此时可以配置一个很好用的镜像源(daocloud),下载非常快:
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
sudo systemctl restart docker
  • 2:创建挂载目录:
mkdir -p /usr/local/docker/elasticsearch/config
mkdir -p /usr/local/docker/elasticsearch/data

chmod 777 /usr/local/docker/elasticsearch/config
chmod 777 /usr/local/docker/elasticsearch/data
  • 3:编写es配置文件:
vi /usr/local/docker/elasticsearch/config/elasticsearch.yml

内容如下:

cluster.name: “es-cluser01”
node.name: es-node1
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.initial_master_nodes: ["es-node1"] #这个一定要填,集群默认的主节点名称(node.name)
  • 4:永久调大虚拟机内存:(不然启动不了)
vim /etc/sysctl.conf

在最后面添加的内容如下:

vm.max_map_count=262144
  • 5:刷新配置:
sysctl -p
  • 6:运行elasticsearch容器:(访问该服务器ip:9200即可访问)
    • ES_JAVA_OPTS两个Xms的值都要一致,不然会报错。(这个很坑!!)
docker run --name elasticsearch \
-p 9200:9200 \
-p 9300:9300 \
-e “discovery.type=single-node” \
-e ES_JAVA_OPTS="-Xms256m -Xmx256m" \
-v /usr/local/docker/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /usr/local/docker/elasticsearch/data:/usr/share/elasticsearch/data \
-v /usr/local/docker/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.8.0

在这里插入图片描述

Docker安装elasticsearch-head5⭐

  • 1:拉取镜像:
docker pull mobz/elasticsearch-head:5
  • 2:启动镜像:
docker run -d -p 9100:9100 --name=elasticsearch-head mobz/elasticsearch-head:5
  • 3:进入容器:
docker exec -it elasticsearch-head /bin/bash
解决es-head 406错误问题
  • 方式1:直接修改容器内文件
  • 方式2:使用容器数据卷的方式(推荐。可以使用容器数据卷的方式修改vendor.js 文件⭐)
直接修改容器内文件(需要下载vim命令)
  • 1:
mv /etc/apt/sources.list /etc/apt/sources.list.bak
    echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib" >> /etc/apt/sources.list
    echo "deb http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list
    echo "deb-src http://mirrors.163.com/debian/ jessie main non-free contrib" >>/etc/apt/sources.list
    echo "deb-src http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list
    
  • 2:更新源
apt update
  • 3:安装vim:(按Y即可)
apt-get install vim
  • 4:修改vendor.js 文件:
vim _site/vendor.js 

修改1:在6886行,把contentType: "application/x-www-form-urlencoded,修改成contentType: “application/json;charset=UTF-8”

修改2:7573行 var inspectData = s.contentType === “application/x-www-form-urlencoded” &&

修改成var inspectData = s.contentType === “application/json;charset=UTF-8” &&

  • 5:重启容器:
docker restart elasticsearch-head

Docker安装kibana(注意:kibana的版本要和elasticsearch的版本相同才行)⭐

  • 1:拉取镜像:(注意:kibana的版本要和elasticsearch的版本相同才行)
docker pull kibana:7.8.0
  • 2:编辑配置文件:
mkdir -p /usr/local/kibana/config/
vi /usr/local/kibana/config/kibana.yml

内容如下:(修改elasticsearch.hosts为你的elasticsearch地址列表)

server.name: kibana
server.host: "0"
elasticsearch.hosts: [ "http://192.168.184.201:9200" ]
xpack.monitoring.ui.container.elasticsearch.enabled: true
  • 3:启动:
docker run -d \
  --name=kibana \
  --restart=always \
  -p 5601:5601 \
  -v /usr/local/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml \
  kibana:7.8.0
  • 4:访问kibana:(服务器ip:5601)

在这里插入图片描述
在这里插入图片描述

你可能感兴趣的:(docker,jenkins,运维)