ElasticSearch2.3.1環境搭建哪些不為人知的坑


 

   首先說明一點,大家最好不要用什么嘗鮮版,用比穩定版就好了,要不麻煩不斷,另外出了問題,最好去官網,或者google搜索,因為這樣靠譜些,要不現在好多都是低版本的,1.4的什么的,結果按照安裝,多少情況下有這樣那樣的問題。

  鄭重聲明,本文ElasticSearch2.3.1最新版的安裝,其他的版本請搭建自行google,最好不要百度,百度一般都是老文章,有些版本問題很多,瞎折騰

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)

所以大家看到

 

[php] view plain  copy
 
 在CODE上查看代碼片派生到我的代碼片
  1. ./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>  

這樣的命令 那么就是坑,因為官方不讓安裝了,因為這個問題,我折騰了好久

 

具體做法就是

 

[php] view plain  copy
 
 在CODE上查看代碼片派生到我的代碼片
  1. $ wget http://xbib.org/repository/org/xbib/elasticsearch/importer/elasticsearch-jdbc/2.3.1.0/elasticsearch-jdbc-2.3.1.0-dist.zip  
  2. $ unzip elasticsearch-jdbc-2.3.1.0-dist.zip  
編輯vim import.sh

 

下面 database是我MySQL數據庫名稱

table是我mysql的表名稱

[php]  view plain  copy
 
 在CODE上查看代碼片派生到我的代碼片
  1. "index" : "test",  
index是es中的數據結構,你可以把他看成mysql中的庫
[php]  view plain  copy
 
 在CODE上查看代碼片派生到我的代碼片
  1. "type" : "stdutent"  
type類似於mysql中的表
[php]  view plain  copy
 
 在CODE上查看代碼片派生到我的代碼片
  1. bin=/root/elasticsearch-2.3.1/elasticsearch-jdbc-2.3.1.0/bin  
  2. lib=/root/elasticsearch-2.3.1/elasticsearch-jdbc-2.3.1.0/lib  
  3. echo '{  
  4. "type" : "jdbc",  
  5. "jdbc": {  
  6. "url":"jdbc:mysql://localhost:3306/database",  
  7. "user":"root",  
  8. "password":"root",  
  9. "sql":"select * from table",  
  10. "index" : "test",  
  11. "type" : "stdutent"  
  12. }  
  13. }'| java \  
  14.     -cp "${lib}/*" \  
  15.     -Dlog4j.configurationFile=${bin}/log4j2.xml \  
  16.     org.xbib.tools.Runner \  
  17.     org.xbib.tools.JDBCImporter  

chmod +x import.sh 根據數據庫原因,導入可能有些慢

運行之后./import.sh
往下

[php]  view plain  copy
 
 在CODE上查看代碼片派生到我的代碼片
  1. [root@localhost elasticsearch-jdbc-2.3.1.0]# curl 'http://localhost:9200/test/student/_search?pretty&q=*'  

 

如果有數據,說明導入成功

 

任何東西不考慮環境因素,那么坑很多,jdbc具體安裝可以參考  這個可能是個完善的方法,我上面只能導入一個表的文件

詳細的jdbc安裝可以參考下面一篇文章

http://bluereader.org/article/122422454



官方插件 https://github.com/jprante/elasticsearch-jdbc

了解下概念吧,下面的jdbc安裝已經不適用了

https://github.com/leotse90/blogs/blob/master/ElasticSearch%E4%B8%8EMySQL%E6%95%B0%E6%8D%AE%E5%90%8C%E6%AD%A5%E4%BB%A5%E5%8F%8A%E4%BF%AE%E6%94%B9%E8%A1%A8%E7%BB%93%E6%9E%84.md

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM