资讯详情

(ES1)ElasticSearch+Kibana+Elasticsearch-analysis-ik系统环境搭建

ElasticSearch简称ES,与传统数据库不同,传统数据库只能模糊匹配关键字,如搜索:java传统数据库只能与字段相匹配:java但是ES会先拆成java,架构,ES将检索包含这两个关键字的数据。

Kibana可以理解为传统数据库的客户端,如连接各种数据库DbVisualizer。

Elasticsearch-analysis-ik 应该是中国人开发的中文分词器。默认的英文分词器会检索每个单词,但是中文语境不需要拆得那么细。

本文主要介绍了这三个软件的安装。稍后将介绍Springboot如何和ElasticSearch集成。

环境已经建成了两天,各种各样的错误都被报告了。幸运的是,通过在线检查数据逐一解决。本文记录,供参考。

7.3.0版本自带jdk假如安装了jdk1.8,启动的时候报个错误没有安装jdk没关系。

Past Releases of Elastic Stack Software | Elastic

或者

wget https://mirrors.huaweicloud.com/elasticsearch/7.3.0/elasticsearch-7.3.0-linux-x86_64.tar.gz

因为elasticsearch不能使用root账号启动,

需要创建新用户 sudo adduser es,修改 es 用户密码:sudo passwd 123456

cd /usr/local mkdir elasticsearch cd elasticsearch 下载并安装当前文件夹 wget https://mirrors.huaweicloud.com/elasticsearch/7.3.0/elasticsearch-7.3.0-linux-x86_64.tar.gz 解压缩 tar -xzf elasticsearch-7.3.0-linux-x86_64.tar.gz # 复制三份目录作为三个节点,后面配置 ES 三个对应于集群 ES 实例 cp -R elasticsearch-7.3.0 es-7.3.0-node-1 cp -R elasticsearch-7.3.0 es-7.3.0-node-2 mv elasticsearch-7.3.0 es-7.3.0-node-3 # 因为以 root 用户无法启动 ES chown -R es es-7.3.0*

vi /usr/local/elasticsearch/es-7.3.0-node-1/config/elasticsearch.yml

#es-7.3.0-node-1 cluster.name: search-7.3.2 node.name: node-1 node.master: true node.data: false node.ingest: false network.host: 0.0.0.0 http.port: 9200 transport.port: 9300 discovery.seed_hosts: ["118.118.133.73:9300","118.118.133.73:9301","118.118.133.73:9302"] cluster.initial_master_nodes: ["node-1"] bootstrap.memory_lock: false bootstrap.system_call_filter: false

vi /usr/local/elasticsearch/es-7.3.0-node-2/config/elasticsearch.yml

#es-7.3.0-node-2 cluster.name: search-7.3.2 node.name: node-2 node.master: true node.data: true node.ingest: false network.host: 0.0.0.0 http.port: 9201 transport.port: 9301 discovery.seed_hosts: ["118.118.133.73:9300","118.118.133.73:9301","118.118.133.73:9302"] bootstrap.memory_lock: false bootstrap.system_call_filter: false

vi /usr/local/elasticsearch/es-7.3.0-node-3/config/elasticsearch.yml

# es-7.3.0-node-3 cluster.name: search-7.3.2 node.name: node-3 node.master: true node.data: true node.ingest: false network.host: 0.0.0.0 http.port: 9202 transport.port: 9302 discovery.seed_hosts: ["118.118.133.73:9300","118.118.133.73:9301","118.118.133.73:9302"] bootstrap.system_call_filter: false

https://github.com/medcl/elasticsearch-analysis-ik

安装时需要和谐elasticsearch版本保持一致,也需要7.3.0的

每个节点的es plugins下面新建一个ik文件夹,然后对应的文件夹ik下载后解压当前文件夹

/usr/local/elasticsearch/es-7.3.0-node-1/plugins/ik

/usr/local/elasticsearch/es-7.3.0-node-2/plugins/ik

/usr/local/elasticsearch/es-7.3.0-node-3/plugins/ik

