ElasticSearch5.2.2版本的集羣安裝部署及插件head安裝

簡介

ElasticSearh作爲目前比較流行的全文搜索引擎。目前使用的公司以及個人比較多。其是基於RESTful web接口使用java語言開發,其能夠達到實時搜索,穩定,可靠,快速,安裝使用方便。本篇簡單介紹下如何在linux系統上進行安裝配置。

安裝環境

1. 操作系統:CentOS 7.4
2. 安裝Elasticsearch前提條件:JDK1.8及以上,我這裏使用的版本是 jdk1.8.0_181
3. 目前Elasticsearch最新的版本是 7.5.1,我這裏使用的版本是 5.2.2

安裝及配置

說明:ElasticSearch的運行不能用root執行,必須普通用戶來啓動。


一、jdk 安裝
JDK安裝
二、elasticsearch安裝

1.創建用戶
[root@test-01 ~]# groupadd elastic
[root@test-01 ~]# useradd elastic -g elastic -m
2.下載安裝
[root@test-01 ~]# wget  https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.tar.gz
[root@test-01 ~]# tar zxvf  elasticsearch-5.2.2.tar.gz
[root@test-01 ~]# mv  elasticsearch-5.2.2  /usr/loca/elasticsearch
//創建數據及日誌目錄
[root@test-01 ~]# mkdir -p /data/elasticsearch/data
[root@test-01 ~]# mkdir -p /data/elasticsearch/logs
//添加權限
[root@test-01 ~]# chown elastic:elastic elasticsearch   /usr/loca/elasticsearch  -R
[root@test-01 ~]# chown elastic:elastic elasticsearch   /data/elasticsearch/logs  -R
[root@test-01 ~]# chown elastic:elastic elasticsearch   /data/elasticsearch/data  -R
3.修改配置文件(修改方法參考如下:)集羣配置文件略同
[root@test-01 ~]# cat /usr/local/elasticsearch/config/elasticsearch.ym l egrep -v '^(#|$)'
cluster.name: es_cluster
node.name: node-01  //隨機定義
node.master: true      //主true 從false
node.data: true
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
network.host: 192.168.0.164
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["192.168.0.165", "192.168.0.164"]
discovery.zen.minimum_master_nodes: 1
xpack.security.enabled: true
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,Content-Type
xpack.security.authc:
accept_default_password: true
解釋說明:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false 一看就知道是關於內用訪問的方面的配置
cluster.name 集羣名字,同一個集羣中使用相同名字,單機就隨意
node.name: node-01 節點名字
node.master: 是否爲集羣的master機器
node.data: true 是否作爲數據節點
network.host: 192.168.0.164 這個不用自然是配置ip地址的,也可以配置成0.0.0.0
http.port: 9200 端口號,不配置的話默認9200
discovery.zen.ping.unicast.hosts: [“192.168.0.165”,”192.168.0.164”] 這個就是配置集羣的時候要用的到了,[]中填上集羣中其他集羣的ip的地址,如果是master的話請把所有salve的機器地址填上
discovery.zen.minimum_master_nodes: 1 關於這個值配置多少合適的話大家去搜一下,自己權衡一下集羣,這裏我用了3臺機器模擬集羣,所以填上2。
http.cors.enabled: true 這個參數的設置和下面一個配置就關於ip的訪問策略了,如果你發現其他ip地址訪問不了就有可以這參數沒有配置
4.調整系統參數
[root@test-01 ~]# vim /etc/security/limits.conf
root soft nofile 65535
root hard nofile 65535
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048

[root@test-01 ~]# vim /etc/sysctl.conf
vm.max_map_count=662144
vm.overcommit_memory = 1
執行命令,使配置文件生效
[root@test-01 ~]# sysctl –p
5.啓動與停止
[root@test-01 ~]# su elastic -c "/usr/local/elasticsearch/bin/elasticsearch -d"
[root@test-01 ~]# kill -9 `ps aux|grep [e]lasticsearch |grep -v tail|awk '{print $2}'`
三、安裝head插件
一般安裝在/usr/local/elasticsearch/elasticsearch-head路徑下
1.安裝node
源碼安裝方法如下:
[root@test-01 ~]# yum -y install gcc make gcc-c++ openssl-devel
下載源碼及解壓:
[root@test-01 ~]# wget  http://nodejs.org/dist/v4.4.7/node-v4.4.7-linux-x64.tar.gz
[root@test-01 ~]# tar zxvf  node-v4.4.7-linux-x64.tar.gz
[root@test-01 ~]# mv node-v4.4.7-linux-x64 /usr/local/node
[root@test-01 ~]# ln -s  /usr/local/node/bin/node  /usr/local/bin/node
[root@test-01 ~]# ln -s  /usr/local/node/bin/npm  /usr/local/bin/npm
[root@test-01 ~]# node -v
2.安裝grunt
grunt是一個很方便的構建工具,可以進行打包壓縮、測試、執行等等的工作,5.2裏的head插件就是通過grunt啓動的。因此需要安裝一下grunt:
[root@test-01 ~]# git clone git://github.com/mobz/elasticsearch-head.git
[root@test-01 ~]# cd elasticsearch-head
[root@test-01 ~]# npm install -g grunt-cli  //執行後會生成node_modules文件夾
[root@test-01 ~]# npm install
注意:5.0以上,elasticsearch-head 不能放在elasticsearch的 plugins、modules 目錄下,否則elasticsearch啓動會報錯。
修改vim Gruntfile.js文件:增加hostname屬性,設置爲*

ElasticSearch5.2.2版本的集羣安裝部署及插件head安裝

3.啓動grunt
[root@test-01 ~]# grunt server &
不安裝 grunt 也可以啓動:
[root@test-01 ~]# npm run start &

ElasticSearch5.2.2版本的集羣安裝部署及插件head安裝
ElasticSearch5.2.2版本的集羣安裝部署及插件head安裝

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章