es笔记-mac版本安装elasticsearch kbn ik elasticsearch-head

编程入门 行业动态 更新时间:2024-10-26 01:32:27

一.前置条件 java

省略java安装 ,用命令检查一下java -version

二. elasticsearch

方法一:多版本(elasticsearch-7.13.4)

  1. 下载官方安装包https://www.elastic.co/cn/downloads/past-releases#elasticsearch

  2. 解压下载的安装包
    tar -zxvf elasticsearch-7.13.4-darwin-x86_64.tar.gz

  3. 启动
    ./bin/elasticsearch

  4. 浏览器输入http://127.0.0.1:9200/ 或者curl一下

elsticsearch curl

	集群健康
	curl -XGET 'http://localhost:9200/_cluster/health?pretty'
	查看集群状态
   curl -XGET "http://localhost:9200/_cat/nodes?v"
  查看所有索引
   curl -XGET "http://localhost:9200/_cat/indices"

方法二:默认版本(不推荐,无法指定特定版本)

	1. 安装:
	brew install elasticsearch #安装 默认7.10.2版本
	brew install elasticsearch@7  默认7.10.2版本
	brew install elasticsearch@6 #安装指定版本号6.x默认版本。不支持到具体版本
	2. 查看和启动
	brew info elasticsearch # 查看es信息 
	brew services start elasticsearch # 启动
	3. 其他
	brew uninstall elasticsearch  # 卸载
	brew uninstall --force elasticsearch
	brew uninstall --force elasticsearch@6
	brew upgrade elasticsearch@7

三. Kibana

  1. 下载zip
    https://www.elastic.co/cn/downloads/past-releases#kibana

  2. 解压
    tar -zxvf kibana-7.13.4-darwin-x86_64.tar.gz

  3. 启动
    ./bin/kibana

  4. 验证
    浏览器输入 http://127.0.0.1:5601/app/home#/

  5. 修改配置国际化为中文,默认是英文的。
    kibana/config/kibana.yml

i18n.locale: "zh-CN"
  1. 连上服务器es集群
    kibana/config/kibana.yml
#远程访问kibana地址
server.host: "0.0.0.0"
# 要用于所有查询的Elasticsearch实例的URL。可以配置多个ES
elasticsearch.hosts: ["http://localhost:9200","http://nas.**:9*"]
  1. 重启kibana
    ps -ef|grep kibana
    kill -9 ***
    nohup ./bin/kibana &
    ps -ef|grep kibana

8, 浏览器输入,切换为中文页面
http://127.0.0.1:5601/

四. ik分词器

  1. 下载zip包
    注意:IK的版本一定要与elasticsearch的版本一致,否则elasticsearch无法启动。
    https://github/medcl/elasticsearch-analysis-ik/releases/tag/v7.13.4

  2. 解压到elasticsearch的plugins

mkdir elasticsearch-7.13.4/plugins/ik
tar -zxvf elasticsearch-analysis-ik-7.13.4.zip -C elasticsearch-7.13.4/plugins/ik
  1. 重启es 和 kbn
    ./elasticsearch-7.13.4/bin/elasticsearch
    ./kibana-7.13.4-darwin-x86_64/bin/kibana

  2. 验证分词器
    不使用分词效果:

get /_analyze
	get /_analyze
	{
	  "text": "中华民族 Chinese nation"
	}

{
  "tokens" : [
    {
      "token" : "中",
      "start_offset" : 0,
      "end_offset" : 1,
      "type" : "<IDEOGRAPHIC>",
      "position" : 0
    },
    {
      "token" : "华",
      "start_offset" : 1,
      "end_offset" : 2,
      "type" : "<IDEOGRAPHIC>",
      "position" : 1
    },
    {
      "token" : "民",
      "start_offset" : 2,
      "end_offset" : 3,
      "type" : "<IDEOGRAPHIC>",
      "position" : 2
    },
    {
      "token" : "族",
      "start_offset" : 3,
      "end_offset" : 4,
      "type" : "<IDEOGRAPHIC>",
      "position" : 3
    },
    {
      "token" : "chinese",
      "start_offset" : 5,
      "end_offset" : 12,
      "type" : "<ALPHANUM>",
      "position" : 4
    },
    {
      "token" : "nation",
      "start_offset" : 13,
      "end_offset" : 19,
      "type" : "<ALPHANUM>",
      "position" : 5
    }
  ]
}

