Elasticsearch学习(一):虚拟机上搭建 Elasticsearch 2.4.4 集群(压缩包安装)
博客专区 > howsweet 的博客 > 博客详情
Elasticsearch学习(一):虚拟机上搭建 Elasticsearch 2.4.4 集群(压缩包安装)
howsweet 发表于4个月前
Elasticsearch学习(一):虚拟机上搭建 Elasticsearch 2.4.4 集群(压缩包安装)
  • 发表于 4个月前
  • 阅读 18
  • 收藏 0
  • 点赞 0
  • 评论 0

腾讯云 新注册用户 域名抢购1元起>>>   

> 本文开始前已通过 VMware 创建好三个虚拟机并安装好jdk: 操作系统:CentOS Linux release 7.2.1511 (Core) 64位 JDK版本:1.7.0_80

###一、 准备安装文件

###二、 安装 Elasticsearch > 以下安装过程以一台虚拟机为例,其它虚拟机安装步骤相同

  1. 将Elasticsearch压缩包拷贝到虚机 /usr/local/howsweetiam/elasticsearch-2.4.4 目录下(任意目录均可);

  2. 到压缩包存放目录,解压安装包,并将解压后的文件夹重命名为elasticsearch(重命名随意);

    cd /usr/local/howsweetiam/elasticsearch-2.4.4
    tar -zxvf elasticsearch-2.4.4.tar.gz
    mv elasticsearch-2.4.4 elasticsearch
    
  3. 由于Elasticsearch可以接收用户输入的脚本并且执行,为了系统安全考虑,不允许root账号启动,所以要为Elasticsearch新建用户并授权,然后切换到elasticsearch用户;

    groupadd elasticsearch
    useradd elasticsearch -g elasticsearch -p elasticsearch
    chown -R elasticsearch:elasticsearch /usr/local/howsweetiam/elasticsearch-2.4.4/elasticsearch
    su elasticsearch
    
  4. 修改配置文件elasticsearch.yml vi /usr/local/howsweetiam/elasticsearch-2.4.4/elasticsearch/config/elasticsearch.yml 修改以下几个配置项:

    • cluster.name: elasticsearch(集群名称,三个节点配置需保证一致)
    • node.name: mdw(节点名称)
    • network.host: 192.168.222.130(对外服务的ip地址,设置为节点ip)
    • http.port: 9200(对外服务的http端口,默认为9200)
    • discovery.zen.ping.unicast.hosts: ["192.168.222.130", "192.168.222.131", "192.168.222.132"](集群所有节点ip)

    修改完成后保存。

  5. 启动elasticsearch服务 /usr/local/howsweetiam/elasticsearch-2.4.4/elasticsearch/bin/elasticsearch 如果想后台启动上面命令后加 "-d" 参数。

  6. 启动成功 出现下列信息说明启动完成:

    [2017-04-06 11:38:02,626][INFO ][node                     ] [Pixx] version[2.4.4], pid[3100], build[fcbb46d/2017-01-03T11:33:16Z]
    [2017-04-06 11:38:02,627][INFO ][node                     ] [Pixx] initializing ...
    [2017-04-06 11:38:03,119][INFO ][plugins                  ] [Pixx] modules [lang-groovy, reindex, lang-expression], plugins [], sites []
    [2017-04-06 11:38:03,142][INFO ][env                      ] [Pixx] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [48.4gb], net total_space [49.9gb], spins? [unknown], types [rootfs]
    [2017-04-06 11:38:03,148][INFO ][env                      ] [Pixx] heap size [1015.6mb], compressed ordinary object pointers [true]
    [2017-04-06 11:38:03,148][WARN ][env                      ] [Pixx] max file descriptors [4096] for elasticsearch process likely too low, consider increasing to at least [65536]
    [2017-04-06 11:38:04,939][INFO ][node                     ] [Pixx] initialized
    [2017-04-06 11:38:04,943][INFO ][node                     ] [Pixx] starting ...
    [2017-04-06 11:38:05,004][INFO ][transport                ] [Pixx] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}, {[::1]:9300}
    [2017-04-06 11:38:05,007][INFO ][discovery                ] [Pixx] elasticsearch/D4XWDBMyROC4cATklF7ipg
    [2017-04-06 11:38:08,136][INFO ][cluster.service          ] [Pixx] new_master {Pixx}{D4XWDBMyROC4cATklF7ipg}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
    [2017-04-06 11:38:08,180][INFO ][http                     ] [Pixx] publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}, {[::1]:9200}
    [2017-04-06 11:38:08,180][INFO ][node                     ] [Pixx] started
    [2017-04-06 11:38:08,191][INFO ][gateway                  ] [Pixx] recovered [0] indices into cluster_state
    

    测试:curl -XGET "http://192.168.222.130:9200/" 启动成功,返回如下结果:

    {
        "name" : "mdw",
        "cluster_name" : "howsweetiam",
        "cluster_uuid" : "Qc01DKu_RquiCbWGZVGppQ",
        "version" : {
            "number" : "2.4.4",
            "build_hash" : "fcbb46dfd45562a9cf00c604b30849a6dec6b017",
            "build_timestamp" : "2017-01-03T11:33:16Z",
            "build_snapshot" : false,
            "lucene_version" : "5.5.2"
        },
        "tagline" : "You Know, for Search"
    }
    
    
  7. 此时如果从电脑本机打开浏览器访问 http://192.168.222.130:9200/ ,出现拒绝连接的提示,可采用以下方法解决:

    • 修改虚机节点的hosts文件:vi /etc/hosts 将 127.0.0.1 修改为 0.0.0.0 ,保存退出。
    • 重新从本机浏览器访问 http://192.168.222.130:9200/ 成功。
标签: ElasticSearch
共有 人打赏支持
粉丝 4
博文 7
码字总数 6036
×
howsweet
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: