• ElasticSearch centos7 安装


    参考:

    https://blog.csdn.net/u014180504/article/details/78733827

    https://blog.csdn.net/youzhouliu/article/details/78885897

    ——————————————————————————————————————————————

    为了避免踩坑,先解决以下问题

    1.  不要用root用户,搭建 ES

    2.  为了避免   这个错误   max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

        需要 [root@localhost config]# vim /etc/security/limits.conf 

        添加以下内容:

    * soft nofile 65536
    * hard nofile 131072
    * soft nproc 2048
    * hard nproc 4096

         我是root用户添加的,要想生效,需要退出用户,重新进入才行(普通用户重新进入才生效)。

    3. 为了避免  max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

       需要在: /etc/sysctl.conf  文件里  set vm.max_map_count=262144

       我设置的是:

     

    4. 机器要安装jdk 1.8+

    -----------------------------------------------------

    单机安装:

    1. 下载 ,url:https://www.elastic.co/downloads/elasticsearch

    2. 上传centos,解压

    tar zxvf elasticsearch-6.5.0.tar.gz 

    3. 配置 config/elasticsearch.yml文件

     在 文件末尾添加如下配置:

    4. 启动: ./bin/elasticsearch

    [2018-11-19T10:55:24,935][INFO ][o.e.n.Node               ] [es-master] started     说明启动成功

    5.浏览器访问  http://192.168.1.157:9200/      注意9200对外开放端口

    -----------------------------------------------

    安装head插件

    1. 下载地址: https://github.com/mobz/elasticsearch-head

         上传, 并 tar -zxvf  解压 

    2. 运行head需要运行node所以也要下载node           https://npm.taobao.org/mirrors/node/latest-v10.x/

         上传,并 unzip 解压

    3.  在  /etc/profile 中添加

    修改完保存并

    source /etc/profile
    1
    这里遇到了大坑啊,由于ES启动时不建议用root账户的所以我直接用其他的账户登录之后修改,但是不让改没权限,然后我就切换到root修改也source 了,但是在切换回其他账户的时候

    echo $NODE_HOME
    1
    死活是空的,我就纳闷了,在看也修改了,这里就埋下了坑,就直接说解决方案吧,哭死了,必须在用当前账户在 source /etc/profile一次才行,在

    echo $NODE_HOME

    安装grunt

    接下来解压下载的master.zip,进入下载的elasticsearch-head-master,
    执行

    [root@localnode1 elasticsearch-head-master]#npm install -g grunt-cli
    1
    接下来检查grunt 安装是否成功

    [root@localnode1 elasticsearch-head]# grunt -version
    grunt-cli v1.3.2
    输出版本说明成功

    修改head插件源码:

    修改服务器监听地址:Gruntfile.js


    修改修改连接地址:_site/app.js

     

    在elasticsearch-head-master目录下

    [root@localnode1 elasticsearch-head]# npm install
    [root@localnode1 elasticsearch-head]# grunt server

    启动成功就可以访问192.168.1.157:9100就可以看到如下界面

     

    ----------------------------------------------

     伪集群搭建:

     1. 把解压的elasticsearch-6.5.0, 复制三份, 分别为es-node1,es-node2,es-node3

    [es@localhost es-node1]$ vim config/elasticsearch.yml 

       cluster.name: elasticsearch

      node.name: es-node1

    network.host: 192.168.1.157

    http.port: 9200

    discovery.zen.ping.unicast.hosts: ["192.168.1.157","192.168.1.157:9301"]

    discovery.zen.minimum_master_nodes: 2

    network.bind_host: 192.168.1.157
    #设置绑定的ip地址,这是master虚拟机的IP
    #
    # network.publish_host: 192.168.1.157
    # #设置其它节点和该节点交互的ip地址
    transport.tcp.port: 9300

    http.cors.enabled: true
    http.cors.allow-origin: "*"

    [es@localhost es-node2]$ vim config/elasticsearch.yml 

    cluster.name: elasticsearch

    node.name: es-node2

    network.host: 192.168.1.157

    http.port: 9201

    discovery.zen.ping.unicast.hosts: ["192.168.1.157","192.168.1.157:9301"]

    discovery.zen.minimum_master_nodes: 2

    network.bind_host: 192.168.1.157
    #设置绑定的ip地址,这是master虚拟机的IP
    #
    # network.publish_host: 192.168.1.157
    # #设置其它节点和该节点交互的ip地址
    transport.tcp.port: 9301

    [es@localhost es-node3]$ vim config/elasticsearch.yml 

    cluster.name: elasticsearch

    node.name: es-node3

    network.host: 192.168.1.157

    http.port: 9202

    discovery.zen.ping.unicast.hosts: ["192.168.1.157","192.168.1.157:9301"]

    discovery.zen.minimum_master_nodes: 2

    network.bind_host: 192.168.1.157
    #设置绑定的ip地址,这是master虚拟机的IP
    #
    # network.publish_host: 192.168.1.157
    #设置其它节点和该节点交互的ip地址
    transport.tcp.port: 9302

    第一步,修改elasticsearch-head下Gruntfile.js文件,内容如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    connect: {
        server: {
            options: {
                hostname: '0.0.0.0',
                port: 9100,
                base: '.',
                keepalive: true
            }
        }
    }

    第二步,修改elasticsearch-head\_siteapp.js 文件。this.base_uri 改为下面的值。

    1
    this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.1.157:9200";

    最后一般,在 elasticsearch.yml  中追加下面的内容。

    1
    2
    http.cors.enabled: true
    http.cors.allow-origin: "*"

    然后重启 elasticsearch ,访问 http://xxxx:9100/ 就可以成功的连接上 9200 端口。

  • 相关阅读:
    Android——ListView学习笔记(一)
    记录笔记——关于request.getRequestDispatcher().forward(request, response)的跳转问题
    Python + openCV 实现图像垂直投影和水平投影
    2020年-第三周助教总结-第二组
    Python记录——字符串的常用方法
    2020年-第二周助教总结-第二组
    Android开发——三种活动跳转方式
    2020年-第一周助教总结-第二组
    Python —— 实例化ndarray对象
    海信聚好看矫恒浩:构建异地双活混合云,利用公共云应对流量突增
  • 原文地址:https://www.cnblogs.com/maohuidong/p/9964420.html
Copyright © 2020-2023  润新知