栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Elasticsearch-核心篇(2)-下载安装,网络技术基础知识点整理

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Elasticsearch-核心篇(2)-下载安装,网络技术基础知识点整理

  1. 默认启动后将会占用9200和9300端口,如果有防火墙或者安全组需要运行通过
  • 9300:通信端口

  • 9200:http端口

  1. es7+要求JDK版本至少是11,所以当启动时可能报错,所以要么升级JDK版本,要么配置ES运行JDK版本
  • 在ES安装目录中已经自带了JDK11

  • 修改bin/elasticsearch-env,在此目录中配置JAVA_HOME路径为ES下的jdk路径即可

| 目录 | 含义 |

| — | — |

| bin | 可执行脚本目录 |

| config | 配置目录 |

| jdk | 内置JDK目录 |

| lib | 类库 |

| logs | 日志目录 |

| modules | 模块目录 |

| plugins | 插件目录 |

1.2 Windows安装


  1. 下载windows版本的elasticsearch
  • https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.8.0-windows-x86_64.zip
  1. 解压压缩包

  2. 运行bin/elasticsearch.bat即可启动

1.3 Docker安装


  1. 下载docker elasticsearch文件

docker pull elasticsearch:7.8.0

  1. 参考文档
  • https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker
  1. 启动es
  • 如果是单节点则必须加入**-e “discovery.type=single-node”**,否则需要指定节点名称

  • 具体可以参考es官方docker文档

docker run -d --name es -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -e “discovery.type=single-node”

  1. 启动结果

1.4 连接测试


  1. 浏览器:http://localhost:9200/?pretty

  2. Linux:

curl http://localhost:9200/?pretty

{

“name”: “tianxin”,

“cluster_name”: “elasticsearch”,

“cluster_uuid”: “aTt3P85JRhW85BmIUJWpjw”,

“version”: {

“number”: “7.8.0”,

“build_flavor”: “default”,

“build_type”: “tar”,

“build_hash”: “757314695644ea9a1dc2fecd26d1a43856725e65”,

“build_date”: “2020-06-14T19:35:50.234439Z”,

“build_snapshot”: false,

“lucene_version”: “8.5.1”,

“minimum_wire_compatibility_version”: “6.8.0”,

“minimum_index_compatibility_version”: “6.0.0-beta1”

},

“tagline”: “You Know, for Search”

}

二、Elasticsearch外网访问

=====================================================================================

  1. ES安装完成之后默认只能在本机进行访问,如果需要能通过外部访问,则需要配置外网访问

  2. 修改es目录下config/elasticsearch.yml文件,将network.host设置为机器ip

  • network.host:

  • 如果需要所有地址都能访问,则可以配置0.0.0.0

  • cluster.initial_master_nodes: [“node-1”]

  • 配置单节点启动

cluster.name: elasticsearch

node.name: node-1

network.host: 0.0.0.0

http.port: 9200

cluster.initial_master_nodes: [“node-1”]

http.cors.enabled: true

http.cors.allow-origin: “*”

  1. 配置完成后重启ES,然后通过外网访问

三、Elasticsearch插件安装

=====================================================================================

3.1 head插件安装


  1. 由于elasticsearch-head插件是由nodejs语言编写,所以安装elasticsearch-head前需要先安装nodejs和grunt

  2. 下载nodejs压缩包任意解压目录,然后配置环境变量

  • vim /etc/profile

  • 添加以下环境变量

  • source /etc/profile

export NODE_HOME=/opt/node

export PATH= P A T H : PATH: PATH:NODE_HOME/bin

  1. 查看node安装完成之后的版本

[root@tianxin node]# node -v

v14.15.4

  1. 安装grunt,直接使用npm安装即可

npm install -g grunt-cli

【一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义】

浏览器打开:qq.cn.hn/FTf 免费领取

[root@tianxin node]# npm install -g grunt-cli

npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated

npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated

/opt/node/bin/grunt -> /opt/node/lib/node_modules/grunt-cli/bin/grunt

  • grunt-cli@1.3.2

added 153 packages from 126 contributors in 31.658s

[root@tianxin node]# grunt --version

grunt-cli v1.3.2

  1. 在es安装目录下新建dashboard/head文件夹(随意为之),拉取elasticsearch-head到head文件夹中
  • 码云:https://gitee.com/tianxincoord/elasticsearch-head.git

  • GitHub:https://github.com/mobz/elasticsearch-head.git

git clone https://gitee.com/tianxincoord/elasticsearch-head.git

  1. 安装head插件
  • 可以安装淘宝镜像

npm install -g cnpm --registry=https://registry.npm.taobao.org

  • head插件安装
npm安装

cd elasticsearch-head/

npm install

npm run start

  • 淘宝安装
cnpm安装

cd elasticsearch-head/

cnpm install

cnpm run start

  1. 安装完成之后打开9100端口即可访问

  1. config/elasticsearch.yml需要配置允许跨域,否则无法连接

http.cors.enabled: true

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/509900.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号