五、elasticsearch、kibana环境搭建

一、软件准备

jdk-8u251-linux-x64.tar.gz
elasticsearch-6.8.18.tar.gz 下载
kibana-6.8.18-linux-x86_64.tar.gz
elasticsearch-analysis-ik-6.8.18.zip 插件下载地址

二、解压

[root@host125 install]#tar xvf jdk-8u251-linux-x64.tar.gz
[root@host125 install]#tar xvf elasticsearch-6.8.18.tar.gz
[root@host125 install]#tar xvf kibana-6.8.18-linux-x86_64.tar.gz
[root@host125 install]# ls
elasticsearch-6.8.18         jdk1.8.0_251                kibana-6.8.18-linux-x86_64
elasticsearch-6.8.18.tar.gz  jdk-8u251-linux-x64.tar.gz  kibana-6.8.18-linux-x86_64.tar.gz
[root@host125 install]# 

三、配置JAVA_HOME

[root@host125 install]# cd
[root@host125 ~]# vi .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
export JAVA_HOME=/opt/install/jdk1.8.0_251
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin

export PATH
[root@host125 ~]# source .bash_profile
[root@host125 ~]# java -version
java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)
[root@host125 ~]#

四、添加elasticsearch用户及用户组,更改文件夹属主

[root@host125 install]# groupadd es
[root@host125 install]# useradd es -g es
[root@host125 install]# chown -R es.es elasticsearch-6.8.18
[root@host125 install]# chown -R es.es kibana-6.8.18-linux-x86_64
[root@host125 install]# ls -l
总用量 517404
drwxr-xr-x.  8 es    es          143 728 12:09 elasticsearch-6.8.18
-rw-r--r--.  1 root  root  149147077 93 07:16 elasticsearch-6.8.18.tar.gz
drwxr-xr-x.  7 10143 10143       245 312 2020 jdk1.8.0_251
-rw-r--r--.  1 root  root  195132576 210 2021 jdk-8u251-linux-x64.tar.gz
drwxr-xr-x. 13 es    es          246 93 08:16 kibana-6.8.18-linux-x86_64
-rw-r--r--.  1 root  root  185537382 93 07:25 kibana-6.8.18-linux-x86_64.tar.gz
[root@host125 install]# 

五、配置elasticsearch

[root@host125 install]# cd elasticsearch-6.8.18/config/
[root@host125 config]# ls
elasticsearch.yml  jvm.options  log4j2.properties  role_mapping.yml  roles.yml  users  users_roles
[root@host125 config]# vi elasticsearch.yml
cluster.name: mall-cluster
network.host: 0.0.0.0
http.port: 9200
# The default list of hosts is ["127.0.0.1", "[::1]"]

六、启动elasticsearch

[root@host125 config]# cd ../bin/
[root@host125 bin]# su es
[es@host125 bin]$ ./elasticsearch
...
[2021-09-03T09:08:37,313][INFO ][o.e.t.TransportService   ] [Fp8FLyG] publish_address {192.168.220.125:9300}, bound_addresses {192.168.220.125:9300}
[2021-09-03T09:08:37,330][INFO ][o.e.b.BootstrapChecks    ] [Fp8FLyG] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [1] bootstrap checks failed
[1]: 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
执行/sbin/sysctl -p 立即生效

[es@host125 bin]$ su
密码:
[root@host125 bin]# vi /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
vm.max_map_count=262144
[root@host125 bin]#/sbin/sysctl -p
[root@host125 bin]# su es
[es@host125 bin]$ ./elasticsearch
.....
[2021-09-03T09:27:04,166][INFO ][o.e.h.n.Netty4HttpServerTransport] [Fp8FLyG] publish_address {192.168.220.125:9200}, bound_addresses {192.168.220.125:9200}
[2021-09-03T09:27:04,167][INFO ][o.e.n.Node               ] [Fp8FLyG] started
[2021-09-03T09:27:04,190][WARN ][o.e.x.s.a.s.m.NativeRoleMappingStore] [Fp8FLyG] Failed to clear cache for realms [[]]
[2021-09-03T09:27:04,264][INFO ][o.e.g.GatewayService     ] [Fp8FLyG] recovered [0] indices into cluster_state
[2021-09-03T09:27:04,508][INFO ][o.e.c.m.MetaDataIndexTemplateService] [Fp8FLyG] adding template [.watches] for index patterns [.watches*]
[2021-09-03T09:27:04,565][INFO ][o.e.c.m.MetaDataIndexTemplateService] [Fp8FLyG] adding template [.triggered_watches] for index patterns [.triggered_watches*]
[2021-09-03T09:27:04,634][INFO ][o.e.c.m.MetaDataIndexTemplateService] [Fp8FLyG] adding template [.watch-history-9] for index patterns [.watcher-history-9*]
[2021-09-03T09:27:04,668][INFO ][o.e.c.m.MetaDataIndexTemplateService] [Fp8FLyG] adding template [.monitoring-logstash] for index patterns [.monitoring-logstash-6-*]
[2021-09-03T09:27:04,711][INFO ][o.e.c.m.MetaDataIndexTemplateService] [Fp8FLyG] adding template [.monitoring-es] for index patterns [.monitoring-es-6-*]
[2021-09-03T09:27:04,758][INFO ][o.e.c.m.MetaDataIndexTemplateService] [Fp8FLyG] adding template [.monitoring-beats] for index patterns [.monitoring-beats-6-*]
[2021-09-03T09:27:04,781][INFO ][o.e.c.m.MetaDataIndexTemplateService] [Fp8FLyG] adding template [.monitoring-alerts] for index patterns [.monitoring-alerts-6]
[2021-09-03T09:27:04,806][INFO ][o.e.c.m.MetaDataIndexTemplateService] [Fp8FLyG] adding template [.monitoring-kibana] for index patterns [.monitoring-kibana-6-*]
[2021-09-03T09:27:04,935][INFO ][o.e.l.LicenseService     ] [Fp8FLyG] license [5cb14457-abea-43b9-968c-96009a5e7398] mode [basic] - valid

