美文网首页
elasticsearch环境搭建过程

elasticsearch环境搭建过程

作者: black3y | 来源:发表于2016-11-09 16:30 被阅读0次
1. 安装java
    $ apt-get update
    $ apt-get upgrade
    $ apt-get install python-software-properties
    $ apt-get install software-properties-common
    $ add-apt-repository ppa:webupd8team/java
    $ apt-get update
    $ apt-get upgrade
    $ apt-get install oracle-java7-installer
    $ apt-get update
    $ apt-get upgrade
2. 下载需要的版本的elasticsearch
    $ wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.5.2.tar.gz
    $ cp elasticsearch-1.5.2.tar.gz /usr/share/
    $ tar -zxvf elasticsearch-1.5.2.tar.gz
    $ mv elasticsearch-1.5.2 elasticsearch
    $ cd elasticsearch/bin
    $ ./elasticsearch -d    #后台启动
    $ ./elasticsearch       #前台启动
3. 加入系统服务
    $ sudo update-rc.d elasticsearch defaults 95 1
    $ /etc/init.d/elasticsearch start
4. 查看服务是否已经成功启动
    打开 http://es服务器IP:9200 看页面 举例:http://127.0.0.1:9200
5. 安装实用插件
        $ cd elasticsearch/plugin/
        $ ./plugin -i lmenezes/elasticsearch-kopf/      #安装kopf,查看es数据状态 http://127.0.0.1:9200/_plugin/kopf

        $ ./plugin -i mobz/elasticsearch-head           #安装head,查看数据内容   http://127.0.0.1:9200/_plugin/head

        $ ./plugin -install river-csv -url https://github.com/AgileWorksOrg/elasticsearch-river-csv/releases/download/2.2.1/elasticsearch-river-csv-2.2.1.zip               
          #安装csv插件,用于导入csv格式数据
          #github: https://github.com/AgileWorksOrg/elasticsearch-river-csv

        $ ./plugin -i 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      
          #安装jdbc

        #安装MySQL JDBC driver
        $ curl -o mysql-connector-java-5.1.33.zip -L 'http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.33.zip/from/http://cdn.mysql.com/'
        $ unzip mysql-connector-java-5.1.33.zip
        $ cd mysql-connector-java-5.1.33
        $ cp mysql-connector-java-5.1.33-bin.jar /usr/share/elasticsearch/plugins/jdbc
        $ chmod 644 /usr/share/elasticsearch/plugins/jdbc
6. 卸载插件
    ./plugin -remove river-mongodb  #卸载river-mongodb
7. 根据需求修改配置
    (1)elasticsearch/bin/elasticsearch.in.sh,将内存最大值和最小值设置成相同的(如果内存64G,可设置30G,最大不能超过32G)
        if [ "x$ES_MIN_MEM" = "x" ]; then
            ES_MIN_MEM=30g
        fi
        if [ "x$ES_MAX_MEM" = "x" ]; then
            ES_MAX_MEM=30g
        fi

    (2)elasticsearch/config/elasticsearch.yml,修改如下参数
        cluster.name: shenfengbkup #修改此处参数,默认elasticsearch,避免内网下存在相同集群名
        http.port: 9200 #可选修改
        index.number_of_replicas: 0  #分片副本数,可修改为0,默认为1,可选修改
        index.number_of_shards: 5   #分片数,默认为5 ,若index数据量不大可修改为1

        在最后添加:
            http.cors.enabled: true
            http.cors.allow-origin: "/.*/"

相关文章

网友评论

      本文标题:elasticsearch环境搭建过程

      本文链接:https://www.haomeiwen.com/subject/xtctpttx.html