#!/bin/bash
# 使用docker安装elasticsearch
# 拉取镜像(项目使用版本为6.5.0)
docker pull elasticsearch:6.5.0
# 启动镜像
docker run -d --restart=always --name elasticsearch -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -p 9200:9200 -p 9300:9300 elasticsearch:6.5.0
# 测试 访问9200端口
http://192.168.1.137:9200/
# 如果启动失败查看日志
docker logs -f elasticsearch
# 报错max_map_count的值太小
# ERROR: max virtual memory areas vm.max_map_count [65530] is too low
# 解决
cat /proc/sys/vm/max_map_count
# 输出 65530
sudo sysctl -w vm.max_map_count=262144
# 输出 sudo sysctl -w vm.max_map_count=262144
# 参考
# https://blog.csdn.net/qq_41754409/article/details/94134747
# 修改elasticsearch配置
docker exec -it elasticsearch bash
vi /usr/share/elasticsearch/config/elasticsearch.yml
# 集群名称
cluster.name: "dataxxx-elasticsearch"
# 可以访问的ip
network.host: 0.0.0.0
# 本节点名称
node.name: master
# 是否master节点
node.master: true
# 是否存储数据
node.data: true
# head插件设置
http.cors.enabled: true
http.cors.allow-origin: "*"
http.port: 9200
transport.tcp.port: 9300
#/usr/share/elasticsearch/config/elasticsearch.yml 配置
################################
cluster.name: "dataxxx-elasticsearch"
network.host: 0.0.0.0
node.name: master
node.master: true
node.data: true
http.cors.enabled: true
http.cors.allow-origin: "*"
http.port: 9200
transport.tcp.port: 9300
##################################
# 重启elasticsearch
docker restart elasticsearch
# 使用docker安装es可视化工具elasticsearch-head
# 拉取镜像
docker pull mobz/elasticsearch-head:5
docker pull docker.io/mobz/elasticsearch-head:5 ##比较慢
# 起动镜像
docker run -d --restart=always -p 9100:9100 docker.io/mobz/elasticsearch-head:5
##配置监听
##进入容器
vim /usr/src/app/Gruntfile.js
connect: {
server: {
options: {
hostname: '0.0.0.0', ##添加
port: 9100,
base: '.',
keepalive: true
}
#测试 访问9100端口
http://192.168.1.1x:9100/ 输入elasticsearch 的IP和端口进行连接
https://www.jianshu.com/p/503dd8f052d0
https://blog.csdn.net/cb2474600377/article/details/78181912
https://blog.csdn.net/jlh21/article/details/78319947