Elasticsearch 5.x_Elasticsearch集群及插件安装

  由于Elasticsearch要求服务端的客户端的版本必须一致,并且最好jdk版本需要一致,所以Elasticsearch搭建的时候选择版本非常重要,经验之谈,否则会很被动。

一、Elasticserch服务(集群)搭建

    1、官网下载tar或者zip,编译离线进行安装

            该方式不进行说明

    2、下载rpm包方式安装

  官网下载稳定版本rpm包,如:elasticsearch-5.6.3.rpm

            rpm -ivh elasticsearch-5.6.3.rpm(安装)

            rpm -q elasticsearch(查询)

            rpm -e ...(删除-q查询的版本)

            service elasticsearch start|stop|restart(启动|停止|重启Elasticsearch服务)

3、yum方式安装

        1)、下载并安装ES的yum公钥

             rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch

        2)、配置ES的yum源

    首先查看/etc/yum.repos.d/ 下是否存在elasticsearch.repo文件,若没有

            # touch /etc/yum.repos.d/elaselasticsearch.repo

    并# vim /etc/yum.repos.d/elaselasticsearch.repo,内容如下:

[elasticsearch-5.x]

name=Elasticsearch repository for 5.x packages

baseurl=https://artifacts.elastic.co/packages/5.x/yum

gpgcheck=1

gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch

enabled=1

autorefresh=1

type=rpm-md

        # :wq!  进行保存


    3)、yum install elasticsearch

一、Elasticserch插件安装

    说明:第一、5.x版本之前是使用插件方式进行集成,之后的版本不支持插件安装,全部使用单独的服务运行。所有的插件服务都会查找该网段下的es,所以在每个网段下安装一个插件服务即可。需要下载插件的git服务包,则使用git进行下载,若没有安装git,则:

            yum install git 使用yum安装git

            git --version  查看git版本

            yum remove git 删除git

         第二:需要在在浏览器上运行插件,需要在elasticsearch.yml中增加以下配置:

            http.cors.enabled: true

            http.cors.allow-origin: "*"

1、Head插件(查看集群节点数据和简单查询聚合)

   说明:需要安装nodejs、npm和grunt,新版本的nojejs中包含npm,并且需要使用npm安装grunt以运行head服务。若Nodejs不是使用git的方式下载,而是使用线下的方式下载导入,则需要安装xz(yum -install xz)

    1)、使用git下载head服务

            git clone https://github.com/mobz/elasticsearch-head

    2)、yum 方式安装 nodejs 和npm

  添加 epel 源(64位):

            Rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

  导入 key:

            rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

  添加 remi 源

            rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

            rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-remi

       安装:

            curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -

            yum -y install nodejs

       检查是否安装成功:

            nodejs -v   和 npm -v

 

  3)、使用npm安装grunt:

  首先需要使用一个目录,运行:npm init (类似为 git init),生成package.json否则报错,然后安装grunt 客户端安装

            npm install –g grunt–cli  

 

    Grunt 本地服务安装:

            npm install grunt --save-dev

 

     检查是否安装成功

            grunt -version

 

    4)、npm 安装依赖

    在elasticsearch-head目录下执行:

        npm install  

  执行过程却是很慢,若确实太慢或安装失败,可以使用国内镜像(则后续使用cnpm执行命令):

        npm install -g cnpm --registry=https://registry.npm.taobao.org

5)、修改Gruntfile.js

  修改下载的elasticsearch-head 插件目录中的Gruntfile.js文件,查找connect属性,新增hostname:‘0.0.0.0’, 如下图:

 

修改_site/app.js文件中的localhost为本地ip,否则从浏览器调整则不能进行访问,或每次都需要在网页上修改正确的ip地址或域名,

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") ||"http://localhost:9200";  //把该处的localhost修改为IP或域名

6)、启动head服务

  在elasticsearch-head目录中启动服务:

         grunt server

     使用后台方式启动:

         nohup grunt server &exit

     关闭服务进程:

         ps aux|grep head

         Kill 进程号

  浏览器输入:http://ip:9100即可进行访问

2、Bigdesk插件(查看集群节点状态)

    Bigdesk插件使用python命令进行启动即可,linux安装时候会默认安装python,所有可以直接启动:

    git clone https://github.com/hlstudio/bigdesk   // 下载bigdesk插件到服务器

    cd bigdesk/_site/

    python -m SimpleHTTPServer // 启动服务


标识启动成功,在浏览器输入:http://ip:8000 ,点击Connect按钮链接集群,点击集群节点则查看节点的各项指标,如图:

 

3、X-pack插件

    插件中包含以下功能模块(但是为非免费):

        Security(旧称 Shield):为es和kibana提供安全认证

        Alerting(通过 Watcher实现) :服务器指标、集群、数据等报警信息

        Monitoring(旧称 Marvel) :集群监控

        Reporting :能够定时导出自定义生成的报表。

        Graph:分析数据间的关系

        Machine Learning:机器学习

        cd 到elasticsearch的安装目录,如/usr/share/elasticsearch/bin目录,运行:

        ./elasticsearch-plugin install x-pack


猜你喜欢

转载自blog.csdn.net/it_lihongmin/article/details/78378137
今日推荐