新开一个窗口,验证是否启动成功

[root@host125 ~]# curl 'http://192.168.220.125:9200/?pretty'
{
  "name" : "Fp8FLyG",
  "cluster_name" : "mall-cluster",
  "cluster_uuid" : "swTJhPd9Rgm9BcdNcIdPUg",
  "version" : {
    "number" : "6.8.18",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "aca2329",
    "build_date" : "2021-07-28T16:06:05.232873Z",
    "build_snapshot" : false,
    "lucene_version" : "7.7.3",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}
[root@host125 ~]#

七、配置kibana并启动

[es@host125 root]$ cd /opt/install/kibana-6.8.18-linux-x86_64/config/
[es@host125 config]$ vi kibana.yml 
#仅修改这一项
server.host: 0.0.0.0
[es@host125 config]$ ../bin/kibana
  ...
  log   [13:53:28.688] [info][status][plugin:reporting@6.8.18] Status changed from uninitialized to green - Ready
  log   [13:53:28.852] [info][task_manager] Installing .kibana_task_manager index template version: 6081899.
  log   [13:53:28.997] [info][task_manager] Installed .kibana_task_manager index template: version 6081899 (API version 1)
  log   [13:53:30.444] [info][migrations] Creating index .kibana_1.
  log   [13:53:30.613] [info][migrations] Pointing alias .kibana to .kibana_1.
  log   [13:53:30.667] [info][migrations] Finished in 223ms.
  log   [13:53:30.669] [info][listening] Server running at http://0.0.0.0:5601
  log   [13:53:30.862] [info][status][plugin:spaces@6.8.18] Status changed from yellow to green - Ready

打开浏览器,验证是否启动成功
在这里插入图片描述

八、安装ik分词器插件

插件下载地址 https://github.com/medcl/elasticsearch-analysis-ik,选择适合自己的版本下载

[root@host125 plugins]# pwd
/opt/install/elasticsearch-6.8.18/plugins
[root@host125 plugins]# ls
elasticsearch-analysis-ik-6.8.18.zip
[root@host125 plugins]# mkdir ik
[root@host125 plugins]# unzip elasticsearch-analysis-ik-6.8.18.zip -d ik
Archive:  elasticsearch-analysis-ik-6.8.18.zip
  inflating: ik/elasticsearch-analysis-ik-6.8.18.jar  
  inflating: ik/httpclient-4.5.2.jar  
  inflating: ik/httpcore-4.4.4.jar   
  inflating: ik/commons-logging-1.2.jar  
  inflating: ik/commons-codec-1.9.jar  
   creating: ik/config/
  inflating: ik/config/extra_stopword.dic  
  inflating: ik/config/extra_single_word.dic  
  inflating: ik/config/main.dic      
  inflating: ik/config/surname.dic   
  inflating: ik/config/quantifier.dic  
  inflating: ik/config/preposition.dic  
  inflating: ik/config/extra_single_word_full.dic  
  inflating: ik/config/IKAnalyzer.cfg.xml  
  inflating: ik/config/suffix.dic    
  inflating: ik/config/stopword.dic  
  inflating: ik/config/extra_single_word_low_freq.dic  
  inflating: ik/config/extra_main.dic  
  inflating: ik/plugin-descriptor.properties  
  inflating: ik/plugin-security.policy  
[root@host125 plugins]# rm -f elasticsearch-analysis-ik-6.8.18.zip

重启elasticsearch

验证
使用标准分词器效果
在这里插入图片描述
使用ik分词器效果
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值