二.ES快速入门

单机版 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)使用插件查看集群状态

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,542评论 6 504
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,822评论 3 394
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,912评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,449评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,500评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,370评论 1 302
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,193评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,074评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,505评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,722评论 3 335
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,841评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,569评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,168评论 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,783评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,918评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,962评论 2 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,781评论 2 354

推荐阅读更多精彩内容