使用分词效果:
ik_smart称为智能分词,网上还有别的称呼:最少切分,最粗粒度划分。
ik_max_word称为最细粒度划分。

get /_analyze
	get /_analyze
	{
	 "analyzer":"ik_smart",
	  "text": "中华民族 Chinese nation"
	}
{
  "tokens" : [
    {
      "token" : "中华民族",
      "start_offset" : 0,
      "end_offset" : 4,
      "type" : "CN_WORD",
      "position" : 0
    },
    {
      "token" : "chinese",
      "start_offset" : 5,
      "end_offset" : 12,
      "type" : "ENGLISH",
      "position" : 1
    },
    {
      "token" : "nation",
      "start_offset" : 13,
      "end_offset" : 19,
      "type" : "ENGLISH",
      "position" : 2
    }
  ]
}
get /_analyze
	{
	 "analyzer":"ik_max_word",
	  "text": "中华民族 Chinese nation"
	}

{
  "tokens" : [
    {
      "token" : "中华民族",
      "start_offset" : 0,
      "end_offset" : 4,
      "type" : "CN_WORD",
      "position" : 0
    },
    {
      "token" : "中华",
      "start_offset" : 0,
      "end_offset" : 2,
      "type" : "CN_WORD",
      "position" : 1
    },
    {
      "token" : "民族",
      "start_offset" : 2,
      "end_offset" : 4,
      "type" : "CN_WORD",
      "position" : 2
    },
    {
      "token" : "chinese",
      "start_offset" : 5,
      "end_offset" : 12,
      "type" : "ENGLISH",
      "position" : 3
    },
    {
      "token" : "nation",
      "start_offset" : 13,
      "end_offset" : 19,
      "type" : "ENGLISH",
      "position" : 4
    }
  ]
}

五.elasticsearch-head插件

  1. 需要依赖项nodejs和git
brew install node 
查看是否安装成功 
git --version
node -v 
出现依赖缺失ca-certificates, Error: No such file or directory @ rb_sysopen *** ca-certificates-2022-03-29.all.bottle.tar.gz
brew install ca-certificates
  1. 下载插件并安装
    https://github/mobz/elasticsearch-head.git

  2. zip解压
    tar -zxvf elasticsearch-head-master.zip

  3. 修改配置, 9200 和 9100有跨越问题 ,提示 http://localhost:9100/ 集群健康值: 未连接
    (1)增加hostname:“*”,允许所有的域名通过.
    /elasticsearch-head-master/Gruntfile.js

	connect: {
			server: {
				options: {
					hostname:"*",
					port: 9100,
					base: '.',
					keepalive: true
				}
			}
		}

(2)配置多个es集群.
/elasticsearch-head-master/_site/app.js

	this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200" || || "http://nas.***:9*";

(3)修改es的跨域配置,vim elasticsearch.yml

	http.cors.enabled: true 
	http.cors.allow-origin: "*"
  1. 安装到node_modules目录
    cd elasticsearch-head-master
    npm install

  2. 启动服务,停止程序 执行命令注意位置,必须在有npm的package.json
    npm run start
    nohup npm start &
    ps -ef | grep node
    ps -ef | grep npm
    Kill -9 *

  3. 输入浏览器 http://localhost:9100/
    (1)本地es:

    (2)远端es:

更多推荐

es笔记-mac版本安装elasticsearch kbn ik elasticsearch-head

本文发布于:2023-06-14 00:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1417632.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:版本   笔记   mac   es   head

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!