单机版 head插件安装 集群搭建
2.1 安装包下载
1)Elasticsearch官网: https://www.elastic.co/cn/downloads/elasticsearch
2.2 安装Elasticsearch(单节点Linux环境)
1)解压elasticsearch-5.6.1.tar.gz到/opt/module目录下
[itstar@hadoop102 software]$ tar -zxvf elasticsearch-5.6.1.tar.gz -C /opt/module/
2)在/opt/module/elasticsearch-5.6.1路径下创建data和logs文件夹
[itstar@hadoop102 elasticsearch-5.6.1]$ mkdir data
[itstar@hadoop102 elasticsearch-5.6.1]$ mkdir logs
3)修改配置文件/opt/module/elasticsearch-5.2.2/confifig/elasticsearch.yml
[itstar@hadoop102 config]$ pwd
/opt/module/elasticsearch-5.6.1/config
[itstar@hadoop102 config]$ vi elasticsearch.yml
# ---------------------------------- Cluster -----------------------------------
cluster.name: my-application
# ------------------------------------ Node ------------------------------------
node.name: node-102
# ----------------------------------- Paths ------------------------------------
path.data: /opt/module/elasticsearch-5.6.1/data
path.logs: /opt/module/elasticsearch-5.6.1/logs
# ----------------------------------- Memory -----------------------------------
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
# ---------------------------------- Network -----------------------------------
network.host: 192.168.1.102
# --------------------------------- Discovery ----------------------------------
discovery.zen.ping.unicast.hosts: ["hadoop102"]
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
(1)cluster.name
如果要配置集群需要两个节点上的elasticsearch配置的cluster.name相同,都启动可以自动组成集群,这里如果不改cluster.name则默认是cluster.name=my-application,
(2)nodename随意取但是集群内的各节点不能相同
(3)修改后的每行前面不能有空格,修改后的“:”后面必须有一个空格
5)配置linux系统环境(参考:http://blog.csdn.net/satiling/article/details/59697916)
(1)编辑limits.conf 添加类似如下内容
[itstar@hadoop102 elasticsearch-5.6.1]$ sudo vi /etc/security/limits.conf
添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096
(2)进入limits.d目录下修改配置文件。
[itstar@hadoop102 elasticsearch-5.6.1]$ sudo vi /etc/security/limits.d/90- nproc.conf
修改如下内容:
* soft nproc 1024
#修改为
* soft nproc 4096
(3)修改配置sysctl.conf
[itstar@hadoop102 elasticsearch-5.6.1]$ sudo vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
[itstar@hadoop102 elasticsearch-5.6.1]$ sudo sysctl -p
然后,重新启动elasticsearch,即可启动成功。
6)启动elasticsearch
[itstar@hadoop105 elasticsearch-5.6.1]$ bin/elasticsearch
7)测试elasticsearch
[itstar@hadoop102 elasticsearch-5.6.1]$ curl http://hadoop102:9200
curl -XGET 'localhost:9200/_cat/health?v&pretty'
{
"name" : "node-102",
"cluster_name" : "my-application",
"cluster_uuid" : "znZfW5tGQou9rKzb6pG6vA",
"version" : {
"number" : "5.6.1",
"build_hash" : "667b497",
"build_date" : "2017-09-14T19:22:05.189Z",
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
8)安装elasticsearch-head.crx插件
第一种安装方法:
(1)Google浏览器:打开浏览器,进入“更多工具”——>“扩展程序”,将插件拖入即可完成安装
(2)360浏览器:打开浏览器,双击elasticsearch-head.crx插件即可完成安装
(3)使用插件查看节点状态
第二种安装方法:
下载插件:https://github.com/mobz/elasticsearch-head
nodejs官网下载安装包:https://nodejs.org/dist/
node-v6.9.2-linux-x64.tar.xz
拷贝
安装nodejs:
解压
配置环境变量:
export NODE_HOME=/usr/local/node-v6.9.2-linux-x64 export PATH=$PATH:$NODE_HOME/bin
查看node和npm版本:
node -v
npm -v
解压head插件到/opt/module目录下:
unzip elasticsearch-head-master.zip
查看当前head插件目录下有无node_modules/grunt目录:
没有:执行命令创建:npm install grunt --save --registry=https://registry.npm.taobao.org
安装head插件:
npm install -g cnpm --registry=https://registry.npm.taobao.org
安装grunt:
npm install -g grunt-cli --registry=https://registry.npm.taobao.org
编辑Gruntfifile.js
vim Gruntfifile.js
文件93行添加
hostname:'0.0.0.0'
检查head根目录下是否存在base文件夹
没有:将 _site下的base文件夹及其内容复制到head根目录下
mkdir base
cp base/* ../base/
启动grunt server:
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?
执行以下命令:
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
最后一个模块可能安装不成功,但是不影响使用。
浏览器访问head插件:
http://192.168.109.133:9100
9)停止集群
kill -9 进程号
2.3 安装Elasticsearch(多节点集群Linux环境)
1)分发Elasticsearch安装包至hadoop103和hadoop104
[itstar@hadoop102 module]$ xsync elasticsearch-5.6.1/
2)修改hadoop102配置信息
[itstar@hadoop102 config]$ vi elasticsearch.yml
添加如下信息:
node.master: true
node.data: true
3)修改hadoop103配置信息
(1)修改Elasticsearch配置信息
[itstar@hadoop103 config]$ vi elasticsearch.yml
node.name: node-103
node.master: false
node.data: true
network.host: 192.168.1.103
(2)修改Linux相关配置信息(同hadoop102)
4)修改hadoop104配置信息
(1)修改Elasticsearch配置信息
[itstar@hadoop104 config]$ vi elasticsearch.yml
node.name: node-104
node.master: false
node.data: true
network.host: 192.168.1.104
(2)修改Linux相关配置信息(同hadoop102)
5)分别启动三台节点的Elasticsearch
6)使用插件查看集群状态