一、安装包下载
Elasticsearch官网: https://www.elastic.co/products/elasticsearch
二、安装Elasticsearch(单节点Linux环境)
- 解压elasticsearch-5.6.1.tar.gz到/install/目录下
[hadoop@hadoop02 tools]$ tar -xvf elasticsearch-5.6.1.tar.gz -C ../install/
- 在/install/elasticsearch-5.6.1.tar.gz/路径下创建data和logs文件夹
[hadoop@hadoop02 elasticsearch-5.6.1]$ mkdir data
[hadoop@hadoop02 elasticsearch-5.6.1]$ mkdir logs
- 修改配置文件/install/elasticsearch-5.6.1.tar.gz/config/elasticsearch.yml
[hadoop@hadoop02 config]$ vi elasticsearch.yml
# ---------------------------------- Cluster -----------------------------------
cluster.name: my-application
# ------------------------------------ Node ------------------------------------
node.name: node-1
# ----------------------------------- Paths ------------------------------------
path.data:/home/hadoop/install/elasticsearch-5.6.1/data/
path.logs:/home/hadoop/install/elasticsearch-5.6.1/logs/
# ----------------------------------- Memory -----------------------------------
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
# ---------------------------------- Network -----------------------------------
network.host: 192.168.22.133
# --------------------------------- Discovery ----------------------------------
discovery.zen.ping.unicast.hosts: ["hadoop02"]
(1)cluster.name
如果要配置集群需要两个节点上的elasticsearch配置的cluster.name相同,都启动可以自动组成集群,这里如果不改cluster.name则默认是cluster.name=my-application,
(2)nodename随意取但是集群内的各节点不能相同
(3)修改后的每行前面不能有空格,修改后的“:”后面必须有一个空格
4.配置linux系统环境
(1)切换到root用户,编辑limits.conf 添加类似如下内容
[root@hadoop02 elasticsearch-5.6.1]# vi /etc/security/limits.conf
添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
(2)切换到root用户,进入limits.d目录下修改配置文件。
[root@hadoop02 elasticsearch-5.6.1]# vi /etc/security/limits.d/90-nproc.conf
修改如下内容:
* soft nproc 1024
#修改为
* soft nproc 2048
(3)切换到root用户修改配置sysctl.conf
[root@hadoop02 elasticsearch-5.6.1]# vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:可以使配置生效
[root@hadoop02 elasticsearch-5.6.1]# sysctl -p
然后,重新启动elasticsearch,即可启动成功。
(4)启动集群!!!注意切换用户
[hadoop@hadoop02 elasticsearch-5.6.1]$bin/elasticsearch
(5)测试集群
[hadoop@hadoop02 elasticsearch-5.6.1]$curl http://hadoop02:9200
{
"name" : "node-1",
"cluster_name" : "my-application",
"cluster_uuid" : "v-nwhc7ITsmVHECpNQYzHw",
"version" : {
"number" : "5.6.1",
"build_hash" : "57e20f3",
"build_date" : "2018-09-23T13:16:45.703Z",
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
(6)停止集群
kill -9 进程号
三、安装Elasticsearch(多节点集群Linux环境)
多节点同上操作即可,有些地方修改。
四、Elasticsearch head插件安装
(1)下载插件
https://github.com/mobz/elasticsearch-head
elasticsearch-head-master.zip
(2)nodejs官网下载安装包
https://nodejs.org/dist/
node-v6.9.2-linux-x64.tar.xz
(3)将elasticsearch-head-master.zip和node-v6.9.2-linux-x64.tar.xz都导入到linux的/install目录。
(4)安装nodejs
[hadoop@hadoop02 tools]$ tar -zxvf node-v6.9.2-linux-x64.tar.gz -C ../install
(5) 配置nodejs环境变量
[root@hadoop02 install]# vi /etc/profile
export NODE_HOME=/home/hadoop/install/node-v6.9.2-linux-x64
export PATH=$PATH:$NODE_HOME/bin
[root@hadoop02 install]# source /etc/profile
(6) 查看node和npm版本
[root@hadoop02 install]# node -v
v6.9.2
[root@hadoop02 install]# npm -v
3.10.9
(7)解压head插件到/insatll目录下
[hadoop@hadoop02 tools]$ unzip elasticsearch-head-master.zip -d ../insatll/
(8) 查看当前head插件目录下有无node_modules/grunt目录:
没有:执行命令创建:
[hadoop@hadoop02 elasticsearch-head-master]$ npm install grunt --save
(9)安装head插件:
[hadoop@hadoop02 elasticsearch-head-master]$ npm install -g cnpm --registry=https://registry.npm.taobao.org
(10)安装grunt:
[hadoop@hadoop02 elasticsearch-head-master]$ npm install -g grunt-cli
(11)编辑Gruntfile.js
[hadoop@hadoop02 elasticsearch-head-master]$ vim Gruntfile.js
#文件93行添加hostname:'0.0.0.0'
options: {
hostname:'0.0.0.0',
port: 9100,
base: '.',
keepalive: true
}
(12)检查head根目录下是否存在base文件夹
没有:将 _site下的base文件夹及其内容复制到head根目录下
[hadoop@hadoop02 elasticsearch-head-master]$ mkdir base
[hadoop@hadoop02 _site]$ cp base/* ../base/
(13)启动grunt server:
[hadoop@hadoop02 elasticsearch-head-master]$ grunt server -d
如果提示grunt的模块没有安装:
Local Npm module “grunt-contrib-clean” not found. Is it installed?
Local Npm module “grunt-contrib-concat” not found. Is it installed?
Local Npm module “grunt-contrib-watch” not found. Is it installed?
Local Npm module “grunt-contrib-connect” not found. Is it installed?
Local Npm module “grunt-contrib-copy” not found. Is it installed?
Local Npm module “grunt-contrib-jasmine” not found. Is it installed?
Warning: Task “connect:server” not found. Use –force to continue.
执行以下命令:
npm install grunt-contrib-clean -registry=https://registry.npm.taobao.org
npm install grunt-contrib-concat -registry=https://registry.npm.taobao.org
npm install grunt-contrib-watch -registry=https://registry.npm.taobao.org
npm install grunt-contrib-connect -registry=https://registry.npm.taobao.org
npm install grunt-contrib-copy -registry=https://registry.npm.taobao.org
npm install grunt-contrib-jasmine -registry=https://registry.npm.taobao.org
最后一个模块可能安装不成功,但是不影响使用。
(14)浏览器访问head插件
http://hadoop102:9100
(15)启动集群插件后发现集群未连接
[hadoop@hadoop02 config]$ pwd
/home/hadoop/install/elasticsearch-5.6.1/config
[hadoop@hadoop02 config]$ vi elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"
再重新启动elasticsearch。
切记需要输入你自己的IP,点击连接,别傻傻的刷新界面!!!