zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    『Python基础』第4节:基础数据类型初识
    『Python基础练习题』day02
    『Python基础』第1节 Windows环境下安装Python3.x
    Windows安装Mysql5.7.22
    jar 运行报错:找不到或无法加载主类
    linux 下的mysql 连接报错
    将本地Jar包安装到maven仓库中去
    Mysql 中的伪列用法
    Mysql 中的伪列用法1
    关于springboot中文件上传,properties配置
  • 原文地址:https://www.cnblogs.com/Don/p/5529003.html
Copyright © 2011-2022 走看看