一: 安装ElasticSearch(centos7)

1 下载es

在这里提供两种下载方法:
官网下载:http://www.elasticsearch.cn/ 百度网盘:
链接https://pan.baidu.com/s/171fHZqeVplCapUv8oYF6BQ 提取码:cbmv

2 将es上传到centos上

上传方式多种多样,我这里就使用CRT进行上传(alt+P),就不详细说步骤了,直接放截图

es 数据压缩 es文件压缩器下载_centos

[root@localhost ~]# ls
anaconda-ks.cfg  docker-files                             kafka            公共  图片  音乐
apisix           elasticsearch-7.6.1-linux-x86_64.tar.gz  test_centos.tar  模板  文档  桌面
data             initial-setup-ks.cfg                     testjar          视频  下载
[root@localhost ~]#

3 解压到/opt目录

[root@localhost ~]# ls
anaconda-ks.cfg  docker-files                             kafka            公共  图片  音乐
apisix           elasticsearch-7.6.1-linux-x86_64.tar.gz  test_centos.tar  模板  文档  桌面
data             initial-setup-ks.cfg                     testjar          视频  下载
[root@localhost ~]# tar -zxvf elasticsearch-7.6.1-linux-x86_64.tar.gz -C /opt
[root@localhost opt]# ls
containerd  elasticsearch-7.6.1  rh
[root@localhost opt]#

4 创建普通用户

因为安全问题,Elasticsearch不允许root用户直接运行,所以要创建新用户,在root用户中创建新用户,执行如下命令:

user add yytest	#新增yytest用户
passwd yytest	#为yytest用户设嚣密码
[root@localhost opt]# useradd yytest
[root@localhost opt]# passwd yytest
更改用户 yytest 的密码 。
新的 密码:
无效的密码: 密码包含用户名在某些地方
重新输入新的 密码:
抱歉,密码不匹配。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@localhost opt]#

5 给新用户授权

chown -R yytest:yytest /opt/elasticsearch-7.4.0 #文件夹所有者
[root@localhost opt]# ll
总用量 0
drwx--x--x. 4 root root  28 12月 17 15:13 containerd
drwxr-xr-x. 9 root root 155 2月  29 2020 elasticsearch-7.6.1
drwxr-xr-x. 2 root root   6 10月 31 2018 rh
[root@localhost opt]# 
[root@localhost opt]# chown -R yytest:yytest /opt/elasticsearch-7.6.1/
[root@localhost opt]# ll
总用量 0
drwx--x--x. 4 root   root    28 12月 17 15:13 containerd
drwxr-xr-x. 9 yytest yytest 155 2月  29 2020 elasticsearch-7.6.1
drwxr-xr-x. 2 root   root     6 10月 31 2018 rh
[root@localhost opt]# cd elasticsearch-7.6.1/
[root@localhost elasticsearch-7.6.1]# ll
总用量 548
drwxr-xr-x.  2 yytest yytest   4096 2月  29 2020 bin
drwxr-xr-x.  2 yytest yytest    148 12月 26 11:53 config
drwxr-xr-x.  9 yytest yytest    107 2月  29 2020 jdk
drwxr-xr-x.  3 yytest yytest   4096 2月  29 2020 lib
-rw-r--r--.  1 yytest yytest  13675 2月  29 2020 LICENSE.txt
drwxr-xr-x.  2 yytest yytest      6 2月  29 2020 logs
drwxr-xr-x. 38 yytest yytest   4096 2月  29 2020 modules
-rw-r--r--.  1 yytest yytest 523209 2月  29 2020 NOTICE.txt
drwxr-xr-x.  2 yytest yytest      6 2月  29 2020 plugins
-rw-r--r--.  1 yytest yytest   8164 2月  29 2020 README.asciidoc
[root@localhost elasticsearch-7.6.1]# cd l
-bash: cd: l: 没有那个文件或目录
[root@localhost elasticsearch-7.6.1]# cd logs/
[root@localhost logs]# ll
总用量 0
[root@localhost logs]#

6 修改配置文件

(1)修改elasticsearch.yml文件

[root@localhost opt]# vim /opt/elasticsearch-7.6.1/config/elasticsearch.yml
#action.destructive_requires_name: true
cluster.name: my-application
node.name: node-1
network.host: 0.0.0.0 
http.port: 9200
cluster.initial_master_nodes: ["node-1"]

es 数据压缩 es文件压缩器下载_centos_02

cluster.name:配置elasticsearch的集群名称,默认是elasticsearch。建议修改成一个有意义的名称

node.name:节点名,elasticsearch会默认随机指定一个名字,建议指定一个有意义的名称,方便管理

network.host:设置为0.0.0.0允许外网访问

http.port: Elasticsearch的http访问端口

cluster.initial_master_nodes:初始化新的集群时需要此配置来选举master

(2)修改配置文件

新创建的itheima用户最大可创建文件数太小,最大虚拟内存太小,切换到root用户,编辑下列配置文件,添加类似如下内容

#切换到root用户
su root

#1.===最大可创建文件数太小=======
vim /etc/security/limits.conf
#在文件末尾中增加下面内容
yytest soft nofile 65536
yytest hard nofile 65536

#=====
vim /etc/security/limits.d/20-nproc.conf
#在文件末尾中增加下面内容
yytest  soft nofi1e 65536
yytest hard nofile 65536
* hard nproc 4096
#注:*代表Linux所有用户名称

#2.===最大虚拟内存太小=====
vim /etc/sysctl.conf
#在文件中增加下面内容
vm.max_map_count=655360
#重新加载,输入下面命令:
sysctl -p

测试代码:

[root@localhost logs]# su root
[root@localhost logs]# vim /etc/security/limits.conf
# /etc/security/limits.conf
#
#This file sets the resource limits for the users logged in via PAM.
#It does not affect resource limits of the system services.
#
#Also note that configuration files in /etc/security/limits.d directory,
#which are read in alphabetical order, override the settings in this
#file in case the domain is the same or more specific.
#That means for example that setting a limit for wildcard domain here
#can be overriden with a wildcard setting in a config file in the
#subdirectory, but a user specific setting here can be overriden only
#with a user specific setting in the subdirectory.
#
#Each line describes a limit for a user in the form:
#
#<domain>        <type>  <item>  <value>
#
#Where:
#<domain> can be:
#        - a user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#        - the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#
#<type> can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
#<item> can be one of the following:
#        - core - limits the core file size (KB)
#        - data - max data size (KB)
#        - fsize - maximum filesize (KB)
#        - memlock - max locked-in-memory address space (KB)
#        - nofile - max number of open file descriptors
#        - rss - max resident set size (KB)
#        - stack - max stack size (KB)
#        - cpu - max CPU time (MIN)
#        - nproc - max number of processes
#        - as - address space limit (KB)
#        - maxlogins - max number of logins for this user
#        - maxsyslogins - max number of logins on the system
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#        - sigpending - max number of pending signals
#        - msgqueue - max memory used by POSIX message queues (bytes)
#        - nice - max nice priority allowed to raise to values: [-20, 19]
#        - rtprio - max realtime priority
#
#<domain>      <type>  <item>         <value>
#

#*               soft    core            0
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4

# End of file
#

yytest soft nofile 65536
yytest hard nofile 65536
"/etc/security/limits.conf" 65L, 2475C 已写入                                      
[root@localhost logs]# 
[root@localhost logs]# vim /etc/security/limits.d/20-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     4096
root       soft    nproc     unlimited
yytest     soft    nofi1e    65536
yytest     hard    nofile    65536
*          hard    nproc     4096
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/security/limits.d/20-nproc.conf" 9L, 295C 已写入                             
[root@localhost logs]#
[root@localhost logs]# vim /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=655360
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/sysctl.conf" 12L, 495C 已写入                                                
[root@localhost logs]# sysctl -p
vm.max_map_count = 655360
[root@localhost logs]#

7 启动ES

# 切换用户
[root@localhost logs]# su yytest
[yytest@localhost logs]$ cd /opt/elasticsearch-7.6.1/
# 进入bin目录启动
[yytest@localhost elasticsearch-7.6.1]$ cd bin/
[yytest@localhost bin]$ ls
elasticsearch                elasticsearch-keystore         elasticsearch-sql-cli
elasticsearch-certgen        elasticsearch-migrate          elasticsearch-sql-cli-7.6.1.jar
elasticsearch-certutil       elasticsearch-node             elasticsearch-syskeygen
elasticsearch-cli            elasticsearch-plugin           elasticsearch-users
elasticsearch-croneval       elasticsearch-saml-metadata    x-pack-env
elasticsearch-env            elasticsearch-setup-passwords  x-pack-security-env
elasticsearch-env-from-file  elasticsearch-shard            x-pack-watcher-env
# 启动es
[yytest@localhost bin]$ ./elasticsearch