wgethttps://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.3.0/elasticsearch-analysis-ik-7.3.0.zip

unzipelasticsearch-analysis-ik-7.3.0.zip

./elasticsearch -p /tmp/elasticsearch-pid -d 查询进程号 cat /tmp/elasticsearch-pid && echo

或者

ps -ef|grepelasticsearch 关闭当前进程 kill -9 查询出来的pid

查看集群

http://118.118.133.73:9200/_cat/nodes

http://118.118.133.73:9200 会显示

{ "name" : "node-1", "cluster_name" : "search-7.3.2", "cluster_uuid" : "sniRZF0-Qwi3J-I9U3rc_g", "version" : { "number" : "7.3.0", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "de777fa", "build_date" : "2019-07-24T18:30:11.767338Z", "build_snapshot" : false, "lucene_version" : "8.1.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" } 另外两个9201,9202显示正常表示部署,

各种报错一般都会出现。

我在这里总结了各种报错。供参考:

 异常1

max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]

在 /etc/security/limits.conf 文件末尾添加

* soft nofile 65535

* hard nofile 65535

异常2

max number of threads [3795] for user [elastic] is too low, increase to at least [4096]

在 /etc/security/limits.conf 文件末尾添加

* soft nproc  4096

* hard nproc  4096

异常3

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

在 /etc/sysctl.conf文件末尾添加

 vm.max_map_count=262144  

异常4

the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

添加elasticsearch.yml配置

cluster.initial_master_nodes: ["node-1"]

异常5

max number of threads [1024] for user [lishang] likely too low

解决办法:

1.切换至root用户

su root

2. 修改limits.d目录下的配置文件:

vi /etc/security/limits.d/90-nproc.conf

改成如下

*          soft    nproc     4096

root       soft    nproc     unlimited

异常6

system call filters failed to install; check the logs and fix your configuration or disable system c

在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面: bootstrap.memory_lock: false bootstrap.system_call_filter: false

异常7

future versions of Elasticsearch will require Java 11; your Java version from [/usr/java/jdk1.8.0_171/jre] does not meet this requirement

不要紧,es自带了jdk会使用自带的

异常8

org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root

需要创建一个新用户

sudo adduser es,修改 es 用户的密码:sudo passwd 123456

异常9:

es用户打开elasticsearch的时候,报错

java.nio.file.AccessDeniedException: /usr/local/elasticsearch/es-7.3.0-node-2/config/elasticsearch.keystore

通过 root账户转让所有权限

chown -R  es /usr/local/elasticsearch/es-7.3.0-node-2

异常10:

seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER compiled in

在config 目录下

vim elasticsearch.yml

在最后添加

bootstrap.system_call_filter: false

改完这些重启Linux,启动Elasticsearch即可其他ip访问

Download Kibana Free | Get Started Now | Elastic

kibana也需要安装对应的版本 7.3.0的 https://artifacts.elastic.co/downloads/kibana/kibana-7.3.0-linux-x86_64.tar.gz

在/usr/local下新建一个kibana的文件夹,同样不要使用root账户启动,

将kibana下载后解压的kibana文件夹

vi /usr/local/kibana/kibana-7.3.0-linux-x86_64/config/kibana.yml

server.port: 5601 #这个不一定需要配置  server.host: "0.0.0.0" #配置IP 建议设置0.0.0.0,方便访问 elasticsearch.hosts: ["http://10.118.133.73:9200"] i18n.locale: "zh-CN" #默认是英文,这个是中文设置  

ps -ef|grep kibana ps -ef|grep 5601 都找不到 尝试 使用 fuser -n tcp 5601 kill -9 端口  ps -ef|grep node   或 netstat -anltp|grep 5601 启动查看是否报错即可 ./kibana 没有报错改成后台启动:

nohup ../bin/kibana &

打开首页 http://118.118.133.73:5601/

能正常打开说明部署成功。

标签: 贴片恢复二极管es1jsod

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

 锐单商城 - 一站式电子元器件采购平台  

 深圳锐单电子有限公司