Elasticsearch 分布式安装步骤

Elasticsearch分布式安装

elasticsearch6.2.2下载
链接:https://pan.baidu.com/s/11t3P16BPGkllz6WXgNZy5A
提取码:c3yq
elasticsearch-head-master下载
链接:https://pan.baidu.com/s/1xeXJKVrTDrg1I7PJn3Yy5w
提取码:c37n

Node下载并安装

1.下载node,利用npm来给elasticsrearch-head服务。
wget https://npm.taobao.org/mirrors/node/v11.0.0/node-v11.0.0.tar.gz,安装完成后可以查看到压缩包。

[root@daibin opt]# wget https://npm.taobao.org/mirrors/node/v11.0.0/node-v11.0.0.tar.gz
[root@daibin opt]# ll
-rw-r--r--. 1 root root  36233644 Oct 24  2018 node-v11.0.0.tar.gz

2.进入node文件夹,安装gcc编译器(编译C程序)和g++编译器(编译C++程序),出现complete!安装完成。

[root@daibin opt]# cd /opt/soft/node11
[root@daibin node11]# yum install gcc gcc-c++

3.依次执行命令 ./configure->make->make install。等待每次命令执行完成,make命令执行需要耐心等待,完成后,可以查看node版本。

[root@daibin node11]# ./configure
[root@daibin node11]# make
[root@daibin node11]# make install
[root@daibin node11]# node -v
v11.0.0

安装elasticsearch

在此之前要求虚拟机已安装配置jdk环境。
1.解压安装包 tar -zxf elasticsearch-6.2.2.tar.gz

[root@daibin1 opt]# tar -zxf elasticsearch-6.2.2.tar.gz 
drwxr-xr-x.  8 root root       143 Feb 17  2018 elasticsearch-6.2.2
-rw-r--r--.  1 root root  29049540 May 19 17:08 elasticsearch-6.2.2.tar.gz
[root@daibin1 opt]# mv elasticsearch-6.2.2 /opt/soft/elasticsearch622

2.修改elasticsearch/config/elasticsearch.yml文件,相关内容修改,去除当前行前的“#”。
cluster.name: es-app #集群名称,可以自行修改
node.name: es-1 #节点名称,自行修改
network.host: 192.168.235.133 #主机地址,这里写本机IP
http.port: 9200 #端口
http.cors.enabled: true #设置跨域
http.cors.allow-origin: “*” #设置访问

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
# ---------------------------------- Cluster -----------------------------------
# Use a descriptive name for your cluster:
cluster.name: db-es
# ------------------------------------ Node ------------------------------------
# Use a descriptive name for the node:
node.name: es-1
# Add custom attributes to the node:
#node.attr.rack: r1
# ----------------------------------- Paths ------------------------------------
# Path to directory where to store the data (separate multiple locations by comma):
#path.data: /path/to/data
# Path to log files:
#
#path.logs: /path/to/logs
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.56.110
# Set a custom port for HTTP:
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 
#
# For more information, consult the zen discovery module documentation.
# ---------------------------------- Gateway -----------------------------------
# Block initial recovery after a full cluster restart until N nodes are started:
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
# ---------------------------------- Various -----------------------------------
# Require explicit names when deleting indices:
#action.destructive_requires_name: true
http.cors.enabled: true
http.cors.allow-origin: "*"

为了避免运行出错,先进行相关配置文件的配置,最后运行elasticsearch。
运行出现如下问题以及解决方案:
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
系统文件最大文件数太低
解决方案:修改/etc/security/limits.conf 文件,末尾追加如下四行代码,obj 是用户名。
obj soft nofile 65536
obj hard nofile 131072
obj soft nproc 4096
obj hard nproc 4096

如果没有root以外用户就新增一个用户,obj
命令:useradd obj

[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
虚拟内存太低
解决方案:修改/etc/sysctl.conf ,在文件末尾追加vm.max_map_count = 655360 shift+G跳转文件末尾

[root@daibin bin]# vi /etc/sysctl.conf 
[root@daibin bin]# sysctl -p
vm.max_map_count = 655360

[3]:java.nio.file.AccessDeniedException: …/elasticsearch-6.2.2/config/jvm.options
[obj@daibin bin]$ chown obj /opt/soft/elasticsearch622/ -R

3.执行程序需要切换用户,在elasticsearch/bin目录下执行文件elasticsearch,出现started运行成功。

[root@daibin elasticsearch622]# su obj
[obj@daibin elasticsearch622]$ cd /opt/soft/elasticsearch622/bin
[obj@daibin bin]$ ./elasticsearch
[2020-06-01T19:48:46,138][INFO ][o.e.n.Node               ] [es-1] started

Elasticsearch-head安装

Elasticsearch-head用于监控elasticsearch集群环境
下载压缩包,通过Xftp导入虚拟机的/opt文件下。
1.解压/opt/elasticsearch-head-master.zip ,并移动到 /opt/soft/head。

[root@daibin opt]# unzip elasticsearch-head-master.zip 
[root@daibin opt]# ll
drwxr-xr-x. 6 root root      4096 Jan 25  2019 elasticsearch-head-master
-rw-r--r--. 1 root root    928667 Jun  1 16:50 elasticsearch-head-master.zip
[root@daibin opt]# mv elasticsearch-head-master /opt/soft/head

2.在head文件下执行npm install 安装 head

[root@daibin head]# npm install

出现error:1类型错误,需要修改镜像。

npm config set registry https://registry.npm.taobao.org

出现npm WARN saveError ENOENT: no such file or directory, open 'F:\test\package.json’错误。原因:package.json文件找不到。
解决方案:在head文件下执行npm init -y命令,自动在head文件下生成一个package.json文件。
3.在head文件下执行 npm run start命令,运行head

[root@daibin head]# npm run start
> elasticsearch-head@0.0.0 start /opt/soft/head
> grunt server
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100

注意:headf服务和elasticsearch服务启动需要在两个连接中分别启动。如图以Xshell为例,开启两个相同连接。
在这里插入图片描述
在windows下打开浏览器,输入192.168.56.123:9100,可以实现elasticsearch数据库的可视化访问,进行后续数据库相关操作。
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值