启动成功,如下图:

es 数据压缩 es文件压缩器下载_vim_03

8 访问es

如果报错的话,有可能是没有开启端口(也可以直接关闭防火墙):具体的命令看这篇博客

es 数据压缩 es文件压缩器下载_es 数据压缩_04

二: es辅助插件安装

在上面的百度链接中已经将这两个程序放到里面了,感兴趣可以下载安装

1.1 postman安装

它是一个专门测试API的工具,Postman提供功能强大的Web API和HTTP请求的调试,它能够发送任何类型的HTTP请求(GET, POST,PUT, DELET…),并且能附带任何数量的参数和Headers。不仅如此,它还提供测试数据和环境配置数据的导入导出。
这个的安装就是一直下一步下一步即可

1.2 Kibana安装

Kibana是一个针对Elasticsearch的开源分析及可视化平台,用来搜索、查看交互存储在Elasticsearch索引中的数据。使用Kibana,可以通过各种图表进行高级数据分析及展示。

Kibana让海量数据更容易理解。它操作简单,基于浏览器的用户界面可以快速创建仪表板(dashboard)实时显示Flasticsearch杳询动态

1 上传kibana

es 数据压缩 es文件压缩器下载_vim_05

[root@localhost ~]# ls
anaconda-ks.cfg                          testjar
apisix                                   公共
data                                     模板
docker-files                             视频
elasticsearch-7.6.1-linux-x86_64.tar.gz  图片
initial-setup-ks.cfg                     文档
kafka                                    下载
kibana-7.6.1-linux-x86_64.tar.gz         音乐
test_centos.tar                          桌面
[root@localhost ~]#

2 解压

[root@localhost ~]# tar -xzf kibana-7.6.1-linux-x86_64.tar.gz -C /opt
[root@localhost ~]# ll /opt
总用量 0
drwx--x--x.  4 root   root    28 12月 17 15:13 containerd
drwxr-xr-x. 10 yytest yytest 167 12月 26 12:20 elasticsearch-7.6.1
drwxr-xr-x. 13 root   root   266 12月 26 12:38 kibana-7.6.1-linux-x86_64
drwxr-xr-x.  2 root   root     6 10月 31 2018 rh
[root@localhost ~]#

3 修改配置

server.port: 5601
server.host: "0.0.0.0"
server.name: "kibana-yy"
elasticsearch.hosts: ["http://127.0.0.1:9200"]
elasticsearch.requestTimeout: 99999
server.port: http	访问端口

server.host: ip地址,0.0.0.0表示可远程访问

server.name: kibana服务名

elasticsearch.hosts: elasticsearch地址

elasticsearch.requestTimeout:请求elasticsearch超时时间,默认为30000,此处可根据情况设置
[root@localhost ~]# vim /opt/kibana-7.6.1-linux-x86_64/config/kibana.yml 
# Kibana is served by a back end server. This setting specifies the port t# Kibana is served by a back end server. This setting specifies the port to use.
#server.port: 5601
.......

# Specifies locale to be used for all localizable strings, dates and number formats.
# Supported languages are the following: English - en , by default , Chinese - zh-CN .
#i18n.locale: "en"
#

server.port: 5601
server.host: "0.0.0.0"
server.name: "kibana-yy"
elasticsearch.hosts: ["http://127.0.0.1:9200"]
elasticsearch.requestTimeout: 99999

<6.1-linux-x86_64/config/kibana.yml" 123L, 5402C 已写入 
[root@localhost ~]#

4 启动kibana

[root@localhost ~]# cd /opt/kibana-7.6.1-linux-x86_64/bin/
[root@localhost bin]# ll
总用量 12
-rwxr-xr-x. 1 root root 656 2月  29 2020 kibana
-rwxr-xr-x. 1 root root 566 2月  29 2020 kibana-keystore
-rwxr-xr-x. 1 root root 634 2月  29 2020 kibana-plugin
[root@localhost bin]# ./kibana --allow-root

最终出现下面的内容就证明启动成功了:

es 数据压缩 es文件压缩器下载_搜索引擎_06


然后在本地浏览器进行访问http://192.168.156.131:5601/,如下图:

es 数据压缩 es文件压缩器下载_elasticsearch_07