elasticsearch-rtf 是国内某大神根据 elasticsearch 安装很多插件改造的,很棒棒,膜拜~
需要安装 Java SE 8以上版本
ubuntu安装 java8
# 安装依赖
sudo apt-get install python-software-properties
# 导入Webupd8 PPA
sudo add-apt-repository ppa:webupd8team/java
# 更新
sudo apt-get update
# 安装
sudo apt-get install oracle-java8-installer
# 查看版本 必须是1.8以上才行
java -version
# 选择版本
sudo update-alternatives --config java # 前面带星号的是当前正在使用的java版本,键入编号选择使用哪个版本。
#编辑/etc/profile,在文件尾添加java环境变量:
sudo vim /etc/profile
# 在最后加上
export JAVA_HOME="/usr/lib/jvm/java-8-oracle/jre/bin"
选择版本
配置环境变量
安装 elasticsearch-rtf
elasticsearch-rtf可以在github找到官方源码
https://github.com/medcl/elasticsearch-rtf
用git下载 服务器没有安装git使用命令 apt-get install git
安装
#用git下载 服务器没有安装git使用命令 ```apt-get install git```安装
# 最好下载家目录下
git clone git://github.com/medcl/elasticsearch-rtf.git -b master --depth 1
安装命令
cd home/ubuntu/elasticsearch-rtf/bin
./elasticsearch
会报错
Java HotSpot(TM) Server VM warning: INFO: os::commit_memory(0x2ae00000, 2080374784, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 2080374784 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /home/ubuntu/elasticsearch-rtf/bin/hs_err_pid15069.log
这是内存不足的意思
需要修改配置文件内容
vim /home/ubuntu/elasticsearch-rtf/config/jvm.options
-Xms2g
-Xmx2g
#修改为
-Xms512m
-Xmx512m
# 再次安装
cd home/ubuntu/elasticsearch-rtf/bin
./elasticsearch
又呦呦呦呦呦报错了!
[2018-04-11T00:19:07,879][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:96) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.cli.Command.main(Command.java:62) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:89) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:82) ~[elasticsearch-5.1.1.jar:5.1.1]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:100) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:176) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:306) ~[elasticsearch-5.1.1.jar:5.1.1]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-5.1.1.jar:5.1.1]
... 6 more
# 单独建用户和用户组。说是为了安全考虑!
groupadd elasticsearch
useradd elasticsearch -g elasticsearch
passwd elasticsearch
# 修改文件归属为elasticsearch用户和组
chown -R elasticsearch:elasticsearch /home/ubuntu/elasticsearch-rtf
# 再次安装!!!
cd home/ubuntu/elasticsearch-rtf/bin
./elasticsearch
#会发现很多警告⚠️不过没关系,知道最后几句话出现
[2018-04-11T00:28:29,232][INFO ][o.e.h.HttpServer ] [Wz_0RtQ] publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}
#再启动一个窗口访问127.0.0.1:9200
#命令 curl 127.0.0.1:9200
#返回类似json值就ojbk了
{
"name" : "Wz_0RtQ",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "LTutLWquRSiU5wkl4Es6eg",
"version" : {
"number" : "5.1.1",
"build_hash" : "5395e21",
"build_date" : "2016-12-06T12:36:15.409Z",
"build_snapshot" : false,
"lucene_version" : "6.3.0"
},
"tagline" : "You Know, for Search"
}
#访问elasticsearch本地服务
curl 127.0.0.1:9200
访问elasticsearch本地服务
# 安装elasticsearch-head
# git:https://github.com/mobz/elasticsearch-head
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
npm run start
# 打开
open http://localhost:9100/
打开显示未连接
需要配置config yaml文件 在最后加上这个
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS,HEAD,GET,POST,PUT,DELETE
http.cors.allow-headers: "X-Requested-With,Content-Type,Content-Length,X-User"
# 注意配置文件中的 : 符号 :后空一格 要不无法识别
#运行 5.X版本后 elasticsearch-head 运行方式
cd elasticsearch-head
npm run start
# 在用户的家目录下下载 5.1.1版本的kibana 因为kibana必须与elasticsearch版本对应
一定要下对应的系统版本,否则安装出错,我踩了两天坑
# 64位系统 :wget https://artifacts.elastic.co/downloads/kibana/kibana-5.5.1-linux-x86_64.tar.gz
# 32位系统:wget https://artifacts.elastic.co/downloads/kibana/kibana-5.1.1-linux-x86.tar.gz
# 解压
tar -xzvf kibana-5.1.1-linux-x86_64.tar.gz 或者 tar -xzvf kibana-5.1.1-linux-x86.tar.gz
# 配置环境变量
/home/ubuntu/kibana-5.1.1-linux-x86/config
vim kibana.yml
# 修改server.host并去掉井号(激活)
server.host: "0.0.0.0"
# 切换目录
cd /home/ubuntu/kibana-5.1.1-linux-x86/bin
#安装
./kibana
kibana安装成功
kibana运行ok
开启 kibana service kibana start
有问题看这个: 查询官方文档,发现Kibana 5.1.2对node版本也有要求,要求的最新版本为6.9.0,从https://nodejs.org/dist/v6.9.2/下载node-v6.9.2-win-x64.zip,解压设置好环境变量,再次运行,kibana终于工作正常。