elasticsearch + kibana 安装教程
因为elasticsearch需要依赖jdk环境,因此在安装elasticsearch前需要安装jdk,如果系统上已经安装了jdk的小伙伴可以忽略。
安装jdk
可以到官网:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
根据自己的系统配置,下载对应的jdk。建议下载*.tar.gz版本。
# 将压缩包解压到安装目录下
lixyu@lixyu:~$ sudo tar -zxvf jdk-8u221-linux-x64.tar.gz
# 删除安装包
lixyu@lixyu:~$ sudo rm -f elasticsearch-7.4.0-linux-x86_64.tar.gz
配置环境变量
lixyu@lixyu:~$ sudo vim ~/.bashrc
# 在末尾 添加jjdk环境变量配置
export JAVA_HOME=/opt/software/java/jdk1.8.0_221 # 安装路径
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=.:${JAVA_HOME}/bin:$PATH
# 重启jdk
lixyu@lixyu:~$ source ~/.bashrc
查看jdk是否安装成功
# 检查版本,确认是否安装成功
lixyu@lixyu:~$ java -version
# 打印以下信息说明安装成功
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
安装 elasticsearch + kibana
下载地址:https://elasticsearch.cn/download/ elasticsearch
和kibana
都可以在目录下下载,建议下载*.tar.gz版本
注: 每一个版本的elasticsearch 都有一个对应的Kibana版本,Kibana 的主版本号和次版本号不要超过 elasticsearch,建议Kibana和elasticsearch 相同版本
# 解压安装包,使用tar -zxvf 命令,当权限不够时,加 sudo。 注意解压路径建议为安装目录
lixyu@lixyu:~$ sudo tar -zxvf elasticsearch-7.4.0-linux-x86_64.tar.gz
# 删除安装包
lixyu@lixyu:~$ sudo rm -f elasticsearch-7.4.0-linux-x86_64.tar.gz
# 启动elasticsearch
lixyu@lixyu:~$ ./elasticsearch-7.4.0/bin/elasticsearch
# 后台启动elasticsearch
lixyu@lixyu:~$ ./elasticsearch-7.4.0/bin/elasticsearch -d
# 如果出现这样的异常 Exception in thread "main" java.nio.file.AccessDeniedException:原因为权限不够,需要修改权限
# elasticsearch不能使用root权限启动,会报错,只能通过修改所属用户和所属组
修改权限的所属用户和所属组(所属用户名和所属组选择自己本机的用户名和组)
# 递归修改所属组和所属用户
lixyu@lixyu:~$ chown -R lixyu:lixyu ./elasticsearch-7.4.0
修改完成再次执行
lixyu@lixyu:~$./elasticsearch-7.4.0/bin/elasticsearch
打印如下日志,则说明已经安装成功,也可以通过浏览器 http://27.0.0.1:9200 (9200为默认端口),返回的是json数据
...
[2020-01-02T10:45:14,076][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [parent-join]
[2020-01-02T10:45:14,077][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [percolator]
[2020-01-02T10:45:14,078][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [rank-eval]
[2020-01-02T10:45:14,078][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [reindex]
[2020-01-02T10:45:14,079][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [repository-url]
[2020-01-02T10:45:14,079][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [search-business-rules]
[2020-01-02T10:45:14,079][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [spatial]
[2020-01-02T10:45:14,080][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [transport-netty4]
[2020-01-02T10:45:14,080][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [vectors]
[2020-01-02T10:45:14,081][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [x-pack-analytics]
[2020-01-02T10:45:14,081][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [x-pack-ccr]
[2020-01-02T10:45:14,081][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [x-pack-core]
[2020-01-02T10:45:14,081][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [x-pack-deprecation]
[2020-01-02T10:45:14,082][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [x-pack-graph]
[2020-01-02T10:45:14,082][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [x-pack-ilm]
[2020-01-02T10:45:14,083][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [x-pack-logstash]
[2020-01-02T10:45:14,083][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [x-pack-ml]
[2020-01-02T10:45:14,083][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [x-pack-monitoring]
[2020-01-02T10:45:14,084][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [x-pack-rollup]
[2020-01-02T10:45:14,084][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [x-pack-security]
[2020-01-02T10:45:14,084][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [x-pack-sql]
[2020-01-02T10:45:14,085][INFO ][o.e.p.PluginsService ] [lixyu] loaded module [x-pack-voting-o
...
浏览器访问127.0.0.1:9200返回以下json数据,说明elasticsearch安装成功
{
"name" : "lixyu",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "knunU7eMRYKpkfI51T6S6A",
"version" : {
"number" : "7.4.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "22e1767283e61a198cb4db791ea66e3f11ab9910",
"build_date" : "2019-09-27T08:36:48.569419Z",
"build_snapshot" : false,
"lucene_version" : "8.2.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
安装kibana
下载:https://elasticsearch.cn/download/ kibana-7.3.0-linux-x86_64.tar.gz
解压到安装目录下:
# 解压
lixyu@lixyu:~$ sudo tar -zxvf kibana-7.3.0-linux-x86_64.tar.gz
# 删除安装包
lixyu@lixyu:~$ sudo rm -f kibana-7.3.0-linux-x86_64.tar.gz
# 修改所属用户和所属组
lixyu@lixyu:~$ chown -R lixyu:lixyu ./kibana-7.3.0-linux-x86_64
# 启动kibana
lixyu@lixyu:~$ ./kibana-7.3.0-linux-x86_64/bin/kibana
# 后台启动kibana
lixyu@lixyu:~$ nohup ./kibana-7.3.0-linux-x86_64/bin/kibana &
打印一下日志说明安装成功
log [02:46:50.408] [info][status][plugin:ml@7.3.0] Status changed from uninitialized to yellow - Waiting for Elasticsearch
log [02:46:50.513] [info][status][plugin:tilemap@7.3.0] Status changed from uninitialized to yellow - Waiting for Elasticsearch
log [02:46:50.516] [info][status][plugin:watcher@7.3.0] Status changed from uninitialized to yellow - Waiting for Elasticsearch
log [02:46:50.540] [info][status][plugin:grokdebugger@7.3.0] Status changed from uninitialized to yellow - Waiting for Elasticsearch
log [02:46:50.550] [info][status][plugin:dashboard_mode@7.3.0] Status changed from uninitialized to green - Ready
log [02:46:50.553] [info][status][plugin:logstash@7.3.0] Status changed from uninitialized to yellow - Waiting for Elasticsearch
log [02:46:50.566] [info][status][plugin:beats_management@7.3.0] Status changed from uninitialized to yellow - Waiting for Elasticsearch
log [02:46:50.613] [info][status][plugin:apm_oss@7.3.0] Status changed from uninitialized to green - Ready
log [02:46:50.650] [info][status][plugin:apm@7.3.0] Status changed from uninitialized to green - Ready
log [02:46:50.652] [info][status][plugin:code@7.3.0] Status changed from uninitialized to green - Ready
log [02:46:50.655] [info][status][plugin:tile_map@7.3.0] Status changed from uninitialized to green - Ready
log [02:46:50.661] [info][status][plugin:task_manager@7.3.0] Status changed from uninitialized to green - Ready
log [02:46:50.669] [info][status][plugin:maps@7.3.0] Status changed from uninitialized to yellow - Waiting for Elasticsearch
log [02:46:50.688] [info][status][plugin:interpreter@7.3.0] Status changed from uninitialized to green - Ready
log [02:46:50.718] [info][status][plugin:canvas@7.3.0] Status changed from uninitialized to green - Ready
log [02:46:50.725] [info][status][plugin:license_management@7.3.0] Status changed from uninitialized to green - Ready
log [02:46:50.727] [info][status][plugin:cloud@7.3.0] Status changed from uninitialized to green - Ready
log [02:46:50.730] [info][status][plugin:index_management@7.3.0] Status changed from uninitialized to yellow - Waiting for Elasticsearch
log [02:46:50.771] [info][status][plugin:console@7.3.0] Status changed from uninitialized to green - Ready
log [02:46:50.775] [info][status][plugin:console_extensions@7.3.0] Status changed from uninitialized to green - Ready
log [02:46:50.780] [info][status][plugin:notifications@7.3.0] Status changed from uninitialized to green - Ready
log [02:46:50.796] [info][status][plugin:index_lifecycle_management@7.3.0] Status changed from uninitialized to yellow - Waiting for Elasticsearch
log [02:46:50.829] [info][status][plugin:metrics@7.3.0] Status changed from uninitialized to green - Ready
log [02:46:50.916] [info][status][plugin:infra@7.3.0] Status changed from uninitialized to green - Ready
log [02:46:50.918] [info][status][plugin:rollup@7.3.0] Status changed from uninitialized to yellow - Waiting for Elasticsearch
kibana 默认端口为 5601 ,可以通过浏览器访问 129.0.0.1:5601,返回如下页面说明安装成功