ElasticSearch2.3.1环境搭建哪些不为人知的坑

如题所述

ElasticSearch 安装配置

这个有点老套了,具体大家去移步官网:https://www.elastic.co/guide/en/sense/current/installing.html

按照上面博客的步骤,我安装了elasticsearch-2.3.1版本的,Java 1.8版本,可是不知道为何运行不起来

Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)

网站一搜,环境变量的问题,可是结果里里外外搞了三次就是不行,去官网搜一下,解决额 ./bin/elasticsearch -Des.insecure.allow.root=true

具体出现问题可以对号入座。这个是因为权限,分组的问题,可以给es用户组 权限等等 具体问题可以百度其他的

marvel的安装请参考官网

https://www.elastic.co/guide/en/marvel/current/installing-marvel.html
cd /usr/share/elasticsearch
sudo bin/plugin install license
sudo bin/plugin install marvel-agent

现在是:http://localhost:9200/_plugin/marvel/ 是空白,还是不知道啥原因,算了,先把数据库数据导入进来再说

推荐:Elasticsearch入门中文版 http://es.xiaoleilu.com/010_Intro/00_README.htm

https://www.gitbook.com/book/looly/elasticsearch-the-definitive-guide-cn/details

将MySQL中的数据导入ElasticSearch

上面那篇文章的问题,下面将会说明
由于es官网叫停river类的导入插件,因此原始的elasticsearch-jdbc-river变更为elasticsearch-jdbc,成
为一个独立的导入工具。官方提到的同类型工具还有logstash,个人觉得logstash在做数据库同步的时候并不是很好用,有太多坑要填。

目前2.0以上版本并不支持windows的环境,所以各位同学不要试了,windows下最高支持到1.7.3。(2015.12.9)

所以大家看到

./bin/plugin --install river-jdbc --url http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-river-jdbc/1.5.0.5/elasticsearch-river-jdbc-1.5.0.5-plugin.zip</span>

这样的命令 那么就是坑,因为官方不让安装了,因为这个问题,我折腾了好久

具体做法就是

$ wget http://xbib.org/repository/org/xbib/elasticsearch/importer/elasticsearch-jdbc/2.3.1.0/elasticsearch-jdbc-2.3.1.0-dist.zip
$ unzip elasticsearch-jdbc-2.3.1.0-dist.zip
编辑vim import.sh

下面 database是我MySQL数据库名称

table是我mysql的表名称

"index" : "test",
index是es中的数据结构,你可以把他看成mysql中的库

"type" : "stdutent"
type类似于mysql中的表

bin=/root/elasticsearch-2.3.1/elasticsearch-jdbc-2.3.1.0/bin
lib=/root/elasticsearch-2.3.1/elasticsearch-jdbc-2.3.1.0/lib
echo '{
"type" : "jdbc",
"jdbc": {
"url":"jdbc:mysql://localhost:3306/database",
"user":"root",
"password":"root",
"sql":"select * from table",
"index" : "test",
"type" : "stdutent"
}
}'| java \
-cp "${lib}/*" \
-Dlog4j.configurationFile=${bin}/log4j2.xml \
org.xbib.tools.Runner \
org.xbib.tools.JDBCImporter

chmod +x import.sh 根据数据库原因,导入可能有些慢

运行之后./import.sh
往下

[root@localhost elasticsearch-jdbc-2.3.1.0]# curl 'http://localhost:9200/test/student/_search?pretty&q=*'

如果有数据,说明导入成功

任何东西不考虑环境因素,那么坑很多,jdbc具体安装可以参考
温馨提示:答案为网友推荐,仅供参考
相